Skip to main content

Verifier

Struct Verifier 

Source
pub struct Verifier { /* private fields */ }
Expand description

A set of RSA verification keys (indexed by kid) plus the issuer / audience policy applied to every token. Construct once at boot, then share behind an Arc and call verify per request — verification is read-only and allocation-light.

Implementations§

Source§

impl Verifier

Source

pub fn from_jwks_value( jwks: &Value, issuer: &str, audience: &str, ) -> Result<Self, VerifyError>

Build a verifier from an in-memory JWKS document, validating tokens against issuer (iss) and audience (aud).

Only RSA signing keys are loaded; entries with a non-RSA kty are skipped (the auth-service publishes RS256 only). An empty key set is permitted — it yields a verifier that rejects every token with VerifyError::UnknownKid, which lets a service boot before its JWKS source is reachable without panicking.

§Errors

VerifyError::Jwks when the document lacks a keys array, a key is missing kid / n / e, or the modulus/exponent are not valid RSA components.

Source

pub fn key_count(&self) -> usize

Number of RSA verification keys loaded from the JWKS.

Source

pub fn verify(&self, token: &str) -> Result<Claims, VerifyError>

Verify an RS256 bearer token: select the key by the header kid, check the signature, then enforce issuer, audience, and expiry.

§Errors

VerifyError::MissingKid / VerifyError::UnknownKid when no key matches, or VerifyError::Jwt when signature/claim validation fails.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.