Skip to content

[Validator] Revert "feature #49789 New PasswordStrength constraint (Spomky)" #49831

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

Closed
wants to merge 1 commit into from

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Mar 27, 2023

This reverts commit c375406, reversing changes made to 497e966.

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

The dev dependency added in #49789 looks problematic:
https://github.com/bjeavons/zxcvbn-php has no commit in 2 years, ignored vulnerability reports + unmerged php compatibility fixes.
Worse, the JS project it's based on didn't make any change in 6 years, has ignored security reports as well and seems to be officially abandoned (dropbox/zxcvbn#290, dropbox/zxcvbn#295).

I propose to revert this change for now, then revisit the topic as soon as possible.
Also some core members argued that this feature could be better handled on the frontend i.e. rewritten as a UX component or a cookbook example.
Either way, if we want to do re-add this, we would need to fork and update the abandoned package. And if it's frontend, we need to find a maintained alternative.

…traint (Spomky)"

This reverts commit c375406, reversing
changes made to 497e966.
@carsonbot carsonbot added this to the 6.3 milestone Mar 27, 2023
@carsonbot carsonbot changed the title Revert "feature #49789 [Validator] New PasswordStrength constraint (Spomky)" [Validator] Revert "feature #49789 New PasswordStrength constraint (Spomky)" Mar 27, 2023
@nicolas-grekas
Copy link
Member

Fine by me to revert for the given reason.

Having this on the server side makes sense to me, see eg #49821, which would enable nice password migration strategies.

It'd be great to figure out a working algo/lib that could work both on the frontend and on the backend.

@weaverryan spotted this lib, which looks quite simple to port to PHP:
https://github.com/deanilvincent/check-password-strength/blob/master/index.js

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Mar 27, 2023

Note that instead of reverting, we would happily accept a PR that replaces the implementation.

@chalasr
Copy link
Member Author

chalasr commented Mar 27, 2023

ping @Spomky FYI

@Spomky
Copy link
Contributor

Spomky commented Mar 27, 2023

Hi,

OK I understand the problem here.
What I can propose is to create an interface used by the validator. This will allow developpers to use zxcvbn-php or any other implementation. WDYT?

@chalasr
Copy link
Member Author

chalasr commented Mar 27, 2023

I think we need this to work out-of-the-box with a properly maintained reference implementation anyway :)

@nicolas-grekas
Copy link
Member

The lib is in bad maintenance state so I'm not sure we need to make it easy to use it. Also, options are specific to each password checkers so I'm not sure we can have this abstraction.

@Spomky
Copy link
Contributor

Spomky commented Mar 27, 2023

Also some core members argued that this feature could be better handled on the frontend i.e. rewritten as a UX component or a cookbook example.

Regarding this, I am preparing a stimulus component to show the strength while typing the password.
But is it sufficient on client side? I think the submitted password should be verified by the application.

@jdreesen
Copy link
Contributor

And if it's frontend, we need to find a maintained alternative.

There is a modern TypeScript rewrite: https://github.com/zxcvbn-ts/zxcvbn

@Spomky
Copy link
Contributor

Spomky commented Mar 27, 2023

I think we need this to work out-of-the-box with a properly maintained reference implementation anyway :)

As a symfony/* component or maybe I could handle this in a new repository I own

@chalasr
Copy link
Member Author

chalasr commented Mar 27, 2023

As a symfony/* component

Fine by me as long as you maintain it :)

@javiereguiluz
Copy link
Member

What I find problematic with zxcvbn is that it requires to generate large sets of data (up to MBs, depending on the locales used in the app).

I like @nicolas-grekas idea to port this JS library to PHP (it's just a few lines of code and it could be enough for most apps):

@weaverryan spotted this lib, which looks quite simple to port to PHP:
https://github.com/deanilvincent/check-password-strength/blob/master/index.js

@Spomky
Copy link
Contributor

Spomky commented Mar 27, 2023

OK I get it now.
My proposal:

  • A new PR that uses most of the previous logic (in particular the constraint object)
  • A new interface|null injected to the validator constructor (let say StrengthEstimatorInterface)
  • A basic strength estimator that implements StrengthEstimatorInterface and used by default (I will check the link shared by @javiereguiluz)
  • For the framework bundle, an option to define another strength estimator
  • For the tests, we could also have a mock

Fine by me as long as you maintain it :)

@chalasr yes! In paralell, I will work on a side project based on the typescript implementation shared by @jdreesen.
It will also implement the StrengthEstimatorInterface so that anyone could use it in place of the basic one.

@WebMamba
Copy link
Contributor

I like the idea! I was thinking about similar as well 😁

@nicolas-grekas
Copy link
Member

If we really want to make the implementation swappable, I'd suggest using a closure instead of adding an interface.

@chalasr
Copy link
Member Author

chalasr commented Mar 29, 2023

Alternative: #49856. Please close this one once it is ready

@fabpot fabpot closed this Mar 29, 2023
@chalasr chalasr deleted the revert-49789 branch March 30, 2023 14:24
fabpot added a commit that referenced this pull request Mar 31, 2023
… builtin solution (Spomky)

This PR was merged into the 6.3 branch.

Discussion
----------

[Validator] Remove `bjeavons/zxcvbn-php` in favor of a builtin solution

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #49831
| License       | MIT
| Doc PR        | symfony/symfony-docs#18124 will be updated

As per the discussion in #49831, this PR aims at removing `bjeavons/zxcvbn-php` in favor of a builtin solution.
The password strength estimator is a PHP implementation of [deanilvincent/check-password-strength](https://github.com/deanilvincent/check-password-strength/blob/master/index.js), but can be changed at will.

Commits
-------

6b2bf22 Remove bjeavons/zxcvbn-php in favor of a builtin solution
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.

9 participants