woutersf / uli-bundle
Generate secure one-time login links for Mautic users via command line
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:mautic-plugin
pkg:composer/woutersf/uli-bundle
Requires
- php: ^7.4|^8.0
- mautic/core: ^4.0|^5.0
README
This plugin provides the ability to generate secure one-time login links for Mautic users via console command.
Features
- 🔐 Secure One-Time Links: Generate cryptographically secure login URLs
- ⏰ Auto-Expiration: Links expire after 24 hours (configurable)
- 🗑️ Auto-Cleanup: Used links are automatically deleted
- 📋 Comprehensive Logging: All login attempts logged for security auditing
- 🛡️ Security Built-in: Protection against replay attacks and expired tokens
- 💻 CLI-Based: Easy integration with automation and scripts
Usage
Generate a unique login link
php bin/console mautic:uli {user_id}
Example:
php bin/console mautic:uli 1
This will generate a URL like:
https://yourmautic.com/s/unique_login?hash=abc123...
Access the login link
Users can access the generated URL in their browser to be automatically logged in. The link:
- Expires after 24 hours
- Is automatically deleted after use
- Logs all access attempts (successful and failed)
Database Schema
The plugin creates a table plugin_uli_unique_logins with the following structure:
id- Primary keyhash- Unique 64-character hashuser_id- Foreign key to users tablettl- Time-to-live (expiration datetime)date_created- Creation timestamp
Security Features
- Cryptographically secure random hash generation
- Automatic cleanup of expired tokens
- Comprehensive logging of all login attempts
- User account status validation
- Protection against replay attacks (one-time use)
Installation
Option 1: Composer (Recommended)
-
Add the plugin to your Mautic installation:
composer require mautic/uli-bundle
-
Run database migrations:
php bin/console doctrine:migrations:migrate
-
Clear the Mautic cache:
php bin/console cache:clear
-
Navigate to Mautic Settings → Plugins and verify installation
Option 2: Manual Installation
-
Clone or download this repository into your Mautic plugins directory:
cd /path/to/mautic/plugins git clone <repository-url> MauticUliBundle
-
Run database migrations:
php bin/console doctrine:migrations:migrate
-
Clear the Mautic cache:
php bin/console cache:clear
-
Navigate to Mautic Settings → Plugins and verify installation
Option 3: Private Repository
If you're hosting this plugin in a private repository, add it to your composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/your-username/mautic-uli-bundle.git"
}
],
"require": {
"mautic/uli-bundle": "^1.0"
}
}
Then run:
composer update mautic/uli-bundle php bin/console doctrine:migrations:migrate php bin/console cache:clear
Configuration
The plugin supports the following configuration parameters:
uli_token_lifetime- Token lifetime in hours (default: 24)
You can configure this in your app/config/local.php:
return [ 'parameters' => [ 'uli_token_lifetime' => 48, // 48 hours ], ];
Use Cases
- Password Recovery: Generate secure login links for users who forgot their password
- Customer Support: Provide temporary access to user accounts for support purposes
- Automation: Integrate with scripts to provide secure access after account creation
- Emergency Access: Quick access for administrators without knowing passwords
- Testing: Generate login links for testing purposes without managing passwords
Requirements
- Mautic 4.x or higher
- PHP 7.4 or higher
- Database with migration support
Publishing to Packagist
To make this plugin available via Composer for everyone:
-
Push to GitHub (or GitLab/Bitbucket):
git init git add . git commit -m "Initial release v1.0.0" git tag v1.0.0 git remote add origin https://github.com/your-username/mautic-uli-bundle.git git push -u origin main git push --tags
-
Submit to Packagist:
- Go to https://packagist.org
- Sign in with your GitHub account
- Click "Submit"
- Enter your repository URL:
https://github.com/your-username/mautic-uli-bundle - Packagist will automatically track new releases via your Git tags
-
Auto-Update Hook (Optional):
- In your GitHub repository settings, add Packagist webhook for automatic updates
- Settings → Webhooks → Add webhook
- Payload URL:
https://packagist.org/api/github?username=YOUR_USERNAME
Version Tagging
When releasing new versions:
# Update composer.json version if needed git add . git commit -m "Release v1.1.0" git tag v1.1.0 git push && git push --tags
Packagist will automatically detect the new tag and update the package.
Author
Mautic Community / Frederik Wouters
License
GPL-3.0-or-later
Support
For issues, questions, or contributions, please open an issue in the repository.
Changelog
Version 1.0.0
- Initial release
- Secure one-time login link generation via CLI
- 24-hour token expiration (configurable)
- Automatic cleanup of used/expired tokens
- Comprehensive security logging
- Database migrations
- Composer support