6 releases
Uses new Rust 2024
0.2.3 | Mar 5, 2025 |
---|---|
0.2.2 | Feb 27, 2025 |
0.1.1 | Jan 27, 2025 |
#1406 in Database interfaces
577 downloads per month
125KB
2.5K
SLoC
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-based authentication
- Social OAuth/OpenID Connect
- Passkey/WebAuthn support
- Full data sovereignty - store user data where you want
- Multiple storage backends:
- SQLite
- PostgreSQL
- MySQL (#4)
Quick Start
- Add dependencies to your
Cargo.toml
:
[dependencies]
torii = { version = "0.2.0", features = ["sqlite", "password"] }
- Initialize the database:
let pool = SqliteStorage::connect("sqlite://todos.db?mode=rwc").await
.expect("Failed to connect to database");
let user_storage = Arc::new(pool.clone());
let session_storage = Arc::new(pool.clone());
// Migrate the user storage
user_storage
.migrate()
.await
.expect("Failed to migrate user storage");
// Migrate the session storage
session_storage
.migrate()
.await
.expect("Failed to migrate session storage");
let torii = Torii::new(user_storage, session_storage).with_password_plugin();
- Create a user:
let user = torii.register_user_with_password("test@example.com", "password").await?;
- Login a user:
let user = torii.login_user_with_password("test@example.com", "password").await?;
Dependencies
~6–26MB
~391K SLoC