pub struct ApiKeyStore { /* private fields */ }Expand description
Thread-safe token store, keyed by opaque bearer-token string.
Implementations§
Source§impl ApiKeyStore
impl ApiKeyStore
Sourcepub fn new(config: AuthConfig) -> Self
pub fn new(config: AuthConfig) -> Self
Create a new token store.
Sourcepub fn add_key(&self, key: impl Into<String>)
pub fn add_key(&self, key: impl Into<String>)
Add a legacy full-control API key.
Backward-compatibility path (spec §4): a bare key with no declared
capabilities maps to a full-control token holding the wildcard, so any
existing --api-key / --require-auth consumer is unaffected and can
never trigger a 403.
Sourcepub fn add_token(&self, key: impl Into<String>, record: TokenRecord)
pub fn add_token(&self, key: impl Into<String>, record: TokenRecord)
Register a token string with an explicit capability record.
Sourcepub fn add_key_with_capabilities(
&self,
key: impl Into<String>,
capabilities: CapabilitySet,
label: impl Into<String>,
)
pub fn add_key_with_capabilities( &self, key: impl Into<String>, capabilities: CapabilitySet, label: impl Into<String>, )
Register a token with the given capabilities and label.
Sourcepub fn remove_key(&self, key: &str) -> bool
pub fn remove_key(&self, key: &str) -> bool
Remove a token.
Sourcepub fn capabilities(&self, key: &str) -> Option<CapabilitySet>
pub fn capabilities(&self, key: &str) -> Option<CapabilitySet>
Look up the capabilities a token grants, if it is registered.
This is the store surface the scope-aware middleware consumes
(spec §5 step 2): token → TokenRecord → capability check.
Sourcepub fn identity(&self, key: &str) -> Option<Identity>
pub fn identity(&self, key: &str) -> Option<Identity>
Identify a token for the audit trail, without revealing it.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if authentication is enabled.
Sourcepub fn extract_key(&self, header_value: &str) -> Option<String>
pub fn extract_key(&self, header_value: &str) -> Option<String>
Extract API key from authorization header.
Trait Implementations§
Source§impl Debug for ApiKeyStore
impl Debug for ApiKeyStore
Auto Trait Implementations§
impl !Freeze for ApiKeyStore
impl RefUnwindSafe for ApiKeyStore
impl Send for ApiKeyStore
impl Sync for ApiKeyStore
impl Unpin for ApiKeyStore
impl UnsafeUnpin for ApiKeyStore
impl UnwindSafe for ApiKeyStore
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> 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.