token

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAllowTokenHeader

func WithAllowTokenHeader[T any](header string) kit.Option[Management[T]]

func WithDecryptKey

func WithDecryptKey(decryptKey string) kit.Option[Options]

func WithExposeAccessHeader

func WithExposeAccessHeader[T any](header string) kit.Option[Management[T]]

func WithExposeRefreshHeader

func WithExposeRefreshHeader[T any](header string) kit.Option[Management[T]]

func WithGenIDFunc

func WithGenIDFunc(fn func() string) kit.Option[Options]

func WithIssuer

func WithIssuer(issuer string) kit.Option[Options]

func WithMethod

func WithMethod(method jwt.SigningMethod) kit.Option[Options]

func WithNowFunc

func WithNowFunc[T any](nowFunc func() time.Time) kit.Option[Management[T]]

func WithRefreshJWTOptions

func WithRefreshJWTOptions[T any](refreshOpts Options) kit.Option[Management[T]]

func WithRotateRefreshToken

func WithRotateRefreshToken[T any](isRotate bool) kit.Option[Management[T]]

Types

type Management

type Management[T any] struct {
	// contains filtered or unexported fields
}

func NewManagement

func NewManagement[T any](accessJWTOptions Options,
	opts ...kit.Option[Management[T]]) *Management[T]

func (*Management[T]) GenerateAccessToken

func (m *Management[T]) GenerateAccessToken(data T) (string, error)

func (*Management[T]) GenerateRefreshToken

func (m *Management[T]) GenerateRefreshToken(data T) (string, error)

func (*Management[T]) MiddlewareBuilder

func (m *Management[T]) MiddlewareBuilder() *MiddlewareBuilder[T]

func (*Management[T]) Refresh

func (m *Management[T]) Refresh(ctx *mist.Context)

func (*Management[T]) SetClaims

func (m *Management[T]) SetClaims(ctx *mist.Context, claims RegisteredClaims[T])

func (*Management[T]) VerifyAccessToken

func (m *Management[T]) VerifyAccessToken(token string, opts ...jwt.ParserOption) (RegisteredClaims[T], error)

func (*Management[T]) VerifyRefreshToken

func (m *Management[T]) VerifyRefreshToken(token string, opts ...jwt.ParserOption) (RegisteredClaims[T], error)

type Manager

type Manager[T any] interface {
	MiddlewareBuilder() *MiddlewareBuilder[T]

	GenerateAccessToken(data T) (string, error)

	VerifyAccessToken(token string, opts ...jwt.ParserOption) (RegisteredClaims[T], error)

	GenerateRefreshToken(data T) (string, error)

	VerifyRefreshToken(token string, opts ...jwt.ParserOption) (RegisteredClaims[T], error)

	SetClaims(ctx *mist.Context, claims RegisteredClaims[T])
}

type MiddlewareBuilder

type MiddlewareBuilder[T any] struct {
	// contains filtered or unexported fields
}

func (*MiddlewareBuilder[T]) Build

func (m *MiddlewareBuilder[T]) Build() mist.Middleware

func (*MiddlewareBuilder[T]) IgnorePath

func (m *MiddlewareBuilder[T]) IgnorePath(path ...string) *MiddlewareBuilder[T]

func (*MiddlewareBuilder[T]) IgnorePathFunc

func (m *MiddlewareBuilder[T]) IgnorePathFunc(fn func(path string) bool) *MiddlewareBuilder[T]

type Options

type Options struct {
	Expire        time.Duration
	EncryptionKey string
	DecryptKey    string
	Method        jwt.SigningMethod
	Issuer        string
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(expire time.Duration, encryptionKey string,
	opts ...kit.Option[Options]) Options

type RegisteredClaims

type RegisteredClaims[T any] struct {
	Data T `json:"data"`
	jwt.RegisteredClaims
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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