jwtT

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// jwt key
	Jwt         = "jwt"
	JwtMsg      = "jwt-msg"
	JwtAuth     = "jwt-auth"
	JwtUser     = "jwt-user"
	JwtUsername = "jwt-username"
	// jwt 错误信息
	JwtTokenError       = "jwt is error"
	JwtTokenEffective   = "jwt is effective"
	JwtTokenCantBeEmpty = "jwt cannot be empty"
	JwtTokenExpired     = "jwt is expired"
	JwtTokenNotValidYet = "jwt is not valid yet"
)

Variables

View Source
var DefaultJwtConfig = &JwtConfig{
	JwtExpiresTime: 60 * 60 * 24 * 7,
	JwtSigningKey:  "tinytok",
}

Functions

func CreateToken

func CreateToken(claims *UserClaims) (string, error)

func JwtAuthMiddleware added in v0.2.1

func JwtAuthMiddleware() gin.HandlerFunc

func RefreshToken

func RefreshToken(tokenString string) (string, error)

Types

type JwtConfig

type JwtConfig struct {
	JwtExpiresTime int
	JwtSigningKey  string
}

type UserClaims

type UserClaims struct {
	Name   string
	UserID int
	jwt.StandardClaims
}

func ParseToken

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

Jump to

Keyboard shortcuts

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