pub struct IdTokenVerifier { /* private fields */ }Expand description
Verifies Google-signed ID tokens for one audience: the RS256 signature against
Google’s signing keys, iss, aud, and exp, nbf and iat with 30 seconds of
leeway.
Keys are fetched on first use and cached for the max-age of their response. A
token signed with a key that is not cached causes a refetch, at most once every 30
seconds. When a fetch fails, cached keys stay in use until their max-age passes.
Share one verifier, behind an Arc, across requests.
Implementations§
Source§impl IdTokenVerifier
impl IdTokenVerifier
Sourcepub fn new(audience: IdTokenAudience) -> Result<Self>
pub fn new(audience: IdTokenAudience) -> Result<Self>
A verifier that fetches Google’s signing keys from https://www.googleapis.com/oauth2/v3/certs. Fails only when the HTTP client cannot be built.
Sourcepub fn with_keys_source(
audience: IdTokenAudience,
keys_source: impl IdTokenKeysSource + 'static,
) -> Self
pub fn with_keys_source( audience: IdTokenAudience, keys_source: impl IdTokenKeysSource + 'static, ) -> Self
A verifier that gets its signing keys from keys_source, such as a fixed local
key in tests. The other checks are the same as new’s.
Sourcepub async fn verify(
&self,
token: &str,
) -> Result<VerifiedIdToken, IdTokenVerifyError>
pub async fn verify( &self, token: &str, ) -> Result<VerifiedIdToken, IdTokenVerifyError>
Verifies token, the bearer token of an authorization header, and returns its
claims.
Auto Trait Implementations§
impl !Freeze for IdTokenVerifier
impl !RefUnwindSafe for IdTokenVerifier
impl !UnwindSafe for IdTokenVerifier
impl Send for IdTokenVerifier
impl Sync for IdTokenVerifier
impl Unpin for IdTokenVerifier
impl UnsafeUnpin for IdTokenVerifier
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request