Skip to main content

secure

Function secure 

Source
pub fn secure(router: Router, loopback_token: bool) -> Router
Expand description

Put a Rahti router behind the native security layers.

One call rather than two .layer(...) lines in every generated shell, for two reasons. The shell then needs no axum dependency of its own — it never names a type from it — and the order of the two layers is decided here, where it can be tested, rather than in generated code where getting it backwards would be invisible.

The order: axum applies the last .layer outermost, so the gate is added second and runs first. A request that did not come from this launch is refused before it reaches the auth guard, the CSRF layer, a handler, or the static file service.

loopback_token is security.loopbackToken. When it is off the layer is not in the router at all, rather than present and deciding it does not apply.