Documentation
¶
Overview ¶
Package introspect checks bearer tokens for revocation by asking their issuer for a live verdict.
Index ¶
- type ProviderConfig
- type TokenIntrospect
- func (ti *TokenIntrospect) Authenticate(_ http.ResponseWriter, r *http.Request) (caddyauth.User, bool, error)
- func (TokenIntrospect) CaddyModule() caddy.ModuleInfo
- func (ti *TokenIntrospect) Provision(ctx caddy.Context) error
- func (ti *TokenIntrospect) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (ti *TokenIntrospect) Validate() error
- type TokenSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProviderConfig ¶
type ProviderConfig struct {
// Type is "cognito" or "oidc".
Type string `json:"type"`
// UserPoolID is the Cognito user pool, e.g. "eu-west-1_AbCdEf123".
// The region, issuer and endpoints are derived from it (cognito).
UserPoolID string `json:"user_pool_id,omitempty"`
// Region overrides the region derived from the pool ID (cognito).
Region string `json:"region,omitempty"`
// Domain overrides the discovered user pool domain used for the
// userInfo probe of hosted UI tokens (cognito).
Domain string `json:"domain,omitempty"`
// Endpoint overrides the cognito-idp base URL, for FIPS or
// PrivateLink deployments (cognito).
Endpoint string `json:"endpoint,omitempty"`
// Issuer enables endpoint discovery and routes tokens whose iss
// claim matches it to this provider (oidc).
Issuer string `json:"issuer,omitempty"`
// ClientID authenticates us to the introspection endpoint (oidc).
ClientID string `json:"client_id,omitempty"`
// ClientSecret authenticates us to the introspection endpoint (oidc).
ClientSecret string `json:"client_secret,omitempty"`
// Method is "introspection" (default) or "userinfo", for servers
// without an introspection endpoint (oidc).
Method string `json:"method,omitempty"`
// IntrospectionEndpoint sets or overrides the discovered endpoint (oidc).
IntrospectionEndpoint string `json:"introspection_endpoint,omitempty"`
// UserinfoEndpoint sets or overrides the discovered endpoint (oidc).
UserinfoEndpoint string `json:"userinfo_endpoint,omitempty"`
}
ProviderConfig configures a single provider; Type selects the implementation.
type TokenIntrospect ¶
type TokenIntrospect struct {
// Sources to extract tokens from, in priority order. At least one is
// required.
Sources []TokenSource `json:"sources,omitempty"`
// CacheTTL bounds how long a verdict (active or not) is reused before
// the issuer is probed again. nil means the 60s default; 0 disables
// caching so every request probes the issuer.
CacheTTL *caddy.Duration `json:"cache_ttl,omitempty"`
// CacheMaxEntries bounds the verdict cache size. Defaults to 10000.
CacheMaxEntries int `json:"cache_max_entries,omitempty"`
// FailOpen allows requests through when no definitive verdict could be
// obtained (issuer unreachable, timeouts, 5xx). Definitive rejections
// are unaffected. Defaults to false: no verdict, no entry.
FailOpen bool `json:"fail_open,omitempty"`
// Timeout for each probe request. Defaults to 5s.
Timeout caddy.Duration `json:"timeout,omitempty"`
// UserClaims lists probe-response fields tried in order for the user
// identity ({http.auth.user.id}). Defaults to [sub, username]. The
// single special value "passthrough" echoes the identity set by an
// earlier authentication handler (e.g. caddy-jwt) instead.
UserClaims []string `json:"user_claims,omitempty"`
// MetaClaims maps probe-response fields to {http.auth.user.*}
// placeholder names. Nested fields use dotted paths.
MetaClaims map[string]string `json:"meta_claims,omitempty"`
// Providers configured to give verdicts. Tokens are routed by their iss
// claim; tokens without one (opaque) try providers in this order.
Providers []ProviderConfig `json:"providers,omitempty"`
// contains filtered or unexported fields
}
TokenIntrospect is an HTTP authentication provider that checks bearer tokens for revocation by probing their issuer.
func (*TokenIntrospect) Authenticate ¶
func (ti *TokenIntrospect) Authenticate(_ http.ResponseWriter, r *http.Request) (caddyauth.User, bool, error)
Authenticate implements caddyauth.Authenticator. Candidates are tried in source priority order, so a stale cookie cannot block a fresh header token. The 401 belongs to the wrapping authentication handler; the response writer is never touched here.
func (TokenIntrospect) CaddyModule ¶
func (TokenIntrospect) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*TokenIntrospect) Provision ¶
func (ti *TokenIntrospect) Provision(ctx caddy.Context) error
Provision implements caddy.Provisioner.
func (*TokenIntrospect) UnmarshalCaddyfile ¶
func (ti *TokenIntrospect) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:
token_introspect {
from_var <name...>
from_header <name...>
from_query <name...>
from_cookies <name...>
cache_ttl <duration> # 0 disables caching
cache_max_entries <int>
fail_open [true|false]
timeout <duration>
user_claims <claim...> | passthrough
meta_claims "<claim> -> <placeholder>"...
provider cognito {
user_pool_id <id>
region <region>
domain <url>
endpoint <url>
}
provider oidc {
issuer <url>
client_id <id>
client_secret <secret>
method introspection|userinfo
introspection_endpoint <url>
userinfo_endpoint <url>
}
}
Source directives may repeat and take several names; the order in which they appear is the extraction priority. Provider order is the fallback chain for opaque tokens.
func (*TokenIntrospect) Validate ¶
func (ti *TokenIntrospect) Validate() error
Validate implements caddy.Validator.
type TokenSource ¶
type TokenSource struct {
// From is one of "var", "header", "query" or "cookie".
From string `json:"from"`
// Name is the variable, header, query parameter or cookie to read.
Name string `json:"name"`
}
TokenSource is one place to look for a token; configured order is the extraction priority.