1 unstable release
new 0.2.1 | Mar 5, 2025 |
---|
#933 in Authentication
102 downloads per month
73KB
1K
SLoC
Magic Link authentication plugin for Torii
This plugin provides magic link authentication functionality, allowing users to sign in by clicking a secure link sent to their email address rather than using a password.
Features
- Generate secure one-time use magic links
- Verify magic link tokens
- Automatic user creation if not exists
- Configurable token expiration
Example
use torii_auth_magic_link::MagicLinkPlugin;
use torii_core::plugin::PluginManager;
// Register the plugin with your PluginManager
let mut plugin_manager = PluginManager::new(user_storage.clone(), session_storage.clone());
plugin_manager.register_plugin(MagicLinkPlugin::new(user_storage.clone()));
// Generate a magic link token
let plugin = plugin_manager.get_plugin::<MagicLinkPlugin>("magic_link").unwrap();
let token = plugin.generate_magic_token("user@example.com").await?;
// Verify the token when user clicks the link
let user = plugin.verify_magic_token(&token.token).await?;
Dependencies
~7–15MB
~167K SLoC