pub struct Adapter { /* private fields */ }Expand description
Serves the Seamless Auth routes and guards the application’s own.
Cheap to clone: clones share the manifest, key set and refresh state.
Implementations§
Source§impl Adapter
impl Adapter
Source§impl Adapter
impl Adapter
Sourcepub fn console_router<S>(&self) -> Router<S>
pub fn console_router<S>(&self) -> Router<S>
Reverse-proxies the Seamless admin dashboard from the auth API, so it loads
from the same origin as the cookie-based auth routes. It serves /console,
the path the dashboard is built against, so merge it rather than nest it:
Router::new().merge(auth.console_router()). (A router nested at
/console never sees /console/, where the browser lands.)
Nothing from the incoming request is forwarded but the method and the path: the console is public static hosting, and the browser’s session cookies have no business at the upstream.
Source§impl Adapter
impl Adapter
Sourcepub async fn authenticate(
&self,
headers: &HeaderMap,
) -> Result<User, Unauthenticated>
pub async fn authenticate( &self, headers: &HeaderMap, ) -> Result<User, Unauthenticated>
Verifies a request’s session: the adapter’s access cookie, or an auth API
access token in Authorization: Bearer for clients with no cookie jar. The
cookie wins when present. It reads the Cookie header itself, so it works
on any route. It does not refresh: silent refresh belongs to the auth
routes, and a bearer client refreshes through POST /auth/refresh itself.
Sourcepub fn require_auth(&self) -> RequireAuthLayer
pub fn require_auth(&self) -> RequireAuthLayer
A layer that answers 401 unless the request carries a valid session, and
puts the User in the request extensions for the handler behind it.