pub struct SecurityConfig {
pub auth: AuthConfig,
pub rate_limit: RateLimitConfig,
pub api_keys: Vec<String>,
pub capabilities: Option<CapabilitySet>,
pub cors: CorsConfig,
}Expand description
Security configuration for the server.
Fields§
§auth: AuthConfigAuthentication configuration.
rate_limit: RateLimitConfigRate limiting configuration.
api_keys: Vec<String>API keys to pre-register.
capabilities: Option<CapabilitySet>Capabilities granted to the pre-registered keys and to the auto-generated fallback key.
None (the default) means full-control (wildcard) — the backward-
compatible behavior for a bare --api-key / --require-auth (spec §4).
Some(set) issues fine-grained tokens scoped to that set (spec §9).
cors: CorsConfigCORS configuration.
Implementations§
Source§impl SecurityConfig
impl SecurityConfig
Sourcepub fn development() -> Self
pub fn development() -> Self
Create a development configuration (no auth, relaxed limits).
Sourcepub fn with_api_key(self, key: impl Into<String>) -> Self
pub fn with_api_key(self, key: impl Into<String>) -> Self
Add an API key.
Sourcepub fn with_capabilities(self, capabilities: CapabilitySet) -> Self
pub fn with_capabilities(self, capabilities: CapabilitySet) -> Self
Scope the issued tokens to a fine-grained capability set (spec §9).
Applies to the pre-registered keys and to the auto-generated fallback key. Without this, tokens are full-control (legacy-compatible).
Sourcepub fn with_cors_allow_any(self) -> Self
pub fn with_cors_allow_any(self) -> Self
Enable permissive (Any) CORS. Opt-in; only for trusted browser UIs.
Trait Implementations§
Source§impl Clone for SecurityConfig
impl Clone for SecurityConfig
Source§fn clone(&self) -> SecurityConfig
fn clone(&self) -> SecurityConfig
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 SecurityConfig
impl Debug for SecurityConfig
Auto Trait Implementations§
impl Freeze for SecurityConfig
impl RefUnwindSafe for SecurityConfig
impl Send for SecurityConfig
impl Sync for SecurityConfig
impl Unpin for SecurityConfig
impl UnsafeUnpin for SecurityConfig
impl UnwindSafe for SecurityConfig
Blanket Implementations§
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.