8000 [Security] Do not make PasswordUpgraderInterface a generic by wouterj · Pull Request #51283 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Do not make PasswordUpgraderInterface a generic #51283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2023

Conversation

wouterj
Copy link
Member
@wouterj wouterj commented Aug 5, 2023
Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Ref #50399 (comment)
License MIT
Doc PR -

Making PasswordUpgraderInterface a generic in 6.3 (#48750) was a mistake. Nothing guarantees that the calling side will only pass TUser into the upgradePassword() method, as there is no way to check which users are supported. Passing a potentially unsupported user is expected behavior and we document in the PHPdoc that the method should silently fail in such cases. The referenced GitHub discussion contains some more details.

Removing the generic from the interface creates a static analysis failure in both Psalm and PHPstan. For this reason, I selected the 6.4 branch although this is a bug fix for 6.3. I'm fine with merging this in 6.3 as well, if this feels better.

@fabpot
Copy link
Member
fabpot commented Aug 5, 2023

Thank you @wouterj.

@fabpot fabpot merged commit 34f46c6 into symfony:6.4 Aug 5, 2023
@wouterj wouterj deleted the remove-generic-password-upgrader branch August 5, 2023 12:49
nicolas-grekas added a commit that referenced this pull request Mar 20, 2025
This PR was squashed before being merged into the 7.3 branch.

Discussion
----------

Improve documentation of PasswordUpgraderInterface

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | n/a
| License       | MIT

Implementations of PasswordUpgraderInterface can be called with a user instance that they don't support and are expected to handle it gracefully.
Handling it gracefully can be done either by being silent or by throwing an UnsupportedUserException.

This is a follow-up of #51283 to document that throwing UnsupportedUserException is actually fine for implementations as the way to handle unsupported users, as shown by the implementation of the ChainUserProvider: https://github.com/symfony/symfony/blob/07e020abdd1ab820ca3c2ead8dfda75ea6e84eae/src/Symfony/Component/Security/Core/User/ChainUserProvider.php#L107-L113

Commits
-------

0784f98 Improve documentation of PasswordUpgraderInterface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0