pub struct InMemoryApiKeyRepository { /* private fields */ }Expand description
In-memory implementation of ApiKeyRepository.
Useful for development, testing, and simple applications.
§Example
ⓘ
use actix_security::http::security::api_key::{ApiKey, InMemoryApiKeyRepository};
let repository = InMemoryApiKeyRepository::new()
.with_key(ApiKey::new("sk_live_abc123")
.name("Production Key")
.roles(vec!["API_USER".into()])
.authorities(vec!["api:read".into()]))
.with_key(ApiKey::new("sk_test_xyz789")
.name("Test Key")
.roles(vec!["API_USER".into(), "API_ADMIN".into()])
.authorities(vec!["api:read".into(), "api:write".into()]));Implementations§
Source§impl InMemoryApiKeyRepository
impl InMemoryApiKeyRepository
Sourcepub fn new() -> InMemoryApiKeyRepository
pub fn new() -> InMemoryApiKeyRepository
Creates an empty repository.
Sourcepub fn with_key(self, key: ApiKey) -> InMemoryApiKeyRepository
pub fn with_key(self, key: ApiKey) -> InMemoryApiKeyRepository
Adds an API key to the repository.
Sourcepub fn remove_key(&self, key: &str) -> Option<ApiKey>
pub fn remove_key(&self, key: &str) -> Option<ApiKey>
Removes an API key from the repository.
Sourcepub fn get_all_keys(&self) -> Vec<ApiKey>
pub fn get_all_keys(&self) -> Vec<ApiKey>
Returns all API keys in the repository.
Trait Implementations§
Source§impl Debug for InMemoryApiKeyRepository
impl Debug for InMemoryApiKeyRepository
Source§impl Default for InMemoryApiKeyRepository
impl Default for InMemoryApiKeyRepository
Source§fn default() -> InMemoryApiKeyRepository
fn default() -> InMemoryApiKeyRepository
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for InMemoryApiKeyRepository
impl RefUnwindSafe for InMemoryApiKeyRepository
impl Send for InMemoryApiKeyRepository
impl Sync for InMemoryApiKeyRepository
impl Unpin for InMemoryApiKeyRepository
impl UnwindSafe for InMemoryApiKeyRepository
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 more