Documentation
¶
Overview ¶
Package easyjwt is used to generate jwt token and parse jwt token, use HS256 to sign the payload, support custom secret and expiration time.
Index ¶
- Variables
- func GenerateCustomToken(payload map[string]interface{}, secret string, expire time.Duration) (string, error)
- func GenerateToken(payload map[string]interface{}) (string, error)
- func ParseCustomToken(tokenStr, secret string) (interface{}, error)
- func ParseToken(tokenStr string) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrPayloadEmpty means the payload passed in is empty. ErrPayloadEmpty = fmt.Errorf("Payload is empty") // ErrExpiredToken means the token has expired. ErrExpiredToken = fmt.Errorf("Token was expired") // ErrSignatureInvalid means that the signature of the token is invalid. ErrSignatureInvalid = fmt.Errorf("Signature validation failed") // ErrUnknown means unknown error type. ErrUnknown = fmt.Errorf("Unknown error") )
Functions ¶
func GenerateCustomToken ¶
func GenerateCustomToken(payload map[string]interface{}, secret string, expire time.Duration) (string, error)
GenerateCustomToken generates jwt token according to data, custom secret and expire time.
func GenerateToken ¶
GenerateToken generates jwt token with data.
func ParseCustomToken ¶
ParseCustomToken parses jwt token with custom secret and return data.
func ParseToken ¶
ParseToken parses jwt token and return data.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.