Documentation
¶
Overview ¶
Package token 提供JSON Web Token认证能力
Index ¶
- Variables
- type Manager
- type Payload
- func (p *Payload) GetAudience() (jwt.ClaimStrings, error)
- func (p *Payload) GetExpirationTime() (*jwt.NumericDate, error)
- func (p *Payload) GetIssuedAt() (*jwt.NumericDate, error)
- func (p *Payload) GetIssuer() (string, error)
- func (p *Payload) GetNotBefore() (*jwt.NumericDate, error)
- func (p *Payload) GetSubject() (string, error)
- func (p *Payload) Valid() error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidToken = errors.New("invalid token") ErrExpiredToken = errors.New("expired token") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface { Create(userName string, duration time.Duration) (string, error) Verify(token string) (*Payload, error) }
Manager token管理接口
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id,omitempty"` UserName string `json:"user_name,omitempty"` IssuedAt time.Time `json:"issued_at,omitempty"` ExpiredAt time.Time `json:"expired_at,omitempty"` }
Payload token载荷信息
func NewPayload ¶
NewPayload 工厂方法
func (*Payload) GetAudience ¶
func (*Payload) GetExpirationTime ¶
func (*Payload) GetIssuedAt ¶
func (*Payload) GetNotBefore ¶
func (*Payload) GetSubject ¶
Click to show internal directories.
Click to hide internal directories.