Documentation ¶
Overview ¶
Package token provides a web token maker. These tokens are used to authenticate users and store additional payload on user log in, for example, user id..
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidToken is returned when the token is invalid. ErrInvalidToken = errors.New("token is invalid") // ErrExpiredToken is returned when the token is expired. ErrExpiredToken = errors.New("token has expired") )
View Source
var ErrInvalidKeySize = fmt.Errorf("invalid key size: must be at least %d characters", minSecretKeySize)
ErrInvalidKeySize is returned when the secret key is too short.
Functions ¶
This section is empty.
Types ¶
type JWTMaker ¶
type JWTMaker struct {
// contains filtered or unexported fields
}
JWTMaker is a JWT web token maker.
func NewJWTMaker ¶
NewJWTMaker creates a new JWTMaker.
func (JWTMaker) CreateToken ¶
CreateToken creates a new JWT web token for a specific username and duration.
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id"` Email string `json:"email"` IssuedAt time.Time `json:"issued_at"` ExpiredAt time.Time `json:"expired_at"` }
Payload contains the payload data of the token.
func NewPayload ¶
NewPayload creates a new token payload with a specific username and duration.
Click to show internal directories.
Click to hide internal directories.