pub async fn require_auth<S>(
state: State<S>,
request: Request<Body>,
next: Next,
) -> ResponseExpand description
Axum middleware that requires a valid authenticated session.
Validates the session cookie, fetches the user, and inserts the User
into request extensions so downstream handlers can access it cheaply via
Extension<User>. Returns 401 JSON on any authentication failure.
Apply to a route group with axum::middleware::from_fn_with_state(ath, require_auth).