pub struct AuthenticatedCaller(pub Option<RequestContext>);Expand description
The authenticated principal of a request, read from the request extensions.
The server’s authentication layer stores the extracted identity as an
Option<RequestContext> extension; middleware written outside this crate
can also store a bare RequestContext. This extractor accepts either and
never rejects: it yields None when no authentication ran, which is how a
handler tells an unauthenticated deployment from an authenticated caller.
§Example
use adk_server::auth_bridge::AuthenticatedCaller;
async fn whoami(AuthenticatedCaller(caller): AuthenticatedCaller) -> String {
caller.map_or_else(|| "anonymous".to_string(), |context| context.user_id)
}
let _app: axum::Router = axum::Router::new().route("/whoami", axum::routing::get(whoami));Tuple Fields§
§0: Option<RequestContext>Implementations§
Trait Implementations§
Source§impl Clone for AuthenticatedCaller
impl Clone for AuthenticatedCaller
Source§impl Debug for AuthenticatedCaller
impl Debug for AuthenticatedCaller
Source§impl Default for AuthenticatedCaller
impl Default for AuthenticatedCaller
Source§impl<S: Send + Sync> FromRequestParts<S> for AuthenticatedCaller
impl<S: Send + Sync> FromRequestParts<S> for AuthenticatedCaller
Auto Trait Implementations§
impl Forget for AuthenticatedCaller
impl Freeze for AuthenticatedCallerwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<(String, String)>: Freeze,
impl Move for AuthenticatedCaller
impl RefUnwindSafe for AuthenticatedCaller
impl Send for AuthenticatedCaller
impl Sync for AuthenticatedCaller
impl Unpin for AuthenticatedCaller
impl UnsafeUnpin for AuthenticatedCallerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
impl UnwindSafe for AuthenticatedCaller
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more