Documentation
¶
Index ¶
- type HMACSessionCookieManager
- func (m *HMACSessionCookieManager) Clear(w http.ResponseWriter)
- func (m *HMACSessionCookieManager) Expiry() time.Duration
- func (m *HMACSessionCookieManager) Parse(r *http.Request) (*SessionCookiePayload, bool)
- func (m *HMACSessionCookieManager) Set(w http.ResponseWriter, s SessionCookiePayload) error
- type SessionCookieManager
- type SessionCookiePayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HMACSessionCookieManager ¶
type HMACSessionCookieManager struct {
// Name is the name of the cookie
Name string
// Secret is the secret used to sign the cookie data
Secret []byte
// TTL is the time-to-live of the cookie
TTL time.Duration
// Secure indicates whether the cookie should be secure
Secure bool
// Domain is the domain of the cookie
Domain string
// HttpOnly indicates whether the cookie should be HTTP-only
HttpOnly bool
// CookiePath is the path of the cookie
CookiePath string
// SameSite indicates whether the cookie should be same-site
SameSite http.SameSite
}
HMACSessionCookieManager is a session cookie manager that uses HMAC to sign the cookie data.
func (*HMACSessionCookieManager) Clear ¶
func (m *HMACSessionCookieManager) Clear(w http.ResponseWriter)
Clear clears a session cookie.
func (*HMACSessionCookieManager) Expiry ¶
func (m *HMACSessionCookieManager) Expiry() time.Duration
func (*HMACSessionCookieManager) Parse ¶
func (m *HMACSessionCookieManager) Parse(r *http.Request) (*SessionCookiePayload, bool)
Parse parses a session cookie.
func (*HMACSessionCookieManager) Set ¶
func (m *HMACSessionCookieManager) Set(w http.ResponseWriter, s SessionCookiePayload) error
Set sets a session in a cookie.
type SessionCookieManager ¶
type SessionCookieManager interface {
Set(w http.ResponseWriter, s SessionCookiePayload) error
Clear(w http.ResponseWriter)
Parse(r *http.Request) (*SessionCookiePayload, bool)
Expiry() time.Duration
}
SessionCookieManager is an interface for managing session cookies.
func GetDefaultHMACCookieSessionManager ¶
func GetDefaultHMACCookieSessionManager() SessionCookieManager
GetDefaultHMACCookieSessionManager returns the default HMACSessionCookieManager. You can override the default values by passing in a custom CookieSessionManager.
type SessionCookiePayload ¶
type SessionCookiePayload struct {
// Provider is the name of the OAuth provider e.g. "google"
Provider string `json:"provider"`
// Subject is the user's unique identifier
Subject string `json:"sub"`
// Email is the user's email address
Email string `json:"email"`
// Name is the user's full name
Name string `json:"name"`
// Expiry is the time when the session expires
Expiry time.Time `json:"exp"`
}
SessionCookiePayload is the payload of the session cookie.
Click to show internal directories.
Click to hide internal directories.