jwtx

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidToken = errors.New("Invalid token")

Functions

This section is empty.

Types

type Auth

type Auth interface {
	GenerateToken(ctx context.Context, subject string) (TokenInfo, error)
	DestroyToken(ctx context.Context, token string) error
	ParseSubject(ctx context.Context, token string) (string, error)
	Release(ctx context.Context) error
}

func InitAuth

func InitAuth(ctx context.Context) (Auth, func(), error)

func New

func New(store Store, opts ...Option) Auth

type Option

type Option func(*options)

func SetExpired

func SetExpired(expired int) Option

func SetSigningKey

func SetSigningKey(key string) Option

func SetSigningMethod

func SetSigningMethod(method jwt.SigningMethod) Option

type Store

type Store interface {
	Set(ctx context.Context, token string, expiration time.Duration) error
	Delete(ctx context.Context, token string) error
	Check(ctx context.Context, token string) (bool, error)
	Close(ctx context.Context) error
}

func NewStoreWithCache

func NewStoreWithCache(cache cachex.Cache, opts ...StoreOption) Store

type StoreOption

type StoreOption func(*storeOptions)

func WithCacheNS

func WithCacheNS(ns string) StoreOption

type TokenInfo

type TokenInfo interface {
	GetAccessToken() string
	GetRefreshToken() string
	GetTokenType() string
	GetExpiresAt() int64
	EncodeToJSON() ([]byte, error)
}

Jump to

Keyboard shortcuts

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