Documentation ¶
Index ¶
- Constants
- func GenerateAccessToken(refreshID uint64, uid uint, appCode, payload string) (string, error)
- func GenerateLoginToken(claims jwtClaims.LoginRedis) (string, error)
- func GenerateMfaToken(claims jwtClaims.LoginRedis, mfaSecret, appCallback string) (string, error)
- func GenerateRefreshToken(uid uint, loginRecordID uint64, appCode, payload string, valid time.Duration) (string, *jwtClaims.RefreshToken, error)
- func GenerateToken(claims jwtClaims.Claims) (string, error)
- func GenerateU2fToken(uid uint, ip string) (string, *jwtClaims.U2fToken, error)
- func GenerateUserToken(uid uint, loginRecordID uint64, name string, groups []string, ...) (string, error)
- func HeaderToken(c *gin.Context, Type string) (string, error)
- func NewTypedClaims(Type string, valid time.Duration) jwtClaims.TypedClaims
- func NewUserClaims(uid uint, Type string, valid time.Duration) (claims jwtClaims.UserClaims, err error)
- func ParseAccessToken(token string) (*jwtClaims.AccessToken, bool, error)
- func ParseLoginToken(token string) (*jwtClaims.LoginRedis, bool, error)
- func ParseMfaToken(token string) (*jwtClaims.MfaRedis, bool, error)
- func ParseRefreshToken(token string) (*jwtClaims.RefreshToken, bool, error)
- func ParseToken[C jwtClaims.Claims](Type, token string, target C) (claims C, valid bool, err error)
- func ParseTokenAndVerify[C jwtClaims.ClaimsUser](Type, token string, target C) (claims C, valid bool, err error)
- func ParseU2fToken(token, ip string) (bool, error)
- func ParseUserToken(token string) (*jwtClaims.UserToken, bool, error)
- func TokenWithType(Type, token string) string
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 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 GenerateU2fToken ¶
GenerateU2fToken 生成后台 U2F 身份令牌,五分钟有效
func GenerateUserToken ¶
func GenerateUserToken(uid uint, loginRecordID uint64, name string, groups []string, valid time.Duration) (string, error)
GenerateUserToken 生成后台 Token
func NewTypedClaims ¶
func NewTypedClaims(Type string, valid time.Duration) jwtClaims.TypedClaims
func NewUserClaims ¶ added in v1.17.7
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 ¶
ParseMfaToken 不会销毁,允许多次验证尝试
func ParseRefreshToken ¶ added in v1.17.2
func ParseRefreshToken(token string) (*jwtClaims.RefreshToken, bool, error)
func ParseToken ¶
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 TokenWithType ¶ added in v1.17.3
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.