jwtauth

package
v0.0.0-...-9bd63dd Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	GenerateAccessToken(UserID int64, UserName string) (string, error)

	GenerateRefreshToken(tokenString string, expire time.Duration) (string, error)

	ParseToken(tokenString string) error

	DestroyToken(tokenString string) error
}

type JwtAuth

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

func New

func New(opts ...Option) *JwtAuth

func (*JwtAuth) GenerateToken

func (a *JwtAuth) GenerateToken(userId int64, userName string) (string, error)

func (*JwtAuth) GenerateUserClaims

func (a *JwtAuth) GenerateUserClaims(userId int64, userName string) *UserClaims

func (*JwtAuth) ParseToken

func (a *JwtAuth) ParseToken(tokenString string) (*UserClaims, error)

type Option

type Option func(*options)

func WithExpired

func WithExpired(expired int) Option

func WithKeyfunc

func WithKeyfunc(keyFunc jwt.Keyfunc) Option

func WithSigningKey

func WithSigningKey(key interface{}) Option

func WithSigningMethod

func WithSigningMethod(method jwt.SigningMethod) Option

type TokenInfo

type TokenInfo interface {
	GetAccessToken() string

	GetRefreshToken() string
}

type UserClaims

type UserClaims struct {
	UserID   int64
	UserName string
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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