pub struct ScopedAuth {
pub token: Option<ApiToken>,
pub is_api_token: bool,
pub user_id: Option<Uuid>,
}Expand description
Marker type for API token authentication with scope checking
Fields§
§token: Option<ApiToken>The API token if present (None for JWT auth)
is_api_token: boolWhether this request uses API token auth
user_id: Option<Uuid>The authenticated user ID
Implementations§
Source§impl ScopedAuth
impl ScopedAuth
Sourcepub fn has_scope(&self, scope: &TokenScope) -> bool
pub fn has_scope(&self, scope: &TokenScope) -> bool
Check if the request has the required scope
For API tokens: checks if the token has the scope For JWT auth: always returns true (implicit all scopes)
Sourcepub fn require_scope(&self, scope: TokenScope) -> Result<(), ApiError>
pub fn require_scope(&self, scope: TokenScope) -> Result<(), ApiError>
Require a specific scope, returning an error if not present
Trait Implementations§
Source§impl Clone for ScopedAuth
impl Clone for ScopedAuth
Source§fn clone(&self) -> ScopedAuth
fn clone(&self) -> ScopedAuth
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ScopedAuth
impl Debug for ScopedAuth
Source§impl<S> FromRequestParts<S> for ScopedAuth
impl<S> FromRequestParts<S> for ScopedAuth
Source§type Rejection = StatusCode
type Rejection = StatusCode
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§async fn from_request_parts(
parts: &mut Parts,
_state: &S,
) -> Result<ScopedAuth, <ScopedAuth as FromRequestParts<S>>::Rejection>
async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<ScopedAuth, <ScopedAuth as FromRequestParts<S>>::Rejection>
Perform the extraction.
Auto Trait Implementations§
impl Freeze for ScopedAuth
impl RefUnwindSafe for ScopedAuth
impl Send for ScopedAuth
impl Sync for ScopedAuth
impl Unpin for ScopedAuth
impl UnsafeUnpin for ScopedAuth
impl UnwindSafe for ScopedAuth
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
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.
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 moreCreates a shared type from an unshared type.