jwt

package
v1.17.29 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	User    = "User"
	Login   = "Login"
	Mfa     = "Mfa"
	U2F     = "U2F"
	Refresh = "Refresh"
	Access  = "Access"
)

Variables

This section is empty.

Functions

func GenerateAccessToken added in v1.17.2

func GenerateAccessToken(refreshID uint64, uid uint, appCode, payload string) (string, error)

func GenerateLoginToken

func GenerateLoginToken(claims jwtClaims.LoginRedis) (string, error)

GenerateLoginToken 生成有效期 5 分钟的登录校验 Token

func GenerateMfaToken

func GenerateMfaToken(claims jwtClaims.LoginRedis, mfaSecret, appCallback string) (string, error)

GenerateMfaToken 生成绑定 TOTP MFA 中间身份令牌,五分钟有效

func GenerateRefreshToken added in v1.17.2

func GenerateRefreshToken(uid uint, appCode, payload string, valid time.Duration) (string, *jwtClaims.RefreshToken, error)

func GenerateToken

func GenerateToken(claims jwtClaims.Claims) (string, error)

func GenerateU2fToken

func GenerateU2fToken(uid uint, ip string) (string, *jwtClaims.U2fToken, error)

GenerateU2fToken 生成后台 U2F 身份令牌,五分钟有效

func GenerateUserToken

func GenerateUserToken(uid uint, name string, groups []string, valid time.Duration) (string, error)

GenerateUserToken 生成后台 Token

func HeaderToken added in v1.17.3

func HeaderToken(c *gin.Context, Type string) (string, error)

func NewTypedClaims

func NewTypedClaims(Type string, valid time.Duration) jwtClaims.TypedClaims

func NewUserClaims added in v1.17.7

func NewUserClaims(uid uint, Type string, valid time.Duration) (claims jwtClaims.UserClaims, err error)

func ParseAccessToken added in v1.17.2

func ParseAccessToken(token string) (*jwtClaims.AccessToken, bool, error)

func ParseLoginToken

func ParseLoginToken(token string) (*jwtClaims.LoginRedis, bool, error)

ParseLoginToken 解析后自动销毁

func ParseMfaToken

func ParseMfaToken(token string) (*jwtClaims.MfaRedis, bool, error)

ParseMfaToken 不会销毁,允许多次验证尝试

func ParseRefreshToken added in v1.17.2

func ParseRefreshToken(token string) (*jwtClaims.RefreshToken, bool, error)

func ParseToken

func ParseToken[C jwtClaims.Claims](Type, token string, target C) (claims C, valid bool, err error)

func ParseTokenAndVerify added in v1.17.7

func ParseTokenAndVerify[C jwtClaims.ClaimsUser](Type, token string, target C) (claims C, valid bool, err error)

func ParseU2fToken

func ParseU2fToken(token, ip string) (bool, error)

func ParseUserToken

func ParseUserToken(token string) (*jwtClaims.UserToken, bool, error)

func TokenWithType added in v1.17.3

func TokenWithType(Type, token string) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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