Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrExpiredToken = errors.New("token has expired") ErrInvalidToken = errors.New("token is invalid") )
Functions ¶
This section is empty.
Types ¶
type PasetoMaker ¶
type PasetoMaker struct {
// contains filtered or unexported fields
}
PasetoMaker is PASETO token maker/manager.
func (*PasetoMaker) CreateToken ¶
func (maker *PasetoMaker) CreateToken(duration time.Duration, userID int64) (string, *Payload, error)
CreateToken create a PASETO based token.
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id"` UserID int64 `json:"user_id"` IssuedAt time.Time `json:"issued_at"` ExpiredAt time.Time `json:"expired_at"` }
A Payload contains the payload data of a token.
func NewPayload ¶
NewPayload creates a new payload with the user ID and duration.
type TokenMaker ¶
type TokenMaker interface { // CreateToken creates a new specific token for a user ID and duration CreateToken(duration time.Duration, userID int64) (string, *Payload, error) // contains filtered or unexported methods }
A TokenMaker is an interface for managing tokens.
func NewPasetoMaker ¶
func NewPasetoMaker(symmetricKey string) (TokenMaker, error)
NewPasetoMaker creates a new PasetoMaker instance.
Click to show internal directories.
Click to hide internal directories.