chauth

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("Token is expired")
	TokenNotValidYet = errors.New("Token not active yet")
	TokenMalformed   = errors.New("That's not even a token")     //格式或者解析错误
	TokenInvalid     = errors.New("Couldn't handle this token:") //校验不通过
)

Functions

This section is empty.

Types

type JWT

type JWT struct {
	SigningKey []byte
	Life       int64
}

JWT Life for second

func NewJWT

func NewJWT(key []byte, second int64) *JWT

func NewJWTString

func NewJWTString(key string, second int64) *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(claim jwt.Claims) (string, error)

CreateToken 创建一个token

func (*JWT) CreateTokenHash

func (j *JWT) CreateTokenHash(method jwt.SigningMethod, claim jwt.Claims) (string, error)

func (*JWT) NewBasicClaim

func (j *JWT) NewBasicClaim(start time.Time) jwt.RegisteredClaims

func (*JWT) ParseToken

func (j *JWT) ParseToken(claim jwt.Claims, tokenString string, options ...jwt.ParserOption) (jwt.Claims, error)

ParseToken 解析token

ErrInvalidKey      = errors.New("key is invalid")
ErrInvalidKeyType  = errors.New("key is of invalid type")
ErrHashUnavailable = errors.New("the requested hash function is unavailable")

ErrTokenMalformed        = errors.New("token is malformed")
ErrTokenUnverifiable     = errors.New("token is unverifiable")
ErrTokenSignatureInvalid = errors.New("token signature is invalid")

ErrTokenInvalidAudience  = errors.New("token has invalid audience")
ErrTokenExpired          = errors.New("token is expired")
ErrTokenUsedBeforeIssued = errors.New("token used before issued")
ErrTokenInvalidIssuer    = errors.New("token has invalid issuer")
ErrTokenNotValidYet      = errors.New("token is not valid yet")
ErrTokenInvalidId        = errors.New("token has invalid id")
ErrTokenInvalidClaims    = errors.New("token has invalid claims")

无法辨认的错误默认TokenInvalid

func (*JWT) ParseTokenWithoutClaimsValidation

func (j *JWT) ParseTokenWithoutClaimsValidation(claim jwt.Claims, tokenString string) (jwt.Claims, error)

Jump to

Keyboard shortcuts

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