pub struct ApiKeyAuth {
pub key_id: Uuid,
pub user_id: Uuid,
pub key_name: String,
pub scopes: Vec<ApiKeyScope>,
pub owner_is_admin: bool,
}Expand description
An authenticated caller via API key.
Use as an Axum handler parameter to enforce API key authentication.
§Examples
use ironflow_auth::extractor::ApiKeyAuth;
async fn protected(key: ApiKeyAuth) -> String {
format!("Key {} (user {})", key.key_name, key.user_id)
}Fields§
§key_id: UuidThe API key ID.
user_id: UuidThe owner user ID.
key_name: StringThe API key name.
scopes: Vec<ApiKeyScope>Scopes granted to this key.
owner_is_admin: boolWhether the key owner is an admin (checked at request time).
Implementations§
Source§impl ApiKeyAuth
impl ApiKeyAuth
Sourcepub fn has_scope(&self, required: &ApiKeyScope) -> bool
pub fn has_scope(&self, required: &ApiKeyScope) -> bool
Check if the API key has a specific scope.
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
Source§impl<S> FromRequestParts<S> for ApiKeyAuth
impl<S> FromRequestParts<S> 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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.