Linking a local user account to a saml account may be incorrectly blocked

Created on 22 June 2023, about 1 year ago
Updated 8 August 2023, 11 months ago

Problem/Motivation

The Samlauth module allows SAML users to be mapped to local users by one or more of:

  • Enable matching on name
  • Enable matching on email

When logging in, Drupal\samlauth\SamlService->doLogin is called. This will do the following if no account is passed in:

  1. Look up the saml user login
  2. Look up any local users with the same login as the saml login
  3. If a local user is found, see if linking by name is allowed
  4. If linking by name is configured, allow login to proceed
  5. If linking by name is not configured throw an exception with user message "A local user account with your login name already exists, and we are disallowed from linking it"
  6. If no account was found by login, perform the same checks as above but by email

The problem is that if you are linking by email and not by name, a legitimate saml user who has both a matching name and email to a local user will not be able to log in. They'll be found by the login lookup, and because login linking is off, they'll be denied access. However, they really should be allowed access because their email does match.

Steps to reproduce

Create a local user:
login: test
email: test@example.com

Configure samlauth module with:
Enable matching on name - off
Enable matching on email - on

Attempt to log in as test user via saml - the link exception will be thrown

Proposed resolution

If a user account is found by name, and linking by name is off, do not immediately throw an exception. Rather, check if linking by email is enabled, the saml user has an email and the email matches the local user email. Only if all of those test fail throw the exception.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

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

Comments & Activities

Production build 0.69.0 2024