Skip to main content

Module auth

Module auth 

Source
Expand description

§modo::auth

Identity and access — session, JWT, OAuth, API keys, roles, and gating guards.

This is the umbrella module for everything related to authenticating callers and gating routes. Each capability lives in its own submodule; the guard submodule houses the route-level layers (require_authenticated, require_role, require_scope) that compose with the rest.

Always available — no feature flag required.

§Submodules

ModulePurpose
sessionDatabase-backed HTTP session management (cookie and JWT sessions)
apikeyPrefixed API key issuance, verification, and lifecycle
roleRole-based gating (extractor + middleware)
guardRoute-level gating layers (require_authenticated, require_role, require_scope)
jwtJWT encoding, decoding, signing, and axum Tower middleware (alias for session::jwt)
oauthOAuth 2.0 provider integrations (GitHub, Google)
passwordArgon2id password hashing and verification
otpNumeric one-time password generation and verification
totpRFC 6238 TOTP authenticator (Google Authenticator compatible)
backupOne-time backup recovery code generation and verification

§Convenience re-exports

The following types are re-exported at the modo::auth level for convenience:

Re-exports§

pub use crate::auth::session::jwt;
pub use password::PasswordConfig;
pub use totp::Totp;
pub use totp::TotpConfig;
pub use jwt::Bearer;
pub use jwt::Claims;
pub use jwt::HmacSigner;
pub use jwt::JwtConfig;
pub use jwt::JwtDecoder;
pub use jwt::JwtEncoder;
pub use jwt::JwtError;
pub use jwt::JwtLayer;
pub use jwt::JwtSessionsConfig;
pub use jwt::TokenSigner;
pub use jwt::TokenSource;
pub use jwt::TokenSourceConfig;
pub use jwt::TokenVerifier;
pub use jwt::ValidationConfig;

Modules§

apikey
modo::auth::apikey
backup
guard
Route-level gating layers — require_authenticated, require_role, require_scope.
oauth
modo::auth::oauth
otp
password
role
modo::auth::role
session
modo::auth::session
totp