iet-stack-auth-htmx-axum
Statically dispatched account UI presets; applications still own providers.
iet-stack-auth-htmx-axumpresetAccount UI presetHow to use it
This stack packages statically dispatched account UI presets. AuthStack::login(auth, csrf) requires only a BrowserLogin and a LoginCsrf; calling .account(provider) additionally enables logout and profile pages through a BrowserFlow provider, while .registration() and .password_recovery() opt into the public flows. The app still owns providers and either registers the stack onto a WebStack (RestApi) or mounts it onto its own Router.
// examples/htmx-starter/servers/web/src/main.rs
use ;
let csrf = new?;
let mut config = default;
config.login.secure_cookies = false;
config.login.session_cookie = "demo_session".into;
let api = login
.account // logout + profiles via the BrowserFlow provider
.configuration
.register?; // `stack` is a WebStack (iet_http_axum::RestApi)
Accountstarts with registration and recovery disabled; enable them explicitly with.registration()/.password_recovery().routes::<()>()/mount(router)are the alternatives when you already own theaxum::Router.StackConfigoverrides the route paths and delegates cookie/asset security toLoginConfig.
How it works
AuthStack is generic over a capability state (LoginOnly, then Account<P> once a BrowserFlow provider is attached); register, routes, and mount first validate the configuration, then compose the login routes with the capability's flow routes, and LoginOnly contributes none.
flowchart LR L["AuthStack login auth csrf"] --> O["LoginOnly"] O --> A["account provider"] A --> C["Account with registration and recovery flags"] C --> X["configuration StackConfig"] X --> P["register or routes or mount"] P --> V["validate paths and cookies"] V --> R["login register_module or routes_without_assets"] V --> F["asset_routes or module_with_policy per flow"] R --> OUT["Router or RestApi"] F --> OUT
What it implements
- Concrete mechanism; see the public API below.
What's inside
Modules
src/capabilities.rssrc/config.rssrc/lib.rssrc/stack.rs
Public API
capabilities
- struct
LoginOnly— Login-only capability state: does not require a BrowserFlow provider. - struct
Account— Explicit account capabilities. Registration/recovery are disabled initially. - trait
Capability
config
- struct
StackConfig
stack
- struct
AuthStack pub fn login(auth: A, csrf: C) -> Selfpub fn account<P: BrowserFlow>(self, provider: P) -> AuthStack<A, C, Account<P>>— Explicitly enable logout and profiles; does not enable public signup or recovery.pub fn registration(mut self) -> Selfpub fn password_recovery(mut self) -> Selfpub fn configuration(mut self, config: StackConfig) -> Selfpub fn routes<S>(self) -> AppResult<Router<S>> where S: Clone + Send + Sync + 'static,pub fn register<S, L>(self, api: RestApi<S, L>) -> AppResult<RestApi<S, L>> where L: iet_http_axum::RateLimit, S: Clone + Send + Sync + 'static,— Adds one named module; caller retains body limits, state and manual registrations.pub fn mount<S>(self, router: Router<S>) -> AppResult<Router<S>> where S: Clone + Send + Sync + 'static,
Impl map
Capability for LoginOnlyCapability for Account<P>Default for StackConfig
Depends on
External crates: axum
Used by
- No other framework crate depends on it directly.
In this repository
examples/htmx-starterexamples/skills-only-appexamples/skills-only-app-task-tracker
Source: crates/stacks/iet-stack-auth-htmx-axum