Do not force 'social auth' based user to change password

Created on 3 November 2023, 8 months ago
Updated 7 April 2024, 3 months ago

Problem/Motivation

For users using the social_auth module to login (For ex: by social_auth_google module or social_auth_facebook module etc), we do not request for any passwords.
For such users, we do not have to enable 'password expiration'.

Steps to reproduce

One scenario:
We have a password_policy module + change_pwd_page module

  • User Signed in via social login - Google for ex
  • Due to the password_policy module & its config, password expiration gets enabled for the user after a few days. (based on the expiration duration set by admin)
  • The User tries to sign up again via social login. He is logged in but gets redirected to the change-password page (this page will have current pass and New pass fields shipped with the change_pwd_page module)
  • The user will be blocked as he will not be able to change the pass - because there was no 'current password' in the first place.

Proposed resolution

Use the fix shared in #3092396: Do not force SSO based user to change password - We avoid setting the checkbox 'password expiration' for users that are logged in via social login method.
Any other solutions are also welcome :)

Another related issue is 🐛 Do not force OpenID connect SSO based user to change password Active

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

🇮🇳India ankithashetty Karnataka, India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ankithashetty
  • 🇮🇳India ankithashetty Karnataka, India
  • Status changed to Needs review 8 months ago
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 7.4 & MySQL 5.7
    last update 8 months ago
    Waiting for branch to pass
  • 🇮🇳India ankithashetty Karnataka, India

    Please review the patch.
    Thanks!

  • 🇮🇳India ankithashetty Karnataka, India

    Uploading a patch here for an older version of the module. This can be ignored ignored.

  • 🇬🇧United Kingdom marcelovani London

    @ankithashetty, what is the current behaviour when change_pwd_page module is not enabled, but we have password_policy + social_auth only?

  • Status changed to Needs work 8 months ago
  • 🇮🇳India rashid_786

    Please add helper comment on before line
    $valid_list = array_diff($valid_list, $social_auth_user_ids);

  • 🇮🇳India ankithashetty Karnataka, India

    @marcelovani, the issue exists even w/o change_pwd_page. It's observed when a user is logged in via social_auth and has password_policy set.

    Let me rewrite the scenario again w/o change_pwd_page.
    Second scenario:
    We have a password_policy module + social_auth module (w/o change_pwd_page module)

    • User Signed in via social login - Google for ex via social_auth
    • Due to the password_policy module & its config, password expiration gets enabled for the user after a few days. (based on the expiration duration set by admin)
    • The User tries to sign up again via social login. He is logged in but gets redirected to the user/%/edit page (w/o the password field)
    • The user will be blocked again.
  • @ankithashetty opened merge request.
  • Status changed to Needs review 8 months ago
  • 🇮🇳India ankithashetty Karnataka, India

    Addressed the comments made in #6 in the MR:https://git.drupalcode.org/project/password_policy/-/merge_requests/61

    CC: @rashid_786

  • Status changed to Postponed: needs info 5 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Hmm... I don't love that we are adding special cases for specific modules in different spots. If we are going to check for certain modules, then it would be nice to put them all together in one check, e.g.

    function usesExternalLogin() {
      // Check all the different modules here and return true or false.
    }
    

    This would require refactoring the other logic too.

    But, it's unclear how this can work if we are grabbing data from these different systems.

    IMO this needs deeper thought at the architectural level. I didn't build this module though... was just added as a co-maintainer.

    I would like more feedback from those more familiar with the architecture.

  • 🇨🇦Canada bryden

    Expanding on Kristen's idea to keep this functionality in one place rather than special cases popping up for each module, I believe a custom hook would be more appropriate. This would allow developers to override the list of users that are set to have their passwords expire by calling a hook like HOOK_password_policy_expired_list_alter($valid_list), doing their own checks on a per user ID basis, and then returning the $valid_list of users to have their passwords expire.

    This would let any third party module take care of special cases, whether that means modules such as externalauth decide to handle it natively, or an in-shop developer creates a private custom module to handle their specific use case for their organization.

  • Status changed to Needs review 4 months ago
  • 🇨🇦Canada bryden

    Setting status to needs review so that the maintainer can decide if they still need more info

  • Status changed to Postponed: needs info 3 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    I like the idea of some sort of hook(s) where other modules could opt-out or opt-in as needed.

    We could then have our own submodules if we did want to support these additional services (or the other service modules could integrate).

    Then developers could decide if they needed the submodules or not. This would keep the main/core code cleaner and provide better performance and easier maintenance.

    I'd still like others to chime in on this though so I'm moving back to postponed for now.

Production build 0.69.0 2024