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.
View Source
const (
// TokenCookieKey is the key of the cookie stored in the context.
TokenCookieKey = "session_token"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
Provider string `json:"provider"`
Credentials []webauthn.Credential `json:"credentials"`
}
Claims are the fields stored in a JWT.
type Option ¶ added in v1.5.0
type Option func(*Options)
Option is an option for JWT.
func WithCredentials ¶ added in v1.5.0
func WithCredentials(credentials []webauthn.Credential) Option
WithCredentials exports Webauthn credentials in the JWT.
type Options ¶ added in v1.5.0
type Options struct {
// contains filtered or unexported fields
}
Options is the struct storing the options for JWT.
type Secret ¶ added in v1.4.1
type Secret []byte
Secret is a HMAC JWT secret used for signing.
func (Secret) GenerateToken ¶ added in v1.4.1
func (s Secret) GenerateToken( userID string, userName string, provider string, options ...Option, ) (string, error)
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.
func (Secret) Middleware ¶ added in v1.6.0
Middleware is a middleware that inject the JWT in the context for HTTP servers.
Click to show internal directories.
Click to hide internal directories.