Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrInvalidJWT = "Invalid JWT." ErrExpiredJWT = "Token has expired." )
Variables ¶
View Source
var (
ErrJWT = errors.New("JWT error")
)
Functions ¶
func EncodeJWT ¶
func EncodeJWT(ctx context.Context, jwtSecret, userID string, expiresIn time.Duration, tokenType JWTType) (string, *apierror.APIError)
EncodeJWT encodes a new JWT for the given user ID, expiration, and token type.
func GenOpaqueToken ¶
GenOpaqueToken generates a new opaque token.
func SanitizeJWT ¶
SanitizeJWT sanitizes a given JWT for display.
Types ¶
type JWTClaims ¶
type JWTClaims struct {
jwt.RegisteredClaims
TokenType JWTType `json:"token_type"`
}
type JWTType ¶
type JWTType string
JWTType represents the type of JWT token.
const ( // JWTTypeAccess represents an access token. JWTTypeAccess JWTType = "access" // JWTTypePasswordReset represents a password reset token. JWTTypePasswordReset JWTType = "password_reset" // JWTTypeMagicLogin represents a magic login token sent in the "already registered" email. JWTTypeMagicLogin JWTType = "magic_login" )
Click to show internal directories.
Click to hide internal directories.