Skip to main content

Crate doido_auth

Crate doido_auth 

Source
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::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 of config/<env>.ymlAuthConfig.
confirmable
confirmable module — require email confirmation before sign-in (the Devise confirmable analogue). Operates on the conventional users columns (confirmation_token, confirmed_at, confirmation_sent_at) via backend-agnostic SQL, gated at runtime by auth.modules. Delivery uses the global doido-mailer deliverer.
controllers
Default auth controllers shipped with doido-auth.
error
Typed auth errors (thiserror per 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 AuthUser and 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
lockable module — locks an account after repeated failed sign-ins and auto-unlocks after auth.unlock_in seconds. Operates on the conventional users columns (failed_attempts, locked_at) via backend-agnostic SQL, gated at runtime by auth.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
recoverable module — password reset via an emailed token (the Devise recoverable analogue). Operates on the conventional users columns (reset_password_token, reset_password_sent_at) via backend-agnostic SQL, gated at runtime by auth.modules. Delivery uses the global doido-mailer deliverer, so tests can capture the mail with a TestDeliverer.
registry
Custom strategy registration at boot.
rememberable
rememberable module — a persistent “remember me” cookie that signs the user back in across browser sessions (the Devise rememberable analogue). Stamps remember_created_at and issues a signed, Max-Age-bearing cookie; a RememberStrategy resolves 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
trackable module — records sign-in statistics (count, timestamps, IPs) on the conventional users columns. Gated at runtime by auth.modules.
user
Generic authenticated subject contract — apps implement this on their User model.
validations
validatable module — email format + password length checks on registration (the Devise validatable analogue). Gated at runtime by auth.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! (like devise_for).

Attribute Macros§

auth_controller
Marks an auth controller impl, preserving generic type parameters (unlike doido_controller::controller on impl<U> …).