crates.io ↗

iet-auth-profiles-axum

integration adapter official

Registers the endpoint that selects a verified persona.

CoreFeaturesIntegrationsStacksTooling
Used byno framework crate yetexamples/htmx-starter
iet-auth-profiles-axumadapterProfile-selection REST adapter
Depends oniet-corecontractiet-authcontractiet-http-axumcontract

How to use it

Registers a profile-selection endpoint: it authenticates the bearer session, verifies the requested persona against a iet_auth::ProfileStore, and issues a new token bound to that profile through iet_auth::TokenIssuer. Pair it with a bearer authenticator, a profile store, and a token issuer.

rust
// examples/htmx-starter/servers/web/tests/framework_auth_rest.rs
iet_auth_profiles_axum::register(
    api,
    "/profile",
    sessions.clone(),   // impl Authenticate<Secret<String>>
    Arc::new(Profiles), // impl iet_auth::ProfileStore
    sessions,           // impl iet_auth::TokenIssuer
)
.unwrap()
.finish(42)
  • The route mounts as the auth.profiles module with a fixed 30/60s rate-limit policy.
  • A denied or unknown profile returns 403, and the issuer never runs.
  • Responses are Cache-Control: no-store.

How it works

register mounts the path as the auth.profiles module with (authenticator, profiles, issuer) as state; the handler validates SelectProfile, reads the bearer token, authenticates it, checks ProfileStore::enabled, then issues a token bound to the chosen profile.

flowchart LR
  Req["POST path"] --> Module["auth.profiles module"]
  Module --> Sel["api select"]
  Sel --> Val["ValidatedJson SelectProfile"]
  Sel --> Bearer["bearer_token"]
  Sel --> Auth["Authenticate Secret"]
  Sel --> Store["ProfileStore enabled"]
  Store --> Iss["TokenIssuer issue"]
  Iss --> Resp["TokenResponse no-store"]

What it implements

  • Concrete mechanism; see the public API below.

What's inside

Modules

  • src/api.rs
  • src/dto.rs
  • src/injector.rs
  • src/lib.rs

Public API

dto

  • struct SelectProfile

injector

  • pub fn register<S, A, P, I, L>( api: RestApi<S, L>, path: &str, authentication: Arc<A>, profiles: Arc<P>, issuer: Arc<I>, ) -> AppResult<RestApi<S, L>> where — Registers verified profile selection and issues a token for that principal.

Impl map

  • Validate for SelectProfile

Depends on

External crates: axum, serde

Used by

  • No other framework crate depends on it directly.

In this repository

  • examples/htmx-starter

Source: crates/integrations/iet-auth-profiles-axum