Forums | Mahara Community
Support
/
auth_remote_user table not updating properly?
16 January 2014, 8:19
What causes new user entries to be added to the auth_remote_user table?
I had this Moodle pluign created last year that allows you to submit mahara pages to a moodle assignment (https://moodle.org/plugins/browse.php?list=set&id=38) and ran into an issue where some users weren't able to see their mahara pages within the assignment. I figured out it's caused when that user is not listed within the auth_remote_user table.
Of course I could run a manual sql query to add all of the mahara users to this table, but why is everyone not in there to begin with? What causes you to get added to this table?
Thanks,
Tony
16 January 2014, 12:25
Okay, so I discovered that new entries ARE being added... if they have never SSO'd into Mahara before (from moodle).
The problem lies with the people who existed in Mahara previous to me adding the SSO from Moodle -> Mahara. If a user already existed in Mahara previous to this, and you SSO to Mahara (using mnet/XMLRPC), it does not add you to the auth_remote_user table. I have no idea why--I would think that if you don't exist in auth_remote_user and you SSO, it should add you. Maybe this is a bug?
Anyway, I ran this simple query to add users into the auth_remote_user table who were not already there:
INSERT IGNORE INTO auth_remote_user (authinstance,remoteusername,localusr)
SELECT authinstance,username,id
FROM usr
WHERE usr.authinstance != 1
16 January 2014, 12:45
Hi Tony,
Sounds like you've got it sorted. The auth_remote_user table is where we store the "Username for external authentication" field, which is used by the XMLRPC plugin to store the user's Moodle username. When the user roams across from Moodle to Mahara, we look up their Moodle username in auth_remote_user to determine which Mahara user account it should log them in as. This allows for setups where the users have different usernames in the two systems.
It should be filled in (by default with their Mahara username) when you switch a user to the XMLRPC authentication method. So if it didn't get filled in when you switched the users over to XMLRPC, then that may indeed be a bug in the system.
What method did you use to change the users to the XMLRPC auth method when you set it up?
Cheers,
Aaron
16 January 2014, 14:10
Aaron,
Thanks for the help as always.
What I did was a manually switch the users within the database, due to the large number of accounts and no way to do it via a batch process (that I know of). That must be why they never got added to the auth_remote_user table.
It doesn't appear there is any check when you log in via XMLRPC to see if your account is in the auth_remote_user table. We do have the $cfg->usersuniquebyusername = true; in config.php because we only authenticate from one system. Because that's set to true, is that why we never had an issue with logins, even though users were missing from the auth_remote_user table?
16 January 2014, 15:39
Direct updating in the database would explain why there is no auth_remote_user record. There is a process described in the manual for changing users' auth instance in bulk, but it's not super easy: http://manual.mahara.org/en/1.8/administration/users.html#change-authentication-method.
And you're correct, if you use $cfg->usersuniquebyusername, then basically the auth_remote_user table gets completely ignored by the login process.
It looks like there is a bug here, though. Several of the XMLRPC web services methods, which are used by the Mahara assignment plugin for Moodle, make use of a method called "find_remote_user()". And this method does not honor the $cfg->usersuniquebyusername flag, but instead tries to locate the user by auth_remote_user.
I've filed a bug about it: https://bugs.launchpad.net/mahara/+bug/1269665
Cheers,
Aaron