pub struct ApiKeyAuth {
pub header: Arc<HeaderName>,
pub allowed_keys: Arc<Vec<String>>,
}
Expand description
API key validation layer.
Fields§
§header: Arc<HeaderName>
The header to find the API key in.
allowed_keys: Arc<Vec<String>>
The list of allowed keys.
Implementations§
Source§impl ApiKeyAuth
impl ApiKeyAuth
Sourcepub fn new(header: HeaderName, allowed_keys: Vec<String>) -> Self
pub fn new(header: HeaderName, allowed_keys: Vec<String>) -> Self
Create new API key auth.
Sourcepub fn get_header<'a, T>(&self, request: &'a Request<T>) -> Option<&'a str>
pub fn get_header<'a, T>(&self, request: &'a Request<T>) -> Option<&'a str>
Try get the API key header from a request.
Sourcepub fn is_allowed_key(&self, key: &str) -> bool
pub fn is_allowed_key(&self, key: &str) -> bool
Check if a given API key is allowed
Trait Implementations§
Source§impl Clone for ApiKeyAuth
impl Clone for ApiKeyAuth
Source§fn clone(&self) -> ApiKeyAuth
fn clone(&self) -> ApiKeyAuth
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ApiKeyAuth
impl Debug for ApiKeyAuth
Auto Trait Implementations§
impl Freeze for ApiKeyAuth
impl RefUnwindSafe for ApiKeyAuth
impl Send for ApiKeyAuth
impl Sync for ApiKeyAuth
impl Unpin for ApiKeyAuth
impl UnwindSafe for ApiKeyAuth
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