-------------------------------------------------------------------------------Authentication API
-----------------AUTHENTICATION PLUGINS
---------------------Each authentication plugin is now contained in a subfolder as a class definition
in the auth.php file. For instance, the LDAP authentication plugin is the class
called auth_plugin_ldap defined in:
/auth/ldap/auth.php
To instantiate the class, there is a function in lib/moodlelib called
get_auth_plugin() that does the work for you:
$ldapauth = get_auth_plugin('ldap');
Auth plugin classes are pretty basic and should be extending auth_plugin_base cl
ass.
They contain the same functions that were previously in each plugin's lib.php fi
le,
but refactored to become class methods, and tweaked to reference the plugin's in
stantiated
config to get at the settings, rather than the global $CFG variable.
When creating new plugins you can either extend the abstract auth_plugin_base cl
ass
(defined in lib/authlib.php) or create a new one and implement all methods from
auth_plugin_base.
The new plugin architecture allows creating of more advanced types such as custo
m SSO
without the need to patch login and logout pages (see *_hook() methods in existi
ng plugins).
Configuration
----------------All auth plugins must have a config property that contains the name value pairs
from the config_plugins table. This is populated using the get_config() function
in the constructor. The settings keys have also had the "auth_" prefix, as well
as the auth plugin name, trimmed. For instance, what used to be
echo $CFG->auth_ldapversion;
is now accessed as
echo $ldapauth->config->version;
Authentication settings have been moved to the config_plugins database table,
with the plugin field set to "auth/foo" (for instance, "auth/ldap").
Method Names
----------------When the functions from lib.php were ported to methods in auth.php, the "auth_"
prefix was dropped. For instance, calls to
auth_user_login($user, $pass);
now become
$ldapauth->user_login($user, $pass);
this also avoids having to worry about which auth/lib file to include since
Moodle takes care of it for you when you create an instance with
get_auth_plugin().
The basic class defines all applicable methods that moodle uses, you can find
more information in lib/authlib.php file.
Upgrading from Moodle 1.7
----------------------------Moodle will upgrade the old auth settings (in $CFG->auth_foobar where foo is the
auth plugin and bar is the setting) to the new style in the config_plugin
database table.