#password #user #plugin #torii #email #validation

torii-auth-password

Password authentication plugin for the torii authentication ecosystem

2 releases

new 0.2.1 Feb 27, 2025
0.2.0 Feb 27, 2025

#867 in Authentication


Used in torii

MIT license

73KB
1.5K SLoC

A plugin for Torii that provides email and password authentication.

This plugin allows users to register and authenticate using an email address and password. It handles password hashing, validation, and session management.

Usage

use torii::Torii;
use torii_storage_sqlite::SqliteStorage;
use std::sync::Arc;

let user_storage = Arc::new(SqliteStorage::new(pool.clone()));
let session_storage = Arc::new(SqliteStorage::new(pool.clone()));

let torii = Torii::new(user_storage, session_storage)
    .with_password_plugin();

// Register a new user
let user = torii.register_user_with_password("user@example.com", "password123").await?;

// Login an existing user
let (user, session) = torii.login_user_with_password("user@example.com", "password123").await?;

The password plugin requires a storage implementation that implements the PasswordStorage trait for storing user credentials and the SessionStorage trait for managing sessions.

Features

  • User registration with email and password
  • Password hashing and validation
  • Session management
  • Optional email verification
  • Event emission for authentication events

Dependencies

~9–18MB
~228K SLoC