MediaWiki  REL1_19
ExternalUser_Hardcoded Class Reference

This class supports external authentication from a literal array dumped in LocalSettings.php. More...

Inheritance diagram for ExternalUser_Hardcoded:
Collaboration diagram for ExternalUser_Hardcoded:

List of all members.

Public Member Functions

 authenticate ($password)
 Is the given password valid for the external user? The password is provided in plaintext.
 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.
 getPref ($pref)
 Retrieve the value corresponding to the given preference key.

Protected Member Functions

 initFromId ($id)
 Given an id, which was at some previous point in history returned by getId(), initialize this object to be the corresponding ExternalUser.
 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.

Private Attributes

 $mName

Detailed Description

This class supports external authentication from a literal array dumped in LocalSettings.php.

It's mostly useful for testing. Example configuration:

$wgExternalAuthType = 'ExternalUser_Hardcoded'; $wgExternalAuthConf = array( 'Bob Smith' => array( 'password' => 'literal string', 'emailaddress' => '[email protected]', ), );

Multiple names may be provided. The keys of the inner arrays can be either 'password', or the name of any preference.

Definition at line 42 of file Hardcoded.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 67 of file Hardcoded.php.

References $wgExternalAuthConf.

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 59 of file Hardcoded.php.

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.

Returns:
string

Reimplemented from ExternalUser.

Definition at line 63 of file Hardcoded.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 74 of file Hardcoded.php.

References $wgExternalAuthConf.

ExternalUser_Hardcoded::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.

Parameters:
$idstring
Returns:
bool Success?

Reimplemented from ExternalUser.

Definition at line 55 of file Hardcoded.php.

References initFromName().

Here is the call graph for this function:

ExternalUser_Hardcoded::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.

Parameters:
$namestring
Returns:
bool Success?

Reimplemented from ExternalUser.

Definition at line 45 of file Hardcoded.php.

References $wgExternalAuthConf.

Referenced by initFromId().

Here is the caller graph for this function:


Member Data Documentation

ExternalUser_Hardcoded::$mName [private]

Definition at line 43 of file Hardcoded.php.


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