jwt

package
v0.0.0-...-a95e806 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenInvalid     = errors.Unauthorized(reason, "Token is invalid")
	ErrTokenExpired     = errors.Unauthorized(reason, "Token has expired")
	ErrTokenParseFailed = errors.Unauthorized(reason, "Failed to parse token")
	ErrSigningMethod    = errors.Unauthorized(reason, "Wrong signing method")
	ErrSignTokenFailed  = errors.Unauthorized(reason, "Failed to sign token")
)
View Source
var (
	MessageTokenInvalid     = &i18n.Message{ID: "jwt.token.invalid", Other: ErrTokenInvalid.Error()}
	MessageTokenExpired     = &i18n.Message{ID: "jwt.token.expired", Other: ErrTokenExpired.Error()}
	MessageTokenParseFailed = &i18n.Message{ID: "jwt.token.parse.failed", Other: ErrTokenParseFailed.Error()}
	MessageSigningMethod    = &i18n.Message{ID: "jwt.wrong.signing.method", Other: ErrSigningMethod.Error()}
	MessageSignTokenFailed  = &i18n.Message{ID: "jwt.token.sign.failed", Other: ErrSignTokenFailed.Error()}
)

Functions

This section is empty.

Types

type JWTAuth

type JWTAuth struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *JWTAuth

func (*JWTAuth) Destroy

func (a *JWTAuth) Destroy(ctx context.Context, accessToken string) error

func (*JWTAuth) ParseClaims

func (a *JWTAuth) ParseClaims(ctx context.Context, accessToken string) (*jwt.RegisteredClaims, error)

func (*JWTAuth) Release

func (a *JWTAuth) Release() error

func (*JWTAuth) Sign

func (a *JWTAuth) Sign(ctx context.Context, userId string) (authn.IToken, error)

type Option

type Option func(*options)

func WithExpired

func WithExpired(expired time.Duration) Option

func WithIssuer

func WithIssuer(issuer string) Option

func WithKeyFunc

func WithKeyFunc(keyFunc jwt.Keyfunc) Option

func WithSigningKey

func WithSigningKey(key any) Option

func WithSigningMethod

func WithSigningMethod(method jwt.SigningMethod) Option

func WithTokenHeader

func WithTokenHeader(header map[string]any) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL