pub struct AuthInterceptor { /* private fields */ }Expand description
A CallInterceptor that injects Authorization headers from a
CredentialsStore.
On each before() call it looks up the credential for the current session
using the configured scheme (default: "bearer"). If found, it adds:
Authorization: Bearer <token>to req.extra_headers. An interceptor made by
api_key writes the header or cookie an agent’s
APIKeySecurityScheme names instead.
Implementations§
Source§impl AuthInterceptor
impl AuthInterceptor
Sourcepub fn new(
store: Arc<dyn CredentialsStore>,
session: SessionId,
) -> AuthInterceptor
pub fn new( store: Arc<dyn CredentialsStore>, session: SessionId, ) -> AuthInterceptor
Creates an AuthInterceptor that injects bearer tokens.
Sourcepub fn with_scheme(
store: Arc<dyn CredentialsStore>,
session: SessionId,
scheme: impl Into<String>,
) -> AuthInterceptor
pub fn with_scheme( store: Arc<dyn CredentialsStore>, session: SessionId, scheme: impl Into<String>, ) -> AuthInterceptor
Creates an AuthInterceptor with a custom auth scheme.
Sourcepub fn api_key(
store: Arc<dyn CredentialsStore>,
session: SessionId,
scheme: impl Into<String>,
api_key: &ApiKeySecurityScheme,
) -> Result<AuthInterceptor, ClientError>
pub fn api_key( store: Arc<dyn CredentialsStore>, session: SessionId, scheme: impl Into<String>, api_key: &ApiKeySecurityScheme, ) -> Result<AuthInterceptor, ClientError>
Creates an AuthInterceptor that sends the credential stored under
scheme where an agent’s APIKeySecurityScheme says (spec §4.5.2):
in the header, the cookie or the query parameter it names.
with_scheme writes Authorization, which an
agent that reads its key from X-API-Key never sees.
A key in the query string travels in the request URL, which the
JSON-RPC and HTTP+JSON transports send and the gRPC and WebSocket
transports refuse (InvalidAuthScheme on the call). It was refused
here until 2026-10-14 (audit register R67). A URL can reach server
and proxy access logs; prefer the header when the agent offers both.
§Errors
ClientError::InvalidAuthScheme for a name that is not an HTTP
token, which no header or cookie can carry; a query parameter is held
to the same rule.
Trait Implementations§
Source§impl CallInterceptor for AuthInterceptor
impl CallInterceptor for AuthInterceptor
Source§fn before<'a>(
&'a self,
req: &'a mut ClientRequest,
) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
fn before<'a>( &'a self, req: &'a mut ClientRequest, ) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
Source§fn after<'a>(
&'a self,
_resp: &'a ClientResponse,
) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
fn after<'a>( &'a self, _resp: &'a ClientResponse, ) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
Source§fn on_error<'a>(
&'a self,
req: &'a ClientRequest,
err: &'a ClientError,
) -> impl Future<Output = ()> + Send + 'a
fn on_error<'a>( &'a self, req: &'a ClientRequest, err: &'a ClientError, ) -> impl Future<Output = ()> + Send + 'a
before hooks saw, in reverse registration order like after. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AuthInterceptor
impl !UnwindSafe for AuthInterceptor
impl Forget for AuthInterceptor
impl Freeze for AuthInterceptor
impl Move for AuthInterceptor
impl Send for AuthInterceptor
impl Sync for AuthInterceptor
impl Unpin for AuthInterceptor
impl UnsafeUnpin for AuthInterceptor
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].