torii-storage-sqlite
SQLite storage backend for the Torii authentication framework.
This crate provides a complete SQLite-based storage implementation for Torii, including all core authentication features like user management, sessions, passwords, OAuth, passkeys, and magic links.
Features
- User Management: Store and retrieve user accounts with email verification support
- Session Management: Handle user sessions with configurable expiration
- Password Authentication: Secure password hashing and verification
- OAuth Integration: Store OAuth account connections and tokens
- Passkey Support: WebAuthn/FIDO2 passkey storage and challenge management
- Magic Link Authentication: Generate and verify magic links for passwordless login
- Database Migrations: Automatic schema management and upgrades
Usage
Add this to your Cargo.toml:
[]
= "0.4.0"
Basic Setup
use SqliteStorage;
use Arc;
async
With Password Authentication
use SqliteStorage;
use ;
use Arc;
async
Database Schema
The SQLite schema includes the following tables:
users- User accounts and profile informationsessions- Active user sessionspasswords- Hashed password credentialsoauth_accounts- Connected OAuth accountspasskeys- WebAuthn passkey credentialspasskey_challenges- Temporary passkey challengesmagic_links- Magic link tokens and metadata
All tables include appropriate indexes for optimal query performance.
Repository Provider
This crate provides SqliteRepositoryProvider which implements the RepositoryProvider trait from torii-core, allowing it to be used directly with the main Torii authentication coordinator.
Storage Implementations
This crate implements the following storage traits:
UserStorage- User account managementSessionStorage- Session management- Password repository for secure password storage
- OAuth repository for third-party authentication
- Passkey repository for WebAuthn support
- Magic link repository for passwordless authentication