Expand description
Unified authentication for Doido — Devise + OmniAuth + JWT analogue.
Re-exports§
pub use config::load as load_config;pub use config::AuthConfig;pub use config::AuthModule;pub use config::AuthRoutesConfig;pub use config::JwtConfig;pub use config::YamlConfig;pub use controllers::AuthOauth;pub use controllers::AuthPasswords;pub use controllers::AuthRegistrations;pub use controllers::AuthSessions;pub use error::AuthError;pub use extractors::AuthToken;pub use extractors::CurrentUser;pub use extractors::MaybeUser;pub use extractors::RequireAuth;pub use framework_views::register_views;pub use handlers::authenticate;pub use handlers::register_user;pub use handlers::sign_in;pub use handlers::sign_in_with_session;pub use handlers::sign_out;pub use identity::AuthIdentity;pub use jwt::JwtClaims;pub use jwt::JwtStrategy;pub use jwt::TokenPair;pub use layer::auth_layer;pub use layer::current_identity;pub use layer::current_user;pub use oauth::OAuth2Provider;pub use oauth::OAuthProvider;pub use oauth::OAuthTokenResponse;pub use registry::register_strategy;pub use registry::registered_strategies;pub use route_mount::mount;pub use session::SessionStrategy;pub use session::SessionStrategy as CookieStrategy;pub use session::SESSION_COOKIE;pub use session::USER_ID_KEY;pub use state::global;pub use state::init;pub use state::set_state;pub use state::try_global;pub use state::AuthState;pub use strategy::AuthStrategy;pub use user::authenticate_password;pub use user::AuthUser;pub use user::RegisterableAuthUser;
Modules§
- config
auth:section ofconfig/<env>.yml→AuthConfig.- confirmable
confirmablemodule — require email confirmation before sign-in (the Deviseconfirmableanalogue). Operates on the conventionaluserscolumns (confirmation_token,confirmed_at,confirmation_sent_at) via backend-agnostic SQL, gated at runtime byauth.modules. Delivery uses the globaldoido-mailerdeliverer.- controllers
- Default auth controllers shipped with
doido-auth. - error
- Typed auth errors (
thiserrorper crate, per the framework convention). - extractors
- Axum extractors for authenticated requests.
- framework_
views - Built-in, overridable auth views (the Devise “views live in the gem” analogue).
- generators
- Shared helpers for auth generators — migration rendering, name inflection, and route/module injection.
- handlers
- Sign-in, sign-up, and sign-out helpers built on
AuthUserand bcrypt. - identity
- Resolved auth subject identity before the full user model is loaded.
- jwt
- JWT bearer strategy — sign/verify access and refresh tokens.
- layer
- Axum middleware that resolves auth identity via enabled strategies.
- lockable
lockablemodule — locks an account after repeated failed sign-ins and auto-unlocks afterauth.unlock_inseconds. Operates on the conventionaluserscolumns (failed_attempts,locked_at) via backend-agnostic SQL, gated at runtime byauth.modules. Email-based unlock is a follow-up; the time-based unlock strategy needs no mailer.- oauth
- OAuth provider registry — abstract interface + config-driven OAuth 2.0 impl.
- recoverable
recoverablemodule — password reset via an emailed token (the Deviserecoverableanalogue). Operates on the conventionaluserscolumns (reset_password_token,reset_password_sent_at) via backend-agnostic SQL, gated at runtime byauth.modules. Delivery uses the globaldoido-mailerdeliverer, so tests can capture the mail with aTestDeliverer.- registry
- Custom strategy registration at boot.
- rememberable
rememberablemodule — a persistent “remember me” cookie that signs the user back in across browser sessions (the Deviserememberableanalogue). Stampsremember_created_atand issues a signed,Max-Age-bearing cookie; aRememberStrategyresolves it on later requests when no session is present.- route_
mount - Programmatic auth router (
mount) for apps without generated controllers. - session
- Cookie/session strategy — integrates with
doido_controller::session. - state
- Process-global auth state installed at boot.
- strategy
- Pluggable authentication strategies.
- testing
- Test helpers and in-memory fakes for auth integration tests.
- trackable
trackablemodule — records sign-in statistics (count, timestamps, IPs) on the conventionaluserscolumns. Gated at runtime byauth.modules.- user
- Generic authenticated subject contract — apps implement this on their User model.
- validations
validatablemodule — email format + password length checks on registration (the Devisevalidatableanalogue). Gated at runtime byauth.modules.
Macros§
- __
auth_ routes_ decl - Internal: expands to
get!/post!/… lines consumed by [doido_auth::routes!]. - auth_
routes - Standalone Devise-style auth router (
.merge(doido_auth::auth_routes!(User))). - routes
- Application route table with Devise-style
auth_routes!(likedevise_for).
Attribute Macros§
- auth_
controller - Marks an auth controller impl, preserving generic type parameters (unlike
doido_controller::controlleronimpl<U> …).