pub struct BearerTokenTenantResolver { /* private fields */ }Expand description
Extracts a tenant ID from the Authorization: Bearer <token> header.
By default, uses the raw bearer token as the tenant identifier. An optional
mapping function can transform or validate the token (e.g. decode a JWT
and extract a tenant_id claim).
§Example
use a2a_protocol_server::tenant_resolver::BearerTokenTenantResolver;
// Use the raw token as tenant ID:
let resolver = BearerTokenTenantResolver::new();
// With a custom mapping:
let resolver = BearerTokenTenantResolver::with_mapper(|token| {
// e.g. decode JWT, look up tenant in cache, etc.
Some(format!("tenant-for-{token}"))
});Implementations§
Source§impl BearerTokenTenantResolver
impl BearerTokenTenantResolver
Sourcepub fn new() -> BearerTokenTenantResolver
pub fn new() -> BearerTokenTenantResolver
Creates a resolver that uses the raw bearer token as the tenant ID.
Sourcepub fn with_mapper<F>(mapper: F) -> BearerTokenTenantResolver
pub fn with_mapper<F>(mapper: F) -> BearerTokenTenantResolver
Creates a resolver with a custom mapping function.
The mapper receives the bearer token (without the Bearer prefix) and
returns an optional tenant ID. Return None to indicate that the token
does not map to a valid tenant.
Trait Implementations§
Source§impl Debug for BearerTokenTenantResolver
impl Debug for BearerTokenTenantResolver
Source§impl Default for BearerTokenTenantResolver
impl Default for BearerTokenTenantResolver
Source§fn default() -> BearerTokenTenantResolver
fn default() -> BearerTokenTenantResolver
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BearerTokenTenantResolver
impl !RefUnwindSafe for BearerTokenTenantResolver
impl Send for BearerTokenTenantResolver
impl Sync for BearerTokenTenantResolver
impl Unpin for BearerTokenTenantResolver
impl UnsafeUnpin for BearerTokenTenantResolver
impl !UnwindSafe for BearerTokenTenantResolver
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
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>
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 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>
Wrap the input message
T in a tonic::Request