Versions in this module Expand all Collapse all v0 v0.1.0 Jun 2, 2025 Changes in this version + var ErrSignTokenFailed = errors.Unauthorized(reason, "Failed to sign token") + var ErrTokenExpired = errors.Unauthorized(reason, "Token has expired") + var ErrTokenInvalid = errors.Unauthorized(reason, "Token is invalid") + var ErrTokenParseFail = errors.Unauthorized(reason, "Fail to parse token") + var ErrUnSupportSigningMethod = errors.Unauthorized(reason, "Wrong signing method") + var MessageSignTokenFailed = &goi18n.Message + var MessageTokenExpired = &goi18n.Message + var MessageTokenInvalid = &goi18n.Message + var MessageTokenParseFail = &goi18n.Message + var MessageUnSupportSigningMethod = &goi18n.Message + type JWTAuth struct + func New(store Storer, opts ...Option) *JWTAuth + func (a *JWTAuth) Destroy(ctx context.Context, refreshToken string) error + func (a *JWTAuth) ParseClaims(ctx context.Context, refreshToken string) (*jwt.RegisteredClaims, error) + func (a *JWTAuth) Release() error + func (a *JWTAuth) Sign(ctx context.Context, userID string) (authn.IToken, error) + type Option func(*options) + func WithExpired(expired time.Duration) Option + func WithIssuer(issuer string) Option + func WithKeyfunc(keyFunc jwt.Keyfunc) Option + func WithSigningKey(key any) Option + func WithSigningMethod(method jwt.SigningMethod) Option + func WithTokenHeader(header map[string]any) Option + type Storer interface + Check func(ctx context.Context, accessToken string) (bool, error) + Close func() error + Delete func(ctx context.Context, accessToken string) (bool, error) + Set func(ctx context.Context, accessToken string, expiration time.Duration) error