auth

package
v1.4.1-0...-415649e Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const TokenExpireDuration = time.Hour * 24 * 30

定义过期时间

Variables

View Source
var MySecret = []byte("这是一段用于生成token的密钥")

定义secret

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func GenerateToken

func GenerateToken(userID uint) (string, error)

生成JWT

func HashPassword

func HashPassword(password string) (string, error)

Types

type MyClaims

type MyClaims struct {
	UserID uint `json:"user_id"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(tokenString string) (*MyClaims, error)

解析JWT

Jump to

Keyboard shortcuts

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