pub struct Auth<D, U = (), P = Nil> { /* private fields */ }Expand description
A configured auth instance. Cheap to clone (two Arcs).
D is the database adapter, U the app’s user fields, P the plugin list
(plugins![TwoFactor, Organization]).
Implementations§
Source§impl<D, U, P> Auth<D, U, P>
impl<D, U, P> Auth<D, U, P>
pub fn config(&self) -> &CoreConfig
pub fn schema(&self) -> &Schema
pub fn adapter(&self) -> &D
pub fn migrator(&self) -> Migrator<'_, D>
Sourcepub fn plugin<Pl, I>(&self) -> &Pl
pub fn plugin<Pl, I>(&self) -> &Pl
A registered plugin’s config. Doesn’t compile when the plugin isn’t registered.
Sourcepub async fn handle(&self, request: Request<Bytes>) -> Response<Bytes>
pub async fn handle(&self, request: Request<Bytes>) -> Response<Bytes>
Handles a request under base_path. Integrations call this.
The session for these request headers, plus Set-Cookie values the caller should
add to its response (refreshed or cleared cookies).
Sourcepub async fn get_session(
&self,
headers: &HeaderMap,
) -> Result<Option<SessionData<U, P>>, AuthError>
pub async fn get_session( &self, headers: &HeaderMap, ) -> Result<Option<SessionData<U, P>>, AuthError>
The session for these request headers (cookie, or any registered resolver).
Sourcepub async fn get_session_by_token(
&self,
token: &str,
) -> Result<Option<SessionData<U, P>>, AuthError>
pub async fn get_session_by_token( &self, token: &str, ) -> Result<Option<SessionData<U, P>>, AuthError>
The session for a raw token, e.g. from a WebSocket query string.
Trait Implementations§
Source§impl<D, U, P> AuthInstance for Auth<D, U, P>
impl<D, U, P> AuthInstance for Auth<D, U, P>
type Db = D
type UserFields = U
type Plugins = P
fn config(&self) -> &CoreConfig
fn api(&self) -> Api<'_, D>
Source§fn try_plugin<Pl>(&self) -> Option<&Pl>where
Pl: Plugin,
fn try_plugin<Pl>(&self) -> Option<&Pl>where
Pl: Plugin,
A registered plugin’s config, or
None when P isn’t registered. For code generic
over AuthInstance (an axum extractor) that can’t name the HasPlugin index; with a
concrete Auth, a plugin’s extension trait is the compile-checked way.fn handle( &self, request: Request<Bytes>, ) -> impl Future<Output = Response<Bytes>> + Send
Auto Trait Implementations§
impl<D, U = (), P = Nil> !RefUnwindSafe for Auth<D, U, P>
impl<D, U = (), P = Nil> !UnwindSafe for Auth<D, U, P>
impl<D, U, P> Forget for Auth<D, U, P>
impl<D, U, P> Freeze for Auth<D, U, P>
impl<D, U, P> Move for Auth<D, U, P>
impl<D, U, P> Send for Auth<D, U, P>
impl<D, U, P> Sync for Auth<D, U, P>
impl<D, U, P> Unpin for Auth<D, U, P>
impl<D, U, P> UnsafeUnpin for Auth<D, U, P>
Blanket Implementations§
Source§impl<A> AdminExt for Awhere
A: AuthInstance,
impl<A> AdminExt for Awhere
A: AuthInstance,
Source§impl<A> ApiKeysExt for Awhere
A: AuthInstance,
impl<A> ApiKeysExt for Awhere
A: AuthInstance,
Source§impl<A> AuthRouter for Awhere
A: AuthInstance,
impl<A> AuthRouter for Awhere
A: AuthInstance,
Source§fn router<S>(&self) -> Router<S>
fn router<S>(&self) -> Router<S>
Every auth route under
base_path (/api/auth by default), for a router whose
state holds this instance (Self: FromRef<S>). Merge it into your app’s router.Source§fn service(&self) -> AuthService<A>
fn service(&self) -> AuthService<A>
The auth routes as a
tower::Service for any request body, e.g. for
Router::nest_service or plain hyper. Requests must arrive with the full path,
base_path included; under nest_service the original URI is used.Source§fn session_layer(&self) -> SessionLayer<A>
fn session_layer(&self) -> SessionLayer<A>
A layer that resolves the session lazily, at most once per request, and adds the
refreshed or cleared session cookies to the response.
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> 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> 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