Cross-Origin Resource Sharing (CORS) support for authorization-server and protected-resource endpoints (RFC 10017 §6.3.3.4).
Browser-based OAuth clients make cross-origin fetch() calls to metadata,
JWKS, token, revocation, introspection, dynamic registration, UserInfo, and
protected-resource endpoints, including OPTIONS preflight requests when
sending Authorization, DPoP, or Content-Type: application/json headers.
Policy resolution order:
- The
:originsoption passed to the plug or helper. :cors_originsonconn.private[:attesto_phoenix_config].- Default
:*(wildcardAccess-Control-Allow-Origin: *, never paired withAccess-Control-Allow-Credentials).
Set cors_origins: false to disable CORS headers and refuse preflights
through the router's normal missing-route handling, or configure an
explicit list of allowed origins (["https://app.example"]) or a 1-arity
predicate callback ((origin -> boolean())). When an allowlist or callback
is used, responses vary by Origin (Vary: origin) and only echo a
matching origin.
Summary
Functions
Applies CORS response headers to conn according to the active policy.
Answers an HTTP OPTIONS CORS preflight request with 204 No Content and
halted connection state. When the effective policy is false, raises
Phoenix.Router.NoRouteError with the connection and router. Outside a
Phoenix router, sends an empty 404 response instead.
Functions
@spec apply_headers(Plug.Conn.t(), keyword()) :: Plug.Conn.t()
Applies CORS response headers to conn according to the active policy.
Existing access-control-allow-origin headers set earlier in the pipeline
are preserved.
@spec preflight(Plug.Conn.t(), keyword()) :: Plug.Conn.t()
Answers an HTTP OPTIONS CORS preflight request with 204 No Content and
halted connection state. When the effective policy is false, raises
Phoenix.Router.NoRouteError with the connection and router. Outside a
Phoenix router, sends an empty 404 response instead.