acseo/change-password-bundle
Symfony bundle for managing user password history with FOSUserBundle: stores previous hashed passwords, forces change when passwords are older than 30 days, and optionally blocks reusing old passwords via a validation constraint.
Pros:
Cons:
FOSUserBundle may limit flexibility if migrating away from it.Symfony/Laravel Bridge:
symfony/bundle, symfony/dependency-injection) if not already in stack.fos_user.change_password) must be mapped to Laravel’s auth events.Database Schema:
password_history table is straightforward but requires migration tooling (e.g., Laravel Migrations or Doctrine Schema updates).user_id and created_at recommended for performance.High:
EventDispatcher).sha512). Modern Laravel uses bcrypt/argon2—hashing strategy must align.fos_user_change_password route may clash with Laravel’s native /password routes.Mitigation:
Auth Stack Compatibility:
FOSUserBundle? If not, what’s the cost to migrate?bcrypt vs. sha512)?Performance:
password_history table scale with millions of users? (Query optimization needed?)Security:
password_history?Maintenance:
Alternatives:
passwords package + custom middleware achieve the same goals with less risk?Best Fit:
FOSUserBundle.laravel/symfony-bridge).Poor Fit:
Assessment Phase:
FOSUserBundle usage, hashing methods).Dependency Setup:
composer require acseo/change-password-bundle:dev-master
Configuration:
User entity to extend FOS\UserBundle\Model\User (or create a compatibility layer).config/packages/doctrine.yaml (Laravel) or app/config/config.yml (Symfony):
doctrine:
orm:
resolve_target_entities:
FOS\UserBundle\Model\User: App\Entity\User
Database Migration:
password_history:
php artisan doctrine:migrations:diff # If using Laravel Doctrine bridge
php artisan migrate
user_id and created_at:
// Example migration
Schema::create('password_history', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('password_hash');
$table->timestamp('created_at')->useCurrent();
$table->index(['user_id', 'created_at']);
});
Routing & Events:
fos_user_change_password route in Laravel’s routes/web.php:
Route::post('/change-password', [ChangePasswordController::class, 'changePassword'])->name('fos_user_change_password');
fos_user.change_password events (use Symfony’s EventDispatcher or Laravel’s Events facade).Testing:
Symfony:
FOSUserBundle.Laravel:
laravel-doctrine/orm).EventDispatcher (use symfony/event-dispatcher package).fos_user_change_password to Laravel’s routing system.Password Hashing:
PasswordHistory entity stores hashes in the same format as Laravel’s users table (e.g., bcrypt).Pros:
Cons:
Challenges:
Mitigation:
Database:
password_history table could grow large (e.g., 1M users × 5 passwords = 5M rows).user_id or created_at.Performance:
password_history on auth (add indexes to mitigate).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Bundle conflicts with Laravel auth | Broken password changes | Isolate bundle in a micro-service |
How can I help you explore Laravel packages today?