pub enum AuthToken {
Legacy(ApiToken),
ApiKey(String),
AccessToken(AccessTokenClaims),
}Expand description
Unified authentication token that handles both legacy and new token types
Variants§
Legacy(ApiToken)
Legacy API token format: “id|token”
ApiKey(String)
Long-lived API key: “ak_xxxxx.yyyyy”
AccessToken(AccessTokenClaims)
Short-lived Paseto access token: “v4.local.xxxxx”
Implementations§
Source§impl AuthToken
impl AuthToken
Sourcepub fn parse(token_str: &str) -> Result<Self, AuthTokenError>
pub fn parse(token_str: &str) -> Result<Self, AuthTokenError>
Parse a token string into the appropriate AuthToken type
Sourcepub fn service_id(&self) -> Option<ServiceId>
pub fn service_id(&self) -> Option<ServiceId>
Get the service ID if available (only for validated tokens)
Sourcepub fn additional_headers(&self) -> BTreeMap<String, String>
pub fn additional_headers(&self) -> BTreeMap<String, String>
Get additional headers if available (only for access tokens)
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if token is expired (only applicable to access tokens)
Trait Implementations§
Source§impl<S> FromRequestParts<S> for AuthToken
impl<S> FromRequestParts<S> for AuthToken
Auto Trait Implementations§
impl Freeze for AuthToken
impl RefUnwindSafe for AuthToken
impl Send for AuthToken
impl Sync for AuthToken
impl Unpin for AuthToken
impl UnwindSafe for AuthToken
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.