Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateAccessToken(usr user.User, key []byte, expiresIn time.Duration) (string, error)
- func GenerateRefreshToken(usr user.User, key []byte, expiresIn time.Duration) (string, error)
- func GenerateTokenPair(usr user.User, key []byte) (accessToken string, refreshToken string, err error)
- type AccessToken
- type RefreshToken
- type UserInfo
Constants ¶
View Source
const ( AccessTokenExpiration = time.Minute * 15 RefreshTokenExpiration = time.Hour * 48 )
View Source
const AccessTokenIssuer = "semaphore"
Variables ¶
View Source
var DefaultJwtKeyFunc = func(key []byte) jwt.Keyfunc { return func(token *jwt.Token) (interface{}, error) { return key, nil } }
Functions ¶
func GenerateAccessToken ¶
func GenerateRefreshToken ¶
Types ¶
type AccessToken ¶
type AccessToken struct { jwt.RegisteredClaims User UserInfo `json:"user"` }
AccessToken represents jwt claims for user.
func ValidateAccessToken ¶
func ValidateAccessToken(token string, keyFunc jwt.Keyfunc) (*AccessToken, error)
type RefreshToken ¶
type RefreshToken struct {
jwt.RegisteredClaims
}
RefreshToken represents jwt claims for user refresh token.
func ValidateRefreshToken ¶
func ValidateRefreshToken(token string, keyFunc jwt.Keyfunc) (*RefreshToken, error)
Click to show internal directories.
Click to hide internal directories.