auth

package
v0.0.0-...-ae0949c Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     error = errors.New("Token is expired")
	TokenNotValidYet error = errors.New("Token not active yet")
	TokenMalformed   error = errors.New("That's not even a token")
	TokenInvalid     error = errors.New("Couldn't handle this token:")
)

一些常量

Functions

func GenerateToken

func GenerateToken(user string, jwtKey, Issuer string) (string, error)

生成令牌

func ParseToken

func ParseToken(token string, jwtKey string) (string, error)

Types

type CustomClaims

type CustomClaims struct {
	jwt.StandardClaims
	User string
}

载荷,可以加一些自己需要的信息

type JWT

type JWT struct {
	SigningKey []byte
}

JWT 签名结构

func NewJWT

func NewJWT(jwtKey string) *JWT

新建一个jwt实例

func (*JWT) CreateToken

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

CreateToken 生成一个token

func (*JWT) ParseToken

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

解析Token

func (*JWT) RefreshToken

func (j *JWT) RefreshToken(tokenString string) (string, error)

更新token

Jump to

Keyboard shortcuts

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