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

torii-auth-password

Password authentication plugin for the torii authentication ecosystem

3 releases

new 0.2.2 Mar 5, 2025
0.2.1 Feb 27, 2025
0.2.0 Feb 27, 2025

#417 in Authentication

Download history 214/week @ 2025-02-22 202/week @ 2025-03-01

416 downloads per month
Used in torii

MIT license

74KB
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.

Usage

use torii_auth_password::PasswordPlugin;
use torii_storage_sqlite::SqliteStorage;
use torii_core::PluginManager;
use std::sync::Arc;

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

let mut manager = PluginManager::new(user_storage);
manager.register_plugin(plugin);

// Register a new user
let plugin = manager.get_plugin::<PasswordPlugin<SqliteStorage>>("password").unwrap();
let user = plugin.register_user_with_password("user@example.com", "password123", None).await?;

// Login an existing user
let user = plugin.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.

Features

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

Dependencies

~9–18MB
~227K SLoC