pub struct SnapTokenVerifier { /* private fields */ }Expand description
Verifies SNAP tokens against either a statically configured key or keys fetched from a JWKS endpoint.
- Tokens without a
kidJWT header claim are verified using the static key. - Tokens with a
kidare verified using a key resolved from theJwksKeyStore. If no JWKS store is configured, the static key is used as a fallback.
Implementations§
Source§impl SnapTokenVerifier
impl SnapTokenVerifier
Sourcepub fn new(static_key: DecodingKey) -> Self
pub fn new(static_key: DecodingKey) -> Self
Creates a verifier that only uses the statically configured key.
Tokens with a kid header claim also use this key as a fallback when no JWKS
store is configured.
Sourcepub fn with_jwks_store(self, store: Arc<JwksKeyStore>) -> Self
pub fn with_jwks_store(self, store: Arc<JwksKeyStore>) -> Self
Attaches a JWKS store for resolving kid-bearing tokens.
Sourcepub async fn verify(
&self,
token: &str,
) -> Result<AnyClaims, SnapTokenVerifyError>
pub async fn verify( &self, token: &str, ) -> Result<AnyClaims, SnapTokenVerifyError>
Verifies a SNAP token JWT and returns the parsed claims on success.
§Key selection
- If the JWT header has a
kidand a JWKS store is configured, the key is resolved from the JWKS store. - Otherwise (no
kid, orkidpresent but no JWKS store configured), the static key is used.
Trait Implementations§
Source§impl Clone for SnapTokenVerifier
impl Clone for SnapTokenVerifier
Source§fn clone(&self) -> SnapTokenVerifier
fn clone(&self) -> SnapTokenVerifier
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 moreAuto Trait Implementations§
impl Freeze for SnapTokenVerifier
impl !RefUnwindSafe for SnapTokenVerifier
impl Send for SnapTokenVerifier
impl Sync for SnapTokenVerifier
impl Unpin for SnapTokenVerifier
impl UnsafeUnpin for SnapTokenVerifier
impl !UnwindSafe for SnapTokenVerifier
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<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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request