Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Maker ¶
type Maker interface { // CreateToken creates a new token for a specific username and duration. // Returns token, payload and error CreateToken(username string, role string, duration time.Duration) (string, *Payload, error) // VerifyToken checks if the token is valid or not VerifyToken(token string) (*Payload, error) }
Maker is an interface that creates and verifies tokens
func NewPasetoMaker ¶
type PasetoMaker ¶
type PasetoMaker struct {
// contains filtered or unexported fields
}
func (*PasetoMaker) CreateToken ¶
func (m *PasetoMaker) CreateToken(username string, role string, duration time.Duration) (string, *Payload, error)
CreateToken creates a new paseto token for a specific username and duration
func (*PasetoMaker) VerifyToken ¶
func (m *PasetoMaker) VerifyToken(token string) (*Payload, error)
type Payload ¶
type Payload struct { // ID is the id of the token ID uuid.UUID `json:"id"` // Username is the username of the token user Username string `json:"username"` // Role is the role of the token user Role string `json:"role"` // IssuedAt is the time the token was issued IssuedAt time.Time `json:"issued_at"` // ExpiredAt is the time the token will expire ExpiredAt time.Time `json:"expired_at"` }
Payload is the payload of the token
func NewPayload ¶
NewPayload creates a new payload for the token
Click to show internal directories.
Click to hide internal directories.