Documentation
¶
Index ¶
- type CustomClaims
- type Jwts
- func (j *Jwts) CreateToken(claims *CustomClaims) (string, error)
- func (j *Jwts) ParserToken(tokenString string) (*CustomClaims, error)
- func (j *Jwts) SetMethod(method jwt.SigningMethod)
- func (j *Jwts) SetPrivateFileName(privateFileName string)
- func (j *Jwts) SetPublicFileName(publicFileName string)
- func (j *Jwts) SetSecret(secret string)
- func (j *Jwts) SetTime(expiresIn int64)
- func (j *Jwts) 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 Jwts ¶
type Jwts struct { Method jwt.SigningMethod Secret []byte Timestamp time.Time ExpiresIn int64 ExpiresAt time.Time PrivateRSA *rsa.PrivateKey PublicRSA *rsa.PublicKey }
func NewExpiresMethodHS256 ¶
func NewExpiresMethodRS256 ¶
func NewMethodHS256 ¶
func NewMethodRS256 ¶
func (*Jwts) CreateToken ¶
func (j *Jwts) CreateToken(claims *CustomClaims) (string, error)
CreateToken 生成token
func (*Jwts) ParserToken ¶
func (j *Jwts) ParserToken(tokenString string) (*CustomClaims, error)
ParserToken 解密token
func (*Jwts) SetPrivateFileName ¶
SetPrivateFileName 设置公有密钥
func (*Jwts) SetPublicFileName ¶
SetPublicFileName 设置公有密钥
Click to show internal directories.
Click to hide internal directories.