pub struct ConsumerStore {
by_name: HashMap<String, Arc<Consumer>>,
by_credential: HashMap<String, HashMap<String, Arc<Consumer>>>,
}Expand description
Lock-free lookup structure over the declared consumers.
Indexes each auth type’s primary credential value → consumer, so an auth
plugin resolves a presented credential in one hash lookup. The primary
credential field per auth type: key-auth → key, basic-auth →
username, jwt-auth → key (falling back to the consumer name). Auth
plugins that need more than the primary field (e.g. basic-auth’s password
check) read the matched consumer’s credentials.
Fields§
§by_name: HashMap<String, Arc<Consumer>>§by_credential: HashMap<String, HashMap<String, Arc<Consumer>>>auth type → credential value → consumer
Implementations§
Source§impl ConsumerStore
impl ConsumerStore
Sourcepub fn from_config(consumers: &[ConsumerConfig]) -> Result<Self, String>
pub fn from_config(consumers: &[ConsumerConfig]) -> Result<Self, String>
Builds the store, failing fast on duplicate consumer names or on two consumers sharing the same credential value for the same auth type.
Sourcepub fn find_by_credential(
&self,
auth_type: &str,
value: &str,
) -> Option<Arc<Consumer>>
pub fn find_by_credential( &self, auth_type: &str, value: &str, ) -> Option<Arc<Consumer>>
Resolves a presented credential value for an auth type.
Trait Implementations§
Source§impl Default for ConsumerStore
impl Default for ConsumerStore
Source§fn default() -> ConsumerStore
fn default() -> ConsumerStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConsumerStore
impl RefUnwindSafe for ConsumerStore
impl Send for ConsumerStore
impl Sync for ConsumerStore
impl Unpin for ConsumerStore
impl UnsafeUnpin for ConsumerStore
impl UnwindSafe for ConsumerStore
Blanket Implementations§
§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
Mutably borrows from an owned value. Read more
§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>
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