Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //ErrTokenExpired token 已经过期 ErrTokenExpired = errors.New("Token is expired") //ErrTokenNotValidYet token不可用 ErrTokenNotValidYet = errors.New("Token not active yet") //ErrTokenMalformed token不合法 ErrTokenMalformed = errors.New("That's not even a token") //ErrTokenInvalid token 不可用 ErrTokenInvalid = errors.New("Couldn't handle this token") //SignKey 签名key SignKey = "test" )
Functions ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { ID int64 `json:"id"` Name string `json:"name"` Email string `json:"email"` jwt.StandardClaims }
CustomClaims 用户关键信息
type JWT ¶
type JWT struct {
SigningKey []byte
}
JWT jwt对象定义,含有jwt需要的签名KEY
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
CreateToken 创建一个token
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)
ParseToken token逆转,获得用户信息
Click to show internal directories.
Click to hide internal directories.