Skip to main content

auth

Function auth 

Source
pub fn auth(app_id: &str, permissions: &[&str]) -> AuthLayer
Expand description

Middleware that enforces authentication, for any tower stack — axum, tonic, or hyper.

Completes Stackure’s sign-in handoff by storing the returned session_token as a cookie on your domain, then stripping it from the URL. On success the user is inserted into the request extensions (read it back with user_from_request). Browser requests get redirected to sign-in on 401; API requests get JSON.

§Example

let app = app.layer(stackure::auth(
    "7f3c1a2e-9b4d-4e6f-8a1b-2c3d4e5f6071",
    &["view_any_app"],
));