Documentation ¶
Index ¶
Constants ¶
View Source
const UserClaimsFlag = "userClaims"
View Source
const UserJwtPayload = "userPayload"
Variables ¶
View Source
var (
ErrJwtNeedToRefresh = errors.New("token需要刷新")
)
View Source
var JwtCfg *config.JwtConfig
Functions ¶
func CreateHs256Jwt ¶
CreateHs256Jwt @Date 2023-01-20 20:35:38 @Param signKey string @Param userId string @Param issuer string @Param expired time.Duration @Return string @Return error @Method @Description: 使用HMCA256对称加密算法创建一个token
Types ¶
type Claims ¶
type Claims struct { UserClaims jwt.RegisteredClaims }
Claims @Date 2023-01-20 20:10:39 @Description: 自定义Token声明
func CreateJwtClaims ¶
func CreateJwtClaims(userClaims UserClaims, issuer string, expired time.Duration) Claims
func ParseHs256Jwt ¶
ParseHs256Jwt @Date 2023-01-20 22:03:46 @Param jwtStr string @Param secret string @Return Claims @Return error @Method @Description: 解析一个HS256签名的JWT
type UserClaims ¶
Click to show internal directories.
Click to hide internal directories.