Skip to content

Custom PasswordHasher block migration of passwords #48348

@thisismeonmounteverest

Description

@thisismeonmounteverest

Symfony version(s) affected

5.4

Description

My project needs a LegacyPasswordHasher to verify old MYSQL passwords and the security configuration should make sure that these passwords are migrated to a newer algorithm. Unfortunately this fails.

How to reproduce

Configure the legacy password hasher in security.yaml:

        legacy:
            id: 'App\Security\PasswordHasher\LegacyPasswordHasher'

        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
            algorithm: 'auto'
            migrate_from:
                - legacy

Implement the PasswordHasherAwareInterface on the user entity checks and make it return 'legacy' to trigger that password hasher:

public function getPasswordHasherName(): ?string
{
    if (preg_match('/^\*[0-9A-F]{40}$/', $this->getPassWord())) {
        return 'legacy';
    }

    return null;
}

Possible Solution

No response

Additional Context

The culprit is in vendor/symfony/security-http/EventListener/PasswordMigratingListener.php::onLoginSuccess when creating the new password hash it calls LegacyPasswordhasher instead of the expected default password hasher.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy