Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Security] Document upgrading password hashes #12395

Copy link
Copy link
Closed
@wouterj

Description

@wouterj
Issue body actions

This is a combination of #11661, #12091, #11656

We should add a new article in security/ explaining how to migrate/upgrade a password hash, so that the safest possible hash is always used. In order to support migrating passwords, two things are necessary:

  1. The key here is to use encoder: auto. It'll create a MigratingPasswordEncoder ([Security] add MigratingPasswordEncoder #11661) with a list of encoder, from most to least secure. It'll loop over the list to try and find an encoder that can validate the user password. It'll also check if there is a better encoder available for this password hash.

  2. Then the UserProvider (or, when using Doctrine, the UserRepository) needs to implement Symfony\Component\Security\Core\User\PasswordUpgraderInterface. This interface has an upgradePassword() method that receives the new (more secure) hash and needs to store it in the database ([Security] add support for opportunistic password migrations #12091). It'll only be called if a better hash is generated.

The maker bundle is updated to create ready to use UserRepositories and security configuration by default.

When a custom encoder is created/used, it needs to implement a needsRehash() method. When this returns true, the credentials are rehashed using the encoder (and PasswordUpgraderInterface::upgradePassword() is called to store this new hash for the user) (#11656).

Metadata

Metadata

Assignees

Labels

SecurityactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.