utils

package
v0.0.0-...-f1241d1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MulanPSL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const BufferTime = "7d"
View Source
const ExpiresTime = "7d"

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:")
)
View Source
var GVA_Concurrency_Control = &singleflight.Group{}

Functions

func ParseDuration

func ParseDuration(d string) (time.Duration, error)

Types

type BaseClaims

type BaseClaims struct {
	UUID        uuid.UUID
	ID          uint
	Username    string
	NickName    string
	AuthorityId uint
}

type CustomClaims

type CustomClaims struct {
	BaseClaims
	BufferTime int64
	jwt.RegisteredClaims
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT(SigningKey string) *JWT

func (*JWT) CreateClaims

func (j *JWT) CreateClaims(baseClaims BaseClaims) CustomClaims

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims CustomClaims) (string, error)

创建一个token

func (*JWT) CreateTokenByOldToken

func (j *JWT) CreateTokenByOldToken(oldToken string, claims CustomClaims) (string, error)

CreateTokenByOldToken 旧token 换新token 使用归并回源避免并发问题

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)

解析 token

Jump to

Keyboard shortcuts

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