jwt

package
v1.1.26 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const GoldenClaims = "golden_claims"
View Source
const GoldenJwtKey = "golden_jwt"

Variables

View Source
var GoldenKey = "golden_key" + viper.GetString("cookie.suffix")

Functions

func GetGoldenClaims added in v1.1.8

func GetGoldenClaims(ctx *gin.Context) (jwtgo.MapClaims, error)

func RefreshCookie added in v1.1.10

func RefreshCookie(ctx *gin.Context) (tokenStr string, err error)

刷新token

Types

type GoldenJwt added in v1.1.1

type GoldenJwt struct {
	Exp int
	// contains filtered or unexported fields
}

func GetGoldenJwt added in v1.1.10

func GetGoldenJwt(ctx *gin.Context) (gj *GoldenJwt, err error)

func NewGoldenJwt added in v1.1.1

func NewGoldenJwt(exp int, puk, prk string) (gj *GoldenJwt, err error)

func (*GoldenJwt) CreateToken added in v1.1.1

func (gj *GoldenJwt) CreateToken(claims jwtgo.MapClaims) (tokenStr string, err error)

createToken 生成一个RS256验证的Token Token里面包括的值,可以自己根据情况添加,

func (*GoldenJwt) CreateTokenAndSetCookie added in v1.1.1

func (gj *GoldenJwt) CreateTokenAndSetCookie(claims jwtgo.MapClaims, ctx *gin.Context) (tokenStr string, err error)

createToken 生成一个RS256验证的Token Token里面包括的值,可以自己根据情况添加,

func (*GoldenJwt) GetClaimsFromToken added in v1.1.1

func (gj *GoldenJwt) GetClaimsFromToken(tokenStr string) (claims jwtgo.MapClaims, err error)

getSubFromToken 获取Token的主题(也可以更改获取其他值) 参数tokenStr指的是 从客户端传来的待验证Token 验证Token过程中,如果Token生成过程中,指定了iat与exp参数值,将会自动根据时间戳进行时间验证

func (*GoldenJwt) GinJwtMiddleware added in v1.1.1

func (gj *GoldenJwt) GinJwtMiddleware(ctx *gin.Context)

Jump to

Keyboard shortcuts

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