pub struct VerifyIdTokenLayer { /* private fields */ }Expand description
A tower layer that lets a request through only with a valid Google ID token in its
authorization: Bearer header, and puts the token’s claims into the request’s
extensions for the VerifiedIdToken extractor.
Requests it refuses never reach the inner service. They get an empty response:
- 401 with
www-authenticate: Bearerwhen there is no bearer token; - 401 with
www-authenticate: Bearer error="invalid_token"when the token does not verify; - 503 when the signing keys cannot be fetched, or when
authorize_asyncfails; - 403 when the token verifies but
authorizeorauthorize_asyncrefuses it.
Implementations§
Source§impl VerifyIdTokenLayer
impl VerifyIdTokenLayer
Sourcepub fn new(verifier: Arc<IdTokenVerifier>) -> Self
pub fn new(verifier: Arc<IdTokenVerifier>) -> Self
A layer that admits every token verifier accepts.
Admits only the verified tokens for which authorize returns true, such as those
of an allowlist of callers; the others get 403. Replaces any earlier authorize or
authorize_async.
Admits only the verified tokens for which the future returned by check
resolves to Ok(true), for checks that need async calls, such as an allowlist kept
in a database. Ok(false) gets 403. Err gets 503: the error is logged with
warn! and never goes into the response. Replaces any earlier
authorize or authorize_async.
The future is 'static, so it cannot borrow the token: copy what the check needs,
such as the email, before the async move block.
Trait Implementations§
Source§impl Clone for VerifyIdTokenLayer
impl Clone for VerifyIdTokenLayer
Auto Trait Implementations§
impl !RefUnwindSafe for VerifyIdTokenLayer
impl !UnwindSafe for VerifyIdTokenLayer
impl Forget for VerifyIdTokenLayer
impl Freeze for VerifyIdTokenLayer
impl Move for VerifyIdTokenLayer
impl Send for VerifyIdTokenLayer
impl Sync for VerifyIdTokenLayer
impl Unpin for VerifyIdTokenLayer
impl UnsafeUnpin for VerifyIdTokenLayer
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> 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> 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