Inherits ExternalUser.
Public Member Functions | |
getId () | |
This must return some identifier that stably, uniquely identifies the user. | |
getName () | |
This must return the name that the user would normally use for login to the external database. | |
authenticate ($password) | |
Is the given password valid for the external user? The password is provided in plaintext. | |
getPref ($pref) | |
Retrieve the value corresponding to the given preference key. | |
getGroups () | |
Return an array of identifiers for all the foreign groups that this user has. | |
Protected Member Functions | |
initFromName ($name) | |
Given a name, which is a string exactly as input by the user in the login form but with whitespace stripped, initialize this object to be the corresponding ExternalUser. | |
initFromId ($id) | |
Given an id, which was at some previous point in history returned by getId(), initialize this object to be the corresponding ExternalUser. | |
Private Member Functions | |
initFromCond ($cond) | |
Private Attributes | |
$mRow | |
$mDb |
Example configuration:
$wgExternalAuthType = 'ExternalUser_MediaWiki'; $wgExternalAuthConf = array( 'DBtype' => 'mysql', 'DBserver' => 'localhost', 'DBname' => 'wikidb', 'DBuser' => 'quasit', 'DBpassword' => 'a5Cr:yf9u-6[{`g', 'DBprefix' => '', );
All fields must be present. These mean the same things as $wgDBtype, $wgDBserver, etc. This implementation is quite crude; it could easily support multiple database servers, for instance, and memcached, and it probably has bugs. Kind of hard to reuse code when things might rely on who knows what configuration globals.
If either wiki uses the UserComparePasswords hook, password authentication might fail unexpectedly unless they both do the exact same validation. There may be other corner cases like this where this will fail, but it should be unlikely.
Definition at line 47 of file MediaWiki.php.
ExternalUser_MediaWiki::authenticate | ( | $ | password | ) |
Is the given password valid for the external user? The password is provided in plaintext.
$password | string |
Reimplemented from ExternalUser.
Definition at line 108 of file MediaWiki.php.
References User::comparePasswords().
ExternalUser_MediaWiki::getGroups | ( | ) |
Return an array of identifiers for all the foreign groups that this user has.
The identifiers are opaque objects that only need to be specifiable by the administrator in LocalSettings.php when configuring $wgAutopromote. They may be, for instance, strings or integers.
TODO: Support this in $wgAutopromote.
Reimplemented from ExternalUser.
Definition at line 125 of file MediaWiki.php.
References $res.
ExternalUser_MediaWiki::getId | ( | ) |
This must return some identifier that stably, uniquely identifies the user.
In a typical web application, this could be an integer representing the "user id". In other cases, it might be a string. In any event, the return value should be a string between 1 and 255 characters in length; must uniquely identify the user in the foreign database; and, if at all possible, should be permanent.
This will only ever be used to reconstruct this ExternalUser object via newFromId(). The resulting object in that case should correspond to the same user, even if details have changed in the interim (e.g., renames or preference changes).
Reimplemented from ExternalUser.
Definition at line 100 of file MediaWiki.php.
ExternalUser_MediaWiki::getName | ( | ) |
This must return the name that the user would normally use for login to the external database.
It is subject to no particular restrictions beyond rudimentary sanity, and in particular may be invalid as a MediaWiki username. It's used to auto-generate an account name that *is* valid for MediaWiki, either with or without user input, but basically is only a hint.
Reimplemented from ExternalUser.
Definition at line 104 of file MediaWiki.php.
ExternalUser_MediaWiki::getPref | ( | $ | pref | ) |
Retrieve the value corresponding to the given preference key.
The most important values are:
The value must meet MediaWiki's requirements for values of this type, and will be checked for validity before use. If the preference makes no sense for the backend, or it makes sense but is unset for this user, or is unrecognized, return null.
$pref will never equal 'password', since passwords are usually hashed and cannot be directly retrieved. authenticate() is used for this instead.
TODO: Currently this is only called for 'emailaddress'; generalize! Add some config option to decide which values are grabbed on user initialization.
$pref | string |
Reimplemented from ExternalUser.
Definition at line 115 of file MediaWiki.php.
ExternalUser_MediaWiki::initFromCond | ( | $ | cond | ) | [private] |
ExternalUser_MediaWiki::initFromId | ( | $ | id | ) | [protected] |
Given an id, which was at some previous point in history returned by getId(), initialize this object to be the corresponding ExternalUser.
Return true if successful, false otherwise.
$id | string |
Reimplemented from ExternalUser.
Definition at line 63 of file MediaWiki.php.
References initFromCond().
ExternalUser_MediaWiki::initFromName | ( | $ | name | ) | [protected] |
Given a name, which is a string exactly as input by the user in the login form but with whitespace stripped, initialize this object to be the corresponding ExternalUser.
Return true if successful, otherwise false.
$name | string |
Reimplemented from ExternalUser.
Definition at line 50 of file MediaWiki.php.
References $name, User::getCanonicalName(), and initFromCond().
ExternalUser_MediaWiki::$mDb [private] |
Definition at line 48 of file MediaWiki.php.
ExternalUser_MediaWiki::$mRow [private] |
Definition at line 48 of file MediaWiki.php.