torii-auth-password 0.2.0

Password authentication plugin for the torii authentication ecosystem
Documentation

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