pub struct AuthConfig {
pub api_keys: HashSet<String>,
pub header_name: String,
pub prefix: String,
pub public_paths: HashSet<String>,
}Expand description
Configuration for API key authentication.
Fields§
§api_keys: HashSet<String>Set of valid API keys.
header_name: StringHeader name for API key (default: “Authorization”).
prefix: StringPrefix expected before the key (default: “Bearer “).
public_paths: HashSet<String>Paths that don’t require authentication.
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn with_keys(keys: impl IntoIterator<Item = String>) -> Self
pub fn with_keys(keys: impl IntoIterator<Item = String>) -> Self
Create a new auth config with the given API keys.
Sourcepub fn add_public_path(self, path: impl Into<String>) -> Self
pub fn add_public_path(self, path: impl Into<String>) -> Self
Add a public path that doesn’t require authentication.
Sourcepub fn requires_auth(&self, path: &str) -> bool
pub fn requires_auth(&self, path: &str) -> bool
Check if authentication is required for a path.
Sourcepub fn validate_key(&self, key: &str) -> bool
pub fn validate_key(&self, key: &str) -> bool
Validate an API key.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if authentication is enabled (has any API keys configured).
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AuthConfig
impl Debug for AuthConfig
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnwindSafe for AuthConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)