Expand description
Fortify-style authentication for Sova (register, verify, reset, 2FA, RBAC).
Builds on sova_passport (session login) + sova_db. Enable feature mail
(and install sova_mail::Mail) for email verification / password reset.
ⓘ
use sova_auth::{AuthMigrator, Feature, Fortify};
// Facade re-exports the same enum as `AuthFeature`.
app.install(Db::from_env().migrations::<AuthMigrator>());
app.install(memory_sessions());
app.install(
Fortify::new()
.features([Feature::Registration, Feature::ResetPasswords, /* … */])
.api_mount("/api/auth")
.login_redirect("/login")
.home("/cabinet"),
);
// Mail only when ResetPasswords / EmailVerification:
// app.install(Mail::from_env());
cabinet.use_middleware(Fortify::guard());
// Programmatic login (impersonation / seed / admin switch):
let cu = load_current_user(db, id).await?.unwrap();
req.login_user(cu); // regenerates session + passport:user
req.logout_user();Modules§
Structs§
- Auth
Migrator - Compose passport + fortify migrations for
Db::migrations::<AuthMigrator>(). - Confirm
Password Form - Current
User - Session principal for Fortify (web + API).
- Disable
TwoFactor Form - Forgot
Form - Fortify
- Laravel Fortify-style auth layer on top of Passport + Mail + Db.
- Fortify
Paths - Relative path segments for Fortify JSON routes.
- Login
Form - Password
Form - Profile
Form - Register
Form - Reset
Form - Reset
Password Mail - Password-reset message.
- TwoFactor
Code Form - Verify
Email Mail - Email-verification message.
Enums§
Traits§
- AuthExt
- Request helpers for RBAC (
CurrentUserfrom Fortify / Passport session).
Functions§
- assign_
role - create_
permission - create_
role - delete_
permission - delete_
role - find_
user_ by_ email - find_
user_ by_ id - list_
permissions - list_
roles - load_
current_ user - make_
verify_ token user_id.exp.sigfor email verification (24h).- mark_
email_ verified - parse_
verify_ token - register_
user - revoke_
role - send_
reset - send_
verify - set_
avatar - set_
user_ roles - sync_
role_ permissions - update_
permission - update_
role - user_
ids_ with_ permission - Users who hold
permission_slugvia any role, plus alladminrole members. - user_
ids_ with_ role - All user ids that have the given role slug (including via direct role_user).