This commit is contained in:
Daniel Ponte 2022-11-13 11:59:15 -05:00
parent 9b38bdbca9
commit 68b971f65a
2 changed files with 3 additions and 25 deletions

View file

@ -14,33 +14,14 @@ import (
"dynatron.me/x/blasphem/pkg/auth/provider"
)
/*
{
"id": "18912b07b66e48558a44c058bf90f1d4",
"user_id": "1bd642b0ed9f410280f622d1d358102b",
"client_id": "https://oauth-redirect.googleusercontent.com/",
"client_name": null,
"client_icon": null,
"token_type": "normal",
"created_at": "2021-12-13T04:34:47.169033+00:00",
"access_token_expiration": 1800.0,
"token": "f93f87557ca616508c675f05b85921d07fdf764efc34c74a81daeebd71ab899a6e8cd5dec94d0ae36499ff281f2efcf715c763ad73eabadd2f586b827057043d",
"jwt_key": "f4507c01fe19b1d99c4b628cadc8208f7838dbdda0a9a051fd029cefdf6f619b0728d6b0a4d3d96ee68614b035054952faa14c48ae36bd212e28d602864f6d1c",
"last_used_at": "2021-12-13T04:34:47.169738+00:00",
"last_used_ip": "108.177.68.93",
"credential_id": "5daeb186d2a943328cbb984f135974cb",
"version": "2021.12.0"
},
*/
type (
TokenType string
TokenTimestamp time.Time
RefreshTokenID string
ExpSeconds float64
ExpireSecs float64
)
func (f ExpSeconds) MarshalJSON() ([]byte, error) {
func (f ExpireSecs) MarshalJSON() ([]byte, error) {
if float64(f) == float64(int(f)) {
return []byte(strconv.FormatFloat(float64(f), 'f', 1, 32)), nil
}
@ -70,7 +51,7 @@ type RefreshToken struct {
ClientIcon *string `json:"client_icon"`
TokenType TokenType `json:"token_type"`
CreatedAt *TokenTimestamp `json:"created_at"`
AccessTokenExpiration ExpSeconds `json:"access_token_expiration"`
AccessTokenExpiration ExpireSecs `json:"access_token_expiration"`
Token string `json:"token"`
JWTKey string `json:"jwt_key"`
LastUsedAt *TokenTimestamp `json:"last_used_at"`

View file

@ -4,8 +4,6 @@ import (
"encoding/json"
"fmt"
"github.com/rs/zerolog/log"
"dynatron.me/x/blasphem/pkg/auth/provider"
"dynatron.me/x/blasphem/pkg/storage"
)
@ -35,7 +33,6 @@ func (a *Authenticator) newAuthStore(s storage.Store) (as *authStore, err error)
for _, u := range as.Users {
as.userMap[u.ID] = &u
log.Debug().Interface("user", u).Msg("user")
}
for _, c := range as.Credentials {