pub struct CorsConfig {
pub enabled: bool,
pub allowed_origins: Vec<String>,
pub allow_credentials: bool,
pub max_age: u64,
pub permissive_headers: bool,
}Expand description
CORS configuration
Fields§
§enabled: boolEnable CORS middleware
allowed_origins: Vec<String>Allowed origins.
The default is ["*"] because these HTTP resource faces carry authority
explicitly in Bearer/DPoP headers, never in ambient browser credentials.
Operators may still configure an exact origin list; pairing that list
with allow_credentials = true preserves the legacy deployment posture.
allow_credentials: boolAllow ambient browser credentials (cookies or HTTP authentication).
Disabled by default. Bearer and DPoP request headers do not require this flag and remain subject to the normal authentication, tenant, and MAC enforcement path.
max_age: u64Max age for preflight cache (in seconds)
permissive_headers: boolAllow all headers in CORS preflights (Access-Control-Allow-Headers: *).
This deliberately widens the preflight surface and must stay confined to
fully-public, secret-free GET endpoints whose contents carry no
authorization — currently only the DID-document routes (see
CorsConfig::did_document), where W3C DID Core requires the documents to
be fetchable cross-origin with arbitrary request headers. It is left
false for the broad public router (CorsConfig::public) and every other
surface so they keep their explicit header allowlist.
Implementations§
Source§impl CorsConfig
impl CorsConfig
Sourcepub fn public() -> Self
pub fn public() -> Self
CORS config for public endpoints (OAuth metadata, token, registration).
Allows any origin but disables credentials (per CORS spec, wildcard +
credentials is invalid). permissive_headers stays false: this broad
router fronts secret-bearing endpoints (/oauth/token, /oauth/register,
/oauth/par, /oauth/revoke, SCIM discovery, …), so it keeps the explicit
request-header allowlist. The arbitrary-header relaxation needed by public
DID documents is scoped separately via CorsConfig::did_document.
Sourcepub fn did_document() -> Self
pub fn did_document() -> Self
CORS config for the public DID-document routes only.
Per W3C DID Core, a DID document is a public identity anchor that carries
no authorization and must be fetchable cross-origin with arbitrary request
headers (e.g. extension/SDK-injected headers, ngrok-skip-browser-warning
for dev tunnels) without preflight rejection. These are secret-free GET
endpoints, so permissive_headers is enabled here and nowhere else.
Applied as a route-group layer on the DID routes (/.well-known/did.json,
/.well-known/atproto-did, /users/:username/did.json,
/clients/:client_id/did.json) so the relaxation never reaches the broad
public router (closes #472).
Trait Implementations§
Source§impl Clone for CorsConfig
impl Clone for CorsConfig
Source§fn clone(&self) -> CorsConfig
fn clone(&self) -> CorsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CorsConfig
impl Debug for CorsConfig
Source§impl Default for CorsConfig
impl Default for CorsConfig
Source§impl<'de> Deserialize<'de> for CorsConfig
impl<'de> Deserialize<'de> for CorsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CorsConfig
impl RefUnwindSafe for CorsConfig
impl Send for CorsConfig
impl Sync for CorsConfig
impl Unpin for CorsConfig
impl UnsafeUnpin for CorsConfig
impl UnwindSafe for CorsConfig
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request