_1_symmetric

package
v0.0.0-...-a7c7adb Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JWTAuth

func JWTAuth(key []byte) gin.HandlerFunc

Types

type JWT

type JWT struct {
	// 在hmac中key 必须是Key must be []byte
	// 在rsa中key 必须是*rsa.PrivateKey 对象
	SigningKey []byte
}

func NewJWT

func NewJWT(secret []byte) *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(user *models.User) (string, error)

CreateToken 创建一个token

func (*JWT) ParseToken

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

ParseToken 解析 token

func (*JWT) RefreshToken

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

RefreshToken 更新token

type JWTConfig

type JWTConfig struct {
	SigningKey string `json:"key"`
}

Jump to

Keyboard shortcuts

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