MediaWiki  REL1_19
ExternalUser_MediaWiki Class Reference

This class supports authentication against an external MediaWiki database, probably any version back to 1.5 or something. More...

Inheritance diagram for ExternalUser_MediaWiki:
Collaboration diagram for ExternalUser_MediaWiki:

List of all members.

Public Member Functions

 authenticate ($password)
 Is the given password valid for the external user? The password is provided in plaintext.
 getGroups ()
 getId ()
 This must return some identifier that stably, uniquely identifies the user.
 getName ()
 getPref ($pref)
 Retrieve the value corresponding to the given preference key.

Protected Member Functions

 initFromId ($id)
 initFromName ($name)

Private Member Functions

 initFromCond ($cond)

Private Attributes

 $mDb
 $mRow

Detailed Description

This class supports authentication against an external MediaWiki database, probably any version back to 1.5 or something.

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 52 of file MediaWiki.php.


Member Function Documentation

Is the given password valid for the external user? The password is provided in plaintext.

Parameters:
$passwordstring
Returns:
bool

Reimplemented from ExternalUser.

Definition at line 132 of file MediaWiki.php.

References User\comparePasswords().

Here is the call graph for this function:

Returns:
array

Reimplemented from ExternalUser.

Definition at line 152 of file MediaWiki.php.

References $res.

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).

Returns:
string

Reimplemented from ExternalUser.

Definition at line 121 of file MediaWiki.php.

Returns:
string

Reimplemented from ExternalUser.

Definition at line 128 of file MediaWiki.php.

Retrieve the value corresponding to the given preference key.

The most important values are:

  • emailaddress
  • language

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.

Parameters:
$prefstring
Returns:
mixed

Reimplemented from ExternalUser.

Definition at line 139 of file MediaWiki.php.

ExternalUser_MediaWiki::initFromCond ( cond) [private]
Parameters:
$condarray
Returns:
bool

Definition at line 89 of file MediaWiki.php.

References $wgExternalAuthConf, and DatabaseBase\factory().

Referenced by initFromId(), and initFromName().

Here is the call graph for this function:

Here is the caller graph for this function:

ExternalUser_MediaWiki::initFromId ( id) [protected]
Parameters:
$idint
Returns:
bool

Reimplemented from ExternalUser.

Definition at line 81 of file MediaWiki.php.

References initFromCond().

Here is the call graph for this function:

ExternalUser_MediaWiki::initFromName ( name) [protected]
Parameters:
$namestring
Returns:
bool

Reimplemented from ExternalUser.

Definition at line 64 of file MediaWiki.php.

References User\getCanonicalName(), and initFromCond().

Here is the call graph for this function:


Member Data Documentation

ExternalUser_MediaWiki::$mDb [private]

Definition at line 58 of file MediaWiki.php.

ExternalUser_MediaWiki::$mRow [private]

Definition at line 53 of file MediaWiki.php.


The documentation for this class was generated from the following file: