Expand description
CORS policy primitive (Sprint 7 §6.2, ADR-057).
Transport-agnostic CORS rules. Consumers (actix-web, axum) call
CorsPolicy::preflight_headers from their OPTIONS handler and
CorsPolicy::response_headers from the normal-response path; this
crate never mounts routes itself.
§Semantics
- Allowed origins. Either
AllowedOrigins::Wildcard(any origin) orAllowedOrigins::Exact(explicit allowlist). An unlisted origin yieldsNonefrom the preflight path — the caller MUST emit a no-CORS response (typically 403 or the un-augmented 200). - Credentials + wildcard. Per the Fetch spec,
Access-Control- Allow-Origin: *is invalid when credentials are included. When both are configured, the policy degrades to echoing the concrete request origin and emitsVary: Originso caches do not leak. - Exposed headers. Default set targets Solid interop (WAC-Allow,
Link, ETag, Accept-Patch, Accept-Post, Updates-Via). Operators
override via
CorsPolicy::with_expose_headers. - Preflight advertising.
Access-Control-Allow-Headersechoes theAccess-Control-Request-Headersvalue verbatim (after whitespace normalisation), matching JSS behaviour — consumers need not maintain an allowlist of request headers.
Structs§
- Cors
Policy - CORS policy aggregate root. Immutable after construction.
Enums§
- Allowed
Origins - Origin-matching strategy.
Constants§
- DEFAULT_
EXPOSE_ HEADERS - Default headers exposed to the browser — tuned for Solid / LDP interoperability.
- DEFAULT_
MAX_ AGE_ SECS - Default Max-Age for preflight caching.
- ENV_
CORS_ ALLOWED_ ORIGINS - Environment variable: comma-separated list of allowed origins, or
*for wildcard. - ENV_
CORS_ ALLOW_ CREDENTIALS - Environment variable:
true/1to enable credentials. - ENV_
CORS_ MAX_ AGE - Environment variable: preflight max-age in seconds.