Problem/Motivation

Most password managers are able to fill the login form correctly by guessing what each field means. However, it is a good practice to use autocomplete attributes to explicitly declare what should be filled.

Proposed resolution

We could add autocomplete="username" on the username field and autocomplete="current-password" on the password field both in the user login and the reset password form.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

The default login and password reset forms now include autocomplete attributes, giving better hints to browsers as to what can be automatically filled in where possible. Sites that previously disabled autocomplete will need to check that the technique they use is still compatible with the updated form.

Issue fork drupal-3181647

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

cilefen’s picture

Version: 9.0.x-dev » 9.2.x-dev

tobiasb made their first commit to this issue’s fork.

tobiasb’s picture

Status: Active » Needs review
Issue tags: +Novice
ilgnerfagundes’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new27.48 KB
new28.08 KB
new33.96 KB
new26.53 KB

I did the test locally and everything seems to be correct, with the application of the changes the autocomplete appears in the proposed fields. I am leaving images as proof that I did the test locally and that it is really working.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record, +Needs release note

There are contrib modules that explicitly disable autocompete on the login form, so this needs a release note and a change record in case those need to be updated for some reason.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pasqualle’s picture

According to
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site...

it is not possible to disable autocomplete on the login form any more. The same is stated on the No Autocomplete project page.

cilefen’s picture

Status: Needs work » Postponed (maintainer needs more info)

Should we close this feature request as effectively impossible to implement?

prudloff’s picture

This issue is about using autocomplete="username" and autocomplete="current-password" and we can still implement this.
#12 is answering #7 by saying that most browsers now ignore autocomplete="off" so we don't need to take this use case into account.

cilefen’s picture

Status: Postponed (maintainer needs more info) » Active

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

prudloff’s picture

The password reset form could also probably benefit from autocomplete="username".

ultimike’s picture

We, the mentoring team, are triaging issues for first time contributors at DrupalCon Lille and I think this is a good issue for the contribution day.
We are reserving this issue so please don't work on this issue if you are not at DrupalCon Lille. You can continue the work when the event is over.

I'll be working on this issue today, with first-time contributors.

thanks,
-mike

mullzk’s picture

We are in the mentoring-contribution-workshop in DrupalCon Lille, and started to work on this issue.
Currently, we all get an error when starting up DrupalPod:

Notice: running 'composer update --lock' in ddev
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires drupal/core == 11.9999999.9999999.9999999-dev -> satisfiable by drupal/core[11.x-dev].
    - drupal/core 11.x-dev requires symfony/console ^4.4 -> found symfony/console[v4.4.0-BETA1, ..., 4.4.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 2
    - Root composer.json requires drupal/core-recommended == 11.9999999.9999999.9999999-dev -> satisfiable by drupal/core-recommended[11.x-dev].
    - drupal/core-recommended 11.x-dev requires drupal/core 9.2.x-dev -> satisfiable by drupal/core[9.2.x-dev] from composer repo (https://repo.packagist.org) but drupal/core[dev-3181647-add-autocomplete-attributes, 11.x-dev] from path repo (repos/drupal/core) has higher repository priority. The packages from the higher priority repository do not match your constraint and are therefore not installable. That repository is canonical so the lower priority repo's packages are not installable. See https://getcomposer.org/repoprio for details and assistance.
  Problem 3
    - Root composer.json requires drupal/core-dev == 11.9999999.9999999.9999999-dev -> satisfiable by drupal/core-dev[11.x-dev].
    - drupal/core-dev 11.x-dev requires behat/mink-browserkit-driver ^1.3 -> found behat/mink-browserkit-driver[v1.3.0, ..., 1.x-dev] but these were not loaded, likely because it conflicts with another require.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Failed to execute command composer update --lock: exit status 2
Failed to run exec_dir composer update --lock; error=exit status 1

real    0m13.019s
user    0m0.246s
sys     0m0.356s
gitpod /workspace/DrupalPod (main) $ 

Manually installing with ddev composer install worked, but then, drush was missing.
Manually installing with ddev composer require drush/drush worked, but then we get an error when installing the site:

gitpod /workspace/DrupalPod (main) $ ddev drush si --account-pass=admin
PHP Fatal error:  Class Drush\Commands\core_development\DevelopmentProjectCommands cannot extend final class Drush\Commands\core\CacheCommands in /var/www/html/drush/Commands/core_development/DevelopmentProjectCommands.php on line 0

Fatal error: Class Drush\Commands\core_development\DevelopmentProjectCommands cannot extend final class Drush\Commands\core\CacheCommands in /var/www/html/drush/Commands/core_development/DevelopmentProjectCommands.php on line 0
 [warning] Drush command terminated abnormally.
Failed to run drush si --account-pass=admin: exit status 1
gitpod /workspace/DrupalPod (main) $ 

ultimike’s picture

We overcame the Composer issue above by realizing that the original MR was over 2 years old and more than 3500 commits behind.

We went ahead and created an update branch and MR. Here's a summary of the steps we took to do so (mainly using the command line):

  1. Cloned Drupal core 11.x using instructions on https://www.drupal.org/node/3060/git-instructions/11.x/nonmaintainer
  2. Used the “Show commands” link on this issue to check out our issue fork.
  3. git rebase 11.x
  4. git push drupal-3181647 3181647-add-autocomplete-attributes --force
  5. git push drupal-3181647 11.x
  6. Created new 3181647-add-autocomplete-attributes-11 branch on the drupal-3181647 issue fork.
  7. Re-launched DrupalPod for this issue using the new fork.

The contributors from DrupalCon Lille were: @guzmanb, @maxime.rffd, @hexaki, @samuel_orhan, @rauch, @guiu.rocafort.ferrer, @mullzk, @binnythomas

guiu.rocafort.ferrer made their first commit to this issue’s fork.

guiu.rocafort.ferrer’s picture

Title: Add autocomplete attributes on login form » Add autocomplete attributes on login form and password reset form
Issue summary: View changes
guiu.rocafort.ferrer’s picture

Updated the issue title and description to include the 'user_pass' form.
Updated the 'user_pass' form to add the autocomplete parameter to the name field.
Also written two functional tests to check the 'user_login_form' form and the 'user_pass' form have the autocomplete attributes present in the name and pass fields ( if present ).

binnythomas’s picture

I reviewed the code in person at DrupalConLille. LTGM

ultimike’s picture

Status: Active » Needs review
jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed the code in MR!5066, tested it successfully locally and since all tests are passing as well, I'm setting this to RTBC.

lostcarpark’s picture

I have reviewed this change, and all looks in accordance with Drupal coding standards.
I have tested in DrupalPod and verified the autocomplete attributes are present.
I'm happy for this change to be merged.

nod_ credited guzmanb.

nod_ credited hexaki.

nod_ credited maxime.rffd.

nod_ credited rauch.

nod_ credited samuel_orhan.

nod_’s picture

Status: Reviewed & tested by the community » Fixed

Committed 981921d and pushed to 11.x. Thanks!

  • nod_ committed 981921d8 on 11.x
    Issue #3181647 by ultimike, guiu.rocafort.ferrer, tobiasb,...

  • nod_ committed 4e03083d on 10.2.x
    Issue #3181647 by ultimike, guiu.rocafort.ferrer, tobiasb,...
volkswagenchick’s picture

Adding attribution for the reviewer, James Sheild

bramdriesen’s picture

Issue tags: +DrupalCon Lille 2023

Adding the DrupalCon tag as well

Status: Fixed » Closed (fixed)

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

longwave’s picture

Added CR and release note snippet.

ronraney’s picture

Added a related issue because I think autocomplete should be set to "off" for security reasons, or at least the option to change it somewhere.
https://www.drupal.org/project/drupal/issues/3522461#comment-16094484