pitbulk/moodle_saml — pull request #9 by janmeier (2014-07-02 12:12:45+00:00)
Title: Added the ability to sync users through another auth module

These changes are to support the usecase where users are imported into moodle through another auth module, for example DB or LDAP, but must authenticate through SAML.

Currently we are using the other module directly, to create the users from the external source, and then changing `$user->auth` to `'saml'`, to be able to log users in using SAML. However, this means that users are not updated or disabled when information from the external source changes, because the other plugin will only update users who are set to log in with its the auth method of the plugin (for example, DB will only update users where `$user->auth === 'db'` and so on).

This change adds a `sync_users.php` script. The script uses another authentication plugin, selectable by the user, to do the actual import, but sets the auth type of the plugin (`$otherauth->authtype`) to `'saml'`, before synchronizing, so that users can be logged in via SAML. Because the users are created with `$otherauth->authtype` (which is = `'saml'`) in the first place, they will be correctly updated and deleted when synching this way.

Tested with ldap and db.

cc @henrikthorn