Documentation
¶
Index ¶
- Constants
- Variables
- func IsHTMXRequest(c *gin.Context) bool
- func Redirect(c *gin.Context, code int, location string)
- type LoginURL
- type OpenIDConfiguration
- type Option
- type Quarterdeck
- func (s *Quarterdeck) Config(ctx context.Context) (out *OpenIDConfiguration, err error)
- func (s *Quarterdeck) Do(req *http.Request, data interface{}) (rep *http.Response, err error)
- func (s *Quarterdeck) Expires(url string) (expires time.Time, ok bool)
- func (s *Quarterdeck) GetKey(token *jwt.Token) (key interface{}, err error)
- func (s *Quarterdeck) JWKS(ctx context.Context) (out *jose.JSONWebKeySet, err error)
- func (s *Quarterdeck) NewRequest(ctx context.Context, url string) (req *http.Request, err error)
- func (s *Quarterdeck) NotAuthorized(c *gin.Context) error
- func (s *Quarterdeck) Run()
- func (s *Quarterdeck) Sync() (err error)
- func (s *Quarterdeck) Verify(accessToken string) (claims *auth.Claims, err error)
Constants ¶
const ( HXRequest = "HX-Request" HXRedirect = "HX-Redirect" )
HTMX Request Headers
const ( // Default timeout for synchronization requests to Quarterdeck. SyncTimeout = 20 * time.Second // Default interval for synchronization of JWKS and OpenID configuration if not // specified by the Expires header. SyncInterval = 1 * time.Hour )
Variables ¶
var (
ErrNoLoginURL = errors.New("no login URL specified or authentication endpoint set in OIDC discovery data")
)
Functions ¶
func IsHTMXRequest ¶ added in v1.2.1
Returns true if the request contains the HXRequest header.
Types ¶
type LoginURL ¶ added in v1.2.1
LoginURL provides a thread-safe way to manage the login URL for Quarterdeck and tracks if the URL is set by the user (immutable) or if it is set by the OpenID configuration, which means it can be updated during synchronization.
type OpenIDConfiguration ¶
type OpenIDConfiguration struct { Issuer string `json:"issuer"` AuthorizationEP string `json:"authorization_endpoint"` TokenEP string `json:"token_endpoint"` DeviceAuthorizationEP string `json:"device_authorization_endpoint"` UserInfoEP string `json:"userinfo_endpoint"` MFAChallengeEP string `json:"mfa_challenge_endpoint"` JWKSURI string `json:"jwks_uri"` RegistrationEP string `json:"registration_endpoint"` RevocationEP string `json:"revocation_endpoint"` ScopesSupported []string `json:"scopes_supported"` ResponseTypesSupported []string `json:"response_types_supported"` CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported"` ResponseModesSupported []string `json:"response_modes_supported"` SubjectTypesSupported []string `json:"subject_types_supported"` IDTokenSigningAlgValues []string `json:"id_token_signing_alg_values_supported"` TokenEndpointAuthMethods []string `json:"token_endpoint_auth_methods_supported"` ClaimsSupported []string `json:"claims_supported"` RequestURIParameterSupported bool `json:"request_uri_parameter_supported"` }
type Option ¶
type Option func(*Quarterdeck) error
func WithClient ¶
func WithIssuer ¶
func WithLoginURL ¶ added in v1.2.1
func WithSigningMethods ¶
type Quarterdeck ¶
Quarterdeck implements the Authenticator and Reauthenticator interface for the Authenticate middleware. It uses the JWKS endpoint exposed by Quarterdeck to verify access tokens and extract claims and the Quarterdeck API to reauthenticate valid refresh tokens.
func (*Quarterdeck) Config ¶
func (s *Quarterdeck) Config(ctx context.Context) (out *OpenIDConfiguration, err error)
Returns the OpenID configuration by performing a GET request to Quarterdeck.
func (*Quarterdeck) Expires ¶
func (s *Quarterdeck) Expires(url string) (expires time.Time, ok bool)
func (*Quarterdeck) GetKey ¶
func (s *Quarterdeck) GetKey(token *jwt.Token) (key interface{}, err error)
func (*Quarterdeck) JWKS ¶
func (s *Quarterdeck) JWKS(ctx context.Context) (out *jose.JSONWebKeySet, err error)
Returns the JWKS (JSON Web Key Set) by performing a GET request to Quarterdeck.
func (*Quarterdeck) NewRequest ¶
func (*Quarterdeck) NotAuthorized ¶ added in v1.2.1
func (s *Quarterdeck) NotAuthorized(c *gin.Context) error
Implements the Unauthenticator interface to redirect to the login URL when authentication fails.
func (*Quarterdeck) Run ¶
func (s *Quarterdeck) Run()
func (*Quarterdeck) Sync ¶
func (s *Quarterdeck) Sync() (err error)
Synchronizes the JWKS and OpenID configuration from Quarterdeck, respecting the cache-control headers and ETag for caching purposes.