What works:
External authentication for new users.
What does not work:
External authentication for existing users. The $user global variable never gets set in the event a valid user is returned through user_load.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | fix-external-auth.patch | 468 bytes | bdrieu |
| #2 | 283026-auth-without-server-part.patch | 2.54 KB | damien tournoud |
Comments
Comment #1
damien tournoud commentedWhich authentication module are you referring to?
Comment #2
damien tournoud commentedThe issue is that user_authenticate does not allow to build an authentication module where user has no server part since #165642: error in SQL syntax in user.module on line 368 (or 378) came in.
After discussion with the security team, we came to the conclusion that we could very well manage that.
Here is a patch against 5.x-dev. Later versions are not affected.
Comment #3
damien tournoud commented#283698: External user authentication broke in 5.8 update was a duplicate.
Also, please note that authentication modules that does not use a "server part" (users in the form name@server) will have to rebuild manually the authmap table for users they manage.
Comment #4
damien tournoud commented#283804: Login with external authentication was another duplicate.
Comment #5
vangorra commentedI'm referring to the user module and the user_authenticate function. This is what I did as a work around until the core source is updated.
$registered_user = user_load(array('name' => $name));
if (!$registered_user->uid) { // Register this new user.
$userinfo = array(
'name' => $name,
'pass' => user_password(),
'init' => $name,
'status' => 1,
'access' => time(),
);
if ($server) {
$userinfo["authname_$module"] = $name;
}
$user = user_save('', $userinfo);
watchdog('user', t('New external user: %user using module %module.', array('%user' => $name, '%module' => $module)), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
break;
} else {
$user = $registered_user;
break;
}
Comment #6
damien tournoud commented#286642: Error processing external authentication sources was a new duplicate.
Comment #7
damien tournoud commented@vangorra: the behavior of the
user_authenticate()in Drupal 5.8/5.9 is the good one (user_authenticate should *not* authenticate local users that are not in the authentication map).Which authentication module are you trying to use?
Comment #8
vangorra commentedI'm using my own authentication module. I wrote it against the Drupal < 5.8 API. The scenario that is troublesome is an external user changes their password on the external source. How the function is written now, Drupal will return an authentication failure even though my auth module returns success. Non-existing external users, however will be registered correctly.
Comment #9
bdrieu commentedI have the same problem.
I created a authentification module for Drupal, which worked fine until drupal 5.8. I made this patch (about the same as vangorra's).
@Damien: if using foo_auth to authenticate local users not in the authentication map has been made obsolete, what is the method that supersede that behaviour?
Comment #10
Anonymous (not verified) commentedbookmark
Comment #11
scb commentedI have the same problem, with a module implementing hook_auth.
New users are authenticated ok and created in the users table, but when you try to login again with the same user, it doesn't authenticate, even hook_auth returns true.
Applying the patch in #9 seems to solve the issue, but throws some warnings... I'll take a look at it to give more info.
Comment #12
cridenour commentedBefore patch, subsequent logins were not working.
After patch, they are. No effect to initial login.
Please commit :)
EDIT: This was referring to Damien's original patch.
Comment #13
janusman commentedThe patch from #2 worked for me when applied to D5-10 --- **BUT** first I had to create entries in the authmap table for every existing user that was created from external authentication.
New users (authenticated externally) are now being created as they should, along with their authmap table entry.
If you have existing users that were created with both internal and external authentication, you might have decide which one goes in the authmap table manually... =(
Comment #14
cridenour commentedYes, so the sooner this patch gets out there, the less work it will be ;)
Comment #15
bigheadfish commentedI have the same problem:
http://drupal.org/node/305568
Comment #16
drummCommitted to 5.x.
Comment #17
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.