Documentation ¶
Index ¶
- type CustomClaims
- type GlangJWT
- func (gj *GlangJWT) CreateToken(claims *CustomClaims) (string, error)
- func (gj *GlangJWT) ParserToken(tokenString string) (*CustomClaims, error)
- func (gj *GlangJWT) SetMethod(method jwt.SigningMethod)
- func (gj *GlangJWT) SetPrivateFileName(privateFileName string)
- func (gj *GlangJWT) SetPublicFileName(publicFileName string)
- func (gj *GlangJWT) SetSecret(secret string)
- func (gj *GlangJWT) SetTime(expiresIn int64)
- func (gj *GlangJWT) UpdateToken(tokenString string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomClaims ¶
type CustomClaims struct { Id int64 `json:"id"` Name string `json:"name"` // StandardClaims结构体实现了Claims接口(Valid()函数) jwt.RegisteredClaims }
CustomClaims 定义载荷
func NewCustomClaims ¶
func NewCustomClaims(id int64, name string) *CustomClaims
type GlangJWT ¶
type GlangJWT struct { Timestamp time.Time ExpiresIn int64 ExpiresAt time.Time PrivateRSA *rsa.PrivateKey PublicRSA *rsa.PublicKey // contains filtered or unexported fields }
func NewMethodHS256 ¶
func NewMethodRS256 ¶
func (*GlangJWT) CreateToken ¶
func (gj *GlangJWT) CreateToken(claims *CustomClaims) (string, error)
CreateToken 生成token
func (*GlangJWT) ParserToken ¶
func (gj *GlangJWT) ParserToken(tokenString string) (*CustomClaims, error)
ParserToken 解密token
func (*GlangJWT) SetMethod ¶
func (gj *GlangJWT) SetMethod(method jwt.SigningMethod)
SetMethod 设置加密方法
func (*GlangJWT) SetPrivateFileName ¶
SetPrivateFileName 设置公有密钥
func (*GlangJWT) SetPublicFileName ¶
SetPublicFileName 设置公有密钥
Click to show internal directories.
Click to hide internal directories.