Torii
Torii is a powerful authentication framework for Rust applications that gives you complete control over your users' data. Unlike hosted solutions like Auth0, Clerk, or WorkOS that store user information in their cloud, Torii lets you own and manage your authentication stack while providing modern auth features through a flexible plugin system.
Features
- Password Authentication: Secure password-based login with bcrypt hashing
- OAuth/OpenID Connect: Social login with major providers (Google, GitHub, etc.)
- Passkey/WebAuthn: Modern passwordless authentication with FIDO2
- Magic Links: Email-based passwordless authentication
- Session Management: Flexible session handling (opaque tokens or JWTs)
- Full Data Sovereignty: Store user data where you choose
- Multiple Storage Backends: SQLite, PostgreSQL, MySQL support via SeaORM
- Type Safety: Strongly typed APIs with compile-time guarantees
- Async/Await: Built for modern async Rust applications
Quick Start
- Add dependencies to your
Cargo.toml:
[]
= { = "0.2.0", = ["sqlite", "password"] }
- Set up your application:
use ;
use SqliteStorage;
use Arc;
async
Storage Backends
Choose the storage backend that fits your needs:
SQLite (Development & Small Apps)
[]
= { = "0.2.0", = ["sqlite", "password"] }
PostgreSQL (Production)
[]
= { = "0.2.0", = ["seaorm-postgres", "password"] }
MySQL (Production)
[]
= { = "0.2.0", = ["seaorm-mysql", "password"] }
Authentication Methods
Password Authentication
// Enable password auth
let torii = new;
// Register user
let user = torii.register_user_with_password.await?;
// Login
let = torii.login_user_with_password.await?;
JWT Sessions
use ;
let jwt_config = new;
let session_config = default.with_jwt;
let torii = new.with_session_config;