pub struct JwtAuthInterceptor { /* private fields */ }Expand description
A ServerInterceptor that authenticates requests with a signed JWT.
Reads Authorization: Bearer <jwt>, validates it with the configured
JwtValidator, and rejects the request (generically) on any failure.
Implementations§
Source§impl JwtAuthInterceptor
impl JwtAuthInterceptor
Sourcepub const fn new(validator: JwtValidator, jwks: Jwks) -> JwtAuthInterceptor
pub const fn new(validator: JwtValidator, jwks: Jwks) -> JwtAuthInterceptor
Creates an interceptor with a fixed key set.
Use an empty Jwks when validating HS256-only (the secret lives on
the validator).
Sourcepub fn from_jwks_url(
validator: JwtValidator,
jwks_url: impl Into<String>,
) -> JwtAuthInterceptor
pub fn from_jwks_url( validator: JwtValidator, jwks_url: impl Into<String>, ) -> JwtAuthInterceptor
Creates an interceptor that fetches keys from a JWKS URL, caching them
for ttl (default 1 hour) and refetching once on a key-id miss (key
rotation).
The keys are not fetched here — the first request triggers the fetch.
Sourcepub fn from_jwks_url_with_tls_config(
validator: JwtValidator,
jwks_url: impl Into<String>,
tls_config: ClientConfig,
) -> JwtAuthInterceptor
pub fn from_jwks_url_with_tls_config( validator: JwtValidator, jwks_url: impl Into<String>, tls_config: ClientConfig, ) -> JwtAuthInterceptor
Like from_jwks_url, but with a caller-supplied
rustls ClientConfig for the JWKS fetch —
for identity providers behind a private CA, where the default
webpki-roots trust store cannot verify the JWKS endpoint.
Sourcepub async fn from_oidc_issuer(
issuer: &str,
validator: JwtValidator,
) -> Result<JwtAuthInterceptor, A2aError>
pub async fn from_oidc_issuer( issuer: &str, validator: JwtValidator, ) -> Result<JwtAuthInterceptor, A2aError>
Sourcepub fn with_jwks_ttl(self, ttl: Duration) -> JwtAuthInterceptor
pub fn with_jwks_ttl(self, ttl: Duration) -> JwtAuthInterceptor
Sets the remote-JWKS cache TTL. No-op for a static key set.
Trait Implementations§
Source§impl Debug for JwtAuthInterceptor
impl Debug for JwtAuthInterceptor
Source§impl ServerInterceptor for JwtAuthInterceptor
impl ServerInterceptor for JwtAuthInterceptor
Source§fn before<'a>(
&'a self,
ctx: &'a CallContext,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn before<'a>( &'a self, ctx: &'a CallContext, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Auto Trait Implementations§
impl !RefUnwindSafe for JwtAuthInterceptor
impl !UnwindSafe for JwtAuthInterceptor
impl Freeze for JwtAuthInterceptor
impl Send for JwtAuthInterceptor
impl Sync for JwtAuthInterceptor
impl Unpin for JwtAuthInterceptor
impl UnsafeUnpin for JwtAuthInterceptor
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
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> ⓘ
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>
T in a tonic::Request