cyve/password-manager-bundle
Installation
composer require cyve/password-manager-bundle
Enable the bundle in config/bundles.php:
Cyve\PasswordManagerBundle\CyvePasswordManagerBundle::class => ['all' => true],
Routing & Security
Add the routes in config/routes.yaml:
cyve_password_manager:
resource: "@CyvePasswordManagerBundle/Resources/config/routing.yaml"
Configure security.yaml to enable login links:
security:
firewalls:
main:
login_link:
check_route: app_login_check
signature_properties: ['userIdentifier']
First Use Case
/password/request-login-link (user submits email/username)./password/update).Request Login Link
/password/request-login-link.LoginLinkAuthenticator)._target_path=/password/update (default).Password Update
/password/update (protected route).UserPasswordHasher.CLI Reset (Admin Use)
bin/console cyve:password:reset <username> <new_password>
templates/CyvePasswordManagerBundle/email/login_link.html.twig.User entity implements PasswordAuthenticatedUserInterface (Symfony’s requirement for password updates).routing.yaml to change /password/update or /request-login-link paths.login_link is configured in the firewall where the user should authenticate.Extend the controller or template:
{# templates/CyvePasswordManagerBundle/password/update.html.twig #}
{{ form_start(form, { attr: { class: 'custom-form' } }) }}
{{ form_widget(form) }}
<button type="submit" class="btn btn-primary">Update Password</button>
{{ form_end(form) }}
_target_path Hardcoding
_target_path=/password/update. If you rename this in security.yaml, redirection breaks.LoginLinkAuthenticator to match your config.Missing UserPasswordHasher
User entity lacks PasswordAuthenticatedUserInterface, password updates fail silently.password property is protected.Email Configuration
MAILER_DSN in .env.templates/CyvePasswordManagerBundle/email/).CSRF Protection
/password/update route is protected but may lack CSRF for POST requests.security.yaml includes csrf_token for the form.bin/console debug:container cyve_password_manager.login_link_authenticator to verify the authenticator is registered.# config/services.yaml
Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher:
decorates: event_dispatcher
arguments: ['@.inner']
Custom Authenticator
Extend LoginLinkAuthenticator to add logic (e.g., rate-limiting):
class CustomLoginLinkAuthenticator extends LoginLinkAuthenticator
{
public function checkPostCredentials($credentials): void
{
// Add custom validation
}
}
Register it in security.yaml:
firewalls:
main:
login_link:
authenticator: app.custom_login_link
Password Policies Add validation to the update form (e.g., minimum length):
// src/EventListener/PasswordUpdateListener.php
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class PasswordUpdateListener
{
public function __construct()
{
$this->container->get('event_dispatcher')->addListener(
FormEvents::PRE_SUBMIT,
[$this, 'onPasswordUpdate']
);
}
public function onPasswordUpdate(FormEvent $event)
{
$data = $event->getData();
if (strlen($data['plainPassword']) < 8) {
$event->getForm()->addError(new FormError('Password too short.'));
}
}
}
Multi-Factor Auth (MFA)
Integrate with Symfony’s MfaAuthenticatorInterface to require MFA during password updates.
signature_properties in security.yaml must match your User entity’s identifier (e.g., email or username).
Example for email:
signature_properties: ['email']
How can I help you explore Laravel packages today?