pub struct SnapTokenVerifier { /* private fields */ }Expand description
Verifies SNAP tokens against a statically configured key, keys fetched from a JWKS endpoint, or both.
- Tokens with a
kidJWT header claim are verified using a key resolved from theJwksKeyStore. If no JWKS store is configured, the static key is used as a fallback. - Tokens without a
kidare verified using the static key, and are rejected outright by a verifier that has none.
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 from_jwks_store(store: Arc<JwksKeyStore>) -> Self
pub fn from_jwks_store(store: Arc<JwksKeyStore>) -> Self
Creates a verifier that resolves every key from store, for a deployment whose tokens all
carry the kid of the key that signed them. A token without one is rejected, since there
is no key to fall back to.
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, and the token is rejected when the verifier has none.
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 (const: unstable) · 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 !RefUnwindSafe for SnapTokenVerifier
impl !UnwindSafe for SnapTokenVerifier
impl Freeze for SnapTokenVerifier
impl Send for SnapTokenVerifier
impl Sync for SnapTokenVerifier
impl Unpin for SnapTokenVerifier
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more