I created the following auth plugin.
- Code: Select all
class MyAuthPlugin extends AuthPlugin {
function register($category, $path) {
$success = parent::register($category, $path);
$this->addLocaleData();
return $success;
}
function getName() {
return 'MyPlugin';
}
function getDisplayName() {
return 'My Authentication Plugin';
}
function getDescription() {
return 'Plugin for authenticating users registered in the My database';
}
//
// Core Plugin Functions
// (Must be implemented by every authentication plugin)
//
function &getInstance($settings, $authId) {
$returner =& new MyAuthPlugin($settings, $authId);
error_log("Gave instance", 3, "err_My.log");
return $returner;
}
function authenticate($username, $password) {
$valid = false;
//TODO:
error_log("I am called for auth", 3, "err_My.log");
//return $valid;
return true;
}
}
This plugin appears in the "Authentication Sources" section and I added and configured it as the default. But the log messages do not appear in the log file that suggest that the hook methods get called. Also, the default return of "true" in the authenticate method should allow any user to proceed, but this doesn't happen.
I looked at the code in the "Validate" class and what I understood from it is that users in the external source should also be registered in the local DB with an AuthID indicating what auth source to use. Is this true?
Also, what is the default role assigned to a user from a custom source. Can I map other roles to such a user?
- Nirav Mehta
