Documentation
¶
Overview ¶
Package router builds the http.Handler that fronts the mock service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ServiceFragment []byte
ServiceFragment is the per-package OpenAPI 3.1 partial doc describing the service-plumbing endpoints mounted directly on the root router (`/healthz`, `/.well-known/jwks.json`, `/openapi.json`, `/openapi.yaml`). The genopenapi bundler reads it from here.
Functions ¶
func MountOpenAPI ¶
MountOpenAPI registers `GET /openapi.json`, `GET /openapi.yaml`, and the `/docs` API reference page (with its static assets) on r. All endpoints are unauthenticated.
Types ¶
type Deps ¶
type Deps struct {
Log zerolog.Logger
Store *matches.Store
Claims *claims.Store
ClaimMappings *claims.MappingStore
// Sessions remembers each user's profile for /userinfo and each refresh
// token's grant for refresh_token requests. Nil is
// defaulted to a fresh store; /admin0/reset clears it.
Sessions *session.Store
// AuthorizeErrors holds the /authorize failure rules. Nil is defaulted
// to an empty store; /admin0/reset clears it.
AuthorizeErrors *authorizeerr.Store
Permissions *permissions.Store
PKCE *pkce.Store
MFA *mfa.Store
Keys *jwks.KeySet
Spec *spec.Spec
Validator *spec.Validator
Issuer string
DefaultAudience string
SpecValidationStrict bool
// MaxRequestBodyBytes caps every incoming request body. Zero or negative
// disables the cap.
MaxRequestBodyBytes int64
// LogoutAllowedURLs is the allow-list of absolute URLs that /v2/logout
// (returnTo) and /oidc/logout (post_logout_redirect_uri) will redirect to.
// Relative URLs are always allowed.
LogoutAllowedURLs []string
// AuthorizeAllowedRedirectURIs is the allow-list of absolute
// redirect_uri values that /authorize will 302 to. Same threat model
// as LogoutAllowedURLs but on the higher-value endpoint (it carries
// `code` / `access_token` in the URL). Empty = no enforcement.
AuthorizeAllowedRedirectURIs []string
// CORSAllowedOrigins is the allow-list of browser origins that get CORS
// headers. Empty (or a "*" entry) allows any origin; see
// middleware.CORS for the entry syntax. An invalid entry makes New fail.
CORSAllowedOrigins []string
// BearerRequireAudience, when non-empty, makes the Mgmt-API bearer
// middleware reject tokens whose `aud` claim doesn't contain this
// value. Opt-in to preserve the documented test-friendly default.
BearerRequireAudience string
// Debug enables the request/response dump middleware. Off by default;
// when on, every request and response gets a full method/path/query/
// headers/body log line at INFO level. Authorization + Cookie headers
// are redacted, bodies truncated at 8 KiB.
Debug bool
// Clock is the controllable time source mounted at /admin0/clock and
// surfaced via the SDK's Client.Clock. May be nil in tests that don't
// exercise the admin surface, in which case /admin0/clock handlers
// will panic if hit.
Clock *clock.Controlled
// EventsReplayBuffer is the cap of the SSE replay ring buffer for
// GET /events. 100 in production via EVENTS_REPLAY_BUFFER; <= 0
// disables replay (the endpoint still works; resume params become
// no-ops). Zero value is the test-friendly default.
EventsReplayBuffer int
// EventsReconnectHint is the SSE `retry:` reconnect-delay hint sent on
// connect (EVENTS_RECONNECT_HINT in production); <= 0 omits it. Zero
// value omits the hint, which is fine for tests.
EventsReconnectHint time.Duration
// Journal records /api/v2 calls for GET /admin0/journal. Nil is
// defaulted to a disabled journal (size 0).
Journal *journal.Journal
}
Deps is the parameter object for New.
Click to show internal directories.
Click to hide internal directories.