Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TokenExpired error = errors.New("Token is expired") TokenNotValidYet error = errors.New("Token not active yet") TokenMalformed error = errors.New("That's not even a token") TokenInvalid error = errors.New("Couldn't handle this token:") )
一些常量
Functions ¶
func CORSMiddleware ¶
func CORSMiddleware() gin.HandlerFunc
func CheckSecretKey ¶
func JwtAuth ¶
func JwtAuth() gin.HandlerFunc
Types ¶
type CustomClaims ¶
type CustomClaims struct { UId uint `json:"uid"` jwt.StandardClaims }
载荷,可以加一些自己需要的信息
type JWT ¶
type JWT struct {
SigningKey []byte
}
JWT 签名结构
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
CreateToken 生成一个token
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)
解析Tokne
Click to show internal directories.
Click to hide internal directories.