Documentation ¶
Overview ¶
Package jwt defines all the methods for JWT manipulation.
Index ¶
Constants ¶
View Source
const ExpiresDuration = 24 * time.Hour
ExpiresDuration is the duration when a user session expires.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct { jwt.RegisteredClaims UserID string `json:"user_id"` UserName string `json:"user_name"` Nonce string `json:"nonce"` }
Claims are the fields stored in a JWT.
type Service ¶ added in v0.2.0
type Service struct { Secret []byte Nonces nonce.Repository }
Service handles common JWT manipulation.
func (*Service) GenerateToken ¶ added in v0.2.0
func (s *Service) GenerateToken( ctx context.Context, userID string, userName string, long bool, ) (claims *Claims, signed string)
GenerateToken creates a JWT session token which stores the user identity.
The returned token is signed with the JWT secret, meaning it cannot be falsified.
Click to show internal directories.
Click to hide internal directories.