Crate torii

Source
Expand description

§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 service architecture.

With Torii, you get powerful authentication capabilities like:

  • Password-based authentication
  • Social OAuth/OpenID Connect
  • Passkey/WebAuthn support
  • Magic Link authentication

Combined with full data sovereignty and the ability to store user data wherever you choose.

§Storage Support

Torii currently supports the following storage backends:

  • SQLite
  • Postgres
  • MySQL

§Warning

This project is in early development and is not production-ready. The API is subject to change without notice. As this project has not undergone security audits, it should not be used in production environments.

§Example

use torii::Torii;
use torii::sqlite::SqliteRepositoryProvider;
use std::sync::Arc;

#[tokio::main]
async fn main() {
    let pool = sqlx::SqlitePool::connect("sqlite::memory:").await.unwrap();
    let repositories = Arc::new(SqliteRepositoryProvider::new(pool));

    let torii = Torii::new(repositories);
}

Modules§

postgres
PostgreSQL storage backend
seaorm
SeaORM storage backend
sqlite
SQLite storage backend

Structs§

JwtClaims
Re-export core types from torii_core
JwtConfig
Re-export core types from torii_core
JwtMetadata
Re-export core types from torii_core
MagicLinkAuth
Magic link authentication provider
MailerConfig
Re-export mailer types when mailer feature is enabled
OAuthAuth
OAuth authentication provider
PasskeyAuth
Passkey authentication provider
PasswordAuth
Namespaced authentication providers for clean API organization
PasswordResetService
Service for password reset operations
SecureToken
Re-export storage types Generic secure token for various authentication purposes
Session
Re-export core types from torii_core
SessionConfig
The configuration for a session.
TemplateContext
Re-export mailer types when mailer feature is enabled
Torii
The main authentication coordinator that manages services and storage.
User
Re-export core types from torii_core
UserId
Re-export core types from torii_core

Enums§

JwtAlgorithm
Re-export core types from torii_core
SessionProviderType
Type of session provider to use
SessionToken
Re-export core types from torii_core
TokenPurpose
Re-export storage types Purpose enumeration for secure tokens to ensure type safety
ToriiError
Errors that can occur when using Torii.