Users cannot log in if Password Compatibility module is not enabled

Created on 5 May 2023, over 1 year ago
Updated 22 May 2023, over 1 year ago

Problem/Motivation

After a site is upgraded to Drupal 10.1, the new Password Compatibility module lets users log in with existing passwords.

Normally, this module is enabled in a post-update function. There are many things that can go wrong: at least

  1. No administrator is logged in when the code is updated, so no one can access /update.php.
  2. The site administrator uninstalls the module, not recognizing the consequences.
  3. The database is restored from a backup made before the upgrade.
  4. The module is uninstalled by importing configuration saved before the upgrade.
  5. Another update or post-update function creates an error, so the module is never enabled.
  6. The administrator neglects to execute database updates.

If no administrator is logged in, and any of these happens, then is is hard to enable the module and fix the problem.

Steps to reproduce

The following steps illustrate (1) from the previous section:

  1. Install Drupal 10.0.9 with the Standard profile.
  2. As a site admin, check the available updates.
  3. Notice that 10.1.0 has been released. (Currently, 10.1.0-alpha1 is the most recent version.)
  4. Decide to upgrade the next day.
  5. Log out and get a good night's sleep.
  6. The next day, update the code.
  7. Try to log in with the existing password. It will not work.

Proposed resolution

Recommend various ways to enable the module:

  • Log in as a site administrator using a one-time login link.
  • Enable the phpass module using Drush.
  • Set $settings['update_free_access'] = TRUE; in settings.php and then visit https://mysite.com/update.php.

We should communicate these options in as many ways as possible:

  1. Add a new section, "If you cannot log in", to the release notes, before "Upgrading from Drupal 6 and 7".
  2. Move the Q&A section from https://www.drupal.org/docs/core-modules-and-themes/core-modules/passwor... β†’ to the change record, so that it is one click away from the release notes instead of two clicks away. Or link directly to that page from the release notes.
  3. Expand the text on /admin/help/phpass. At least recommend logging out and logging in before uninstalling the module.
  4. Add a warning message to the confirmation form /admin/modules/uninstall/confirm when uninstalling phpass.
  5. (followup issue) Consider adding part of the Password Stats β†’ module to the Password Compatibility module. This will add a notice to the site status report, and it can be used to update the warning message in the previous point.

Remaining tasks

User interface changes

Before this issue, the text on /admin/help/phpass is

The Password Compatibility module provides the password checking algorithm for user entities created with Drupal prior to version 10.1.x. For more information, see the online documentation for the Password Compatibility module β†’ .

This issue expands that:

The Password Compatibility module provides the password checking algorithm for user accounts created with Drupal prior to version 10.1.0. For more information, see the online documentation for the Password Compatibility module β†’ .

Drupal 10.1.0 and later use a different algorithm to compute the hashed password. This provides better security against brute-force attacks. The hashed passwords are different from the ones computed with Drupal versions before 10.1.0.

When the Password Compatibility module is installed, a user can log in with a username and password created before Drupal 10.1.0. The first time these credentials are used, a new hash is computed and saved. From then on, the user will be able to log in with the same username and password whether or not this module is installed.

Passwords created before Drupal 10.1.0 will not work unless they are used at least once while this module is installed. Make sure that you can log in before uninstalling this module.

When the module is uninstalled through the admin UI, this issue adds a warning to the confirmation form at /admin/modules/uninstall/confirm:

API changes

None

Data model changes

None

Release notes snippet

TBD

πŸ› Bug report
Status

Fixed

Version

10.1 ✨

Component
User moduleΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

  • Issue created by @benjifisher
  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I am updating (1) in the proposed resolution: make it earlier on the page.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    @benjifisher, pinged me in Slack about this. I can confirm the problem using the steps to reproduce in the issue summary.

    Even though there is a workaround (using a one time login link) and there is no data loss I am changing to Critical, this should be done before 10.1 is released.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    Talked to catch, who pointed out that there is update_free_access and drush for situations where you can't login. and moving back to Major.

    I have done #2, updated the CR with the data from the Q and A section of the module doc page. I think that section can be removed from the docs page. For the CR, I moved the phpass section to the top of the API section and added formatting. I was going to add text to strongly suggest reading the CR but it just became too late.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    I updated the release notes to encourage reading the change record, but not as suggested in #1. Is it sufficient?

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    @quietone:

    I fixed a broken link in the release notes, and I formatted the Q&A section of the module docs using <h3> tags.

    I think we still need to do more in the release notes. If I am a site administrator who does not read instructions carefully, and find that I cannot log into my site, then I need something in the release notes that says, "If you cannot log in, then READ THIS." It should go on to tell me how I can install the module even though I cannot log in.

    I think that a separate <h3> near the top of the release notes, as I suggested in #1 of the proposed resolution, is the best way to help administrators in this situation. It should include something like the unordered list (bullet points) at the start of the proposed resolution.

    Thanks for turning the "API deprecations and behavior changes" section into a list. The previous formatting did not make it clear where one point finished and another started.

    I think I should pay some more attention to the text I added to the module doc page. I will try to do that in the next few days.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    Oops. And I usually check links. Thanks for the fix.

    I have added the module docs to the parent guide and added a section 'if you can not log in' to the change record. While not being to log in is disconcerting, getting a one-time login link is common practice. So, I don't think a new section in the release notes is needed.

  • last update over 1 year ago
    29,388 pass
  • @benjifisher opened merge request.
  • last update over 1 year ago
    29,388 pass
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    MR 3991 implements (3) and (4) from the proposed resolution. I have not yet updated the text on the module doc page.

    Most of the new text on the module's help page comes from the online documentation page. The paragraph at the end is new:

    Passwords created before Drupal 10.1.0 will not work unless they are used at least once while this module is installed. Make sure that you can log in before uninstalling this module.

    I hope that gets the point across. While the module is installed, legacy passwords will work. When the module is not installed, legacy passwords will work if they have been used while the module was installed.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I made one change to the existing text on the help page: I replaced "user entities" with "user accounts". I made the same change in the .info.yml file. (That text appears on /admin/modules.)

  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    @benjifisher thank you so much for pointing this out. I was considering upgrading a site to 10.1 that will launch end of June and this made me pause more.

    @rkoller left some comments and I chimed in but would refer to his expertise on the wording.

  • last update over 1 year ago
    29,388 pass
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    @smustgrave:

    Thanks for updating the issue status. I did not notice the comments on the MR.

    I updated 10.1.x to 10.1.0 in the MR and in the issue summary. I disagree with the other suggestions on the MR. Back to NR.

  • Status changed to RTBC over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Changes look good.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I added πŸ“Œ Add counts of legacy password hashes Active for Part 5 of the proposed resolution.

  • last update over 1 year ago
    29,388 pass
  • last update over 1 year ago
    29,388 pass
    • catch β†’ committed 9e8d5400 on 10.1.x
      Issue #3358524 by benjifisher, quietone, smustgrave: Users cannot log in...
    • catch β†’ committed b119e9b6 on 11.x
      Issue #3358524 by benjifisher, quietone, smustgrave: Users cannot log in...
  • Status changed to Fixed over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    This looks like a good improvement and it should get in before 10.1.0 - committed/pushed to 11.x and cherry-picked to 10.1.x, thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024