Make it possible to auto-enable SAML logins for existing Drupal users (by adding entries in the

authmap

table) based on the Drupal account's email address. This can be done in addition to the existing functionality that auto-enables SAML for accounts based on username.

This is a one-line change, and would make it much easier to implement sign-on using an email address SAML Attribute. This would be particularly useful in the case of a single sign-on IdP authenticating for several Drupal websites that may have different usernames for the same SAML Principal.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hampercm created an issue. See original summary.

hampercm’s picture

Assigned: hampercm » Unassigned
Status: Active » Needs review
FileSize
800 bytes
hampercm’s picture

Issue summary: View changes
FileSize
731 bytes

My original patch had one of my debugging watchdog() calls contaminating it. Here's a corrected patch.

becw’s picture

I had the same need; I have a bunch of migrated users who I would like to log in by email address. I had a slightly more verbose solution, which makes this configurable, and also works when you enable SAML for individual accounts in Drupal.

pbuyle’s picture

_simplesamlphp_auth_get_authname()

+++ b/simplesamlphp_auth.module
@@ -427,33 +430,108 @@ function _simplesamlphp_auth_isEnabled($show_inactive_msg = FALSE) {
 function _simplesamlphp_auth_get_authname() {
+  $authname = '';
+
+  switch (variable_get('simplesamlphp_authname_source', 'uid')) {
+    case 'mail':
+      $authname = _simplesamlphp_auth_get_mail();
+      break;
+    case 'username':
+      $authname = _simplesamlphp_auth_get_default_name();
+      break;
+    case 'uid':
+    default:
+      $authname = _simplesamlphp_auth_get_authname();
+  }
+
+  return $authname;
+}
+

Infinite loop when simplesamlphp_authname_source is uid. It seems a missing _simplesamlphp_auth_get_unique_id() function should be called instead.

Otherwise, the patch seems to be working fine when matching with the email.

pbuyle’s picture

Status: Needs review » Needs work
jnicola’s picture

Tested the patch above for mapping via email. Works for me! Did not test UID infinite loop correlation. Perhaps keeping this to just email or username for now would be best?

roi’s picture

Enabling email is good but not the only field by which we should use SAML. In my site there's a need to retrieve some very specific substring from the SAML auth and look for it on one of the existing user's fields. My patch allows other modules to do that, and it also lets you use email, of course.

sherakama’s picture

I like roi's approach with the drupal_alter call instead of a switch statement. Roi's approach will make it much more flexible for other modules to hook in and provide their use case specific options.

Maybe we can provide the best of both worlds? Perhaps have username and email lookups by default and then hook out with drupal_alter?

Thanks

sherakama’s picture

I've been doing some of this work here: https://www.drupal.org/node/2745089