Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrExpiredToken = errors.New("token has expired") ErrInvalidToken = errors.New("token is invalided") )
View Source
var ErrSecretLen = errors.New("密钥长度不合法")
Functions ¶
This section is empty.
Types ¶
type JWTMaker ¶
type JWTMaker struct {
// contains filtered or unexported fields
}
JWTMaker is a JSON Web Token maker
type Maker ¶
type Maker interface { // CreateToken creates a new token for a specific username and duration CreateToken(content []byte, duration time.Duration) (string, *Payload, error) // VerifyToken checks if the token is valid or not VerifyToken(token string) (*Payload, error) }
Maker is an interface for managing tokens
func NewJWTMaker ¶
func NewPasetoMaker ¶
type PasetoMaker ¶
type PasetoMaker struct { Key []byte //symmetric对称 // contains filtered or unexported fields }
func (*PasetoMaker) CreateToken ¶
func (maker *PasetoMaker) CreateToken(content []byte, duration time.Duration) (string, *Payload, error)
CreateToken 构造token
func (*PasetoMaker) VerifyToken ¶
func (maker *PasetoMaker) VerifyToken(token string) (*Payload, error)
VerifyToken checks if the token is valid or not
Click to show internal directories.
Click to hide internal directories.