MediaWiki REL1_31
|
Utility class for bot passwords. More...
Public Member Functions | |
delete () | |
Delete the BotPassword from the database. | |
getAppId () | |
Get the app ID. | |
getGrants () | |
Get the grants. | |
getRestrictions () | |
Get the restrictions. | |
getToken () | |
Get the token. | |
getUserCentralId () | |
Get the central user ID. | |
isInvalid () | |
Whether the password is currently invalid. | |
isSaved () | |
Indicate whether this is known to be saved. | |
save ( $operation, Password $password=null) | |
Save the BotPassword to the database. | |
Static Public Member Functions | |
static | canonicalizeLoginData ( $username, $password) |
There are two ways to login with a bot password: "username@appId", "password" and "username", "appId@password". | |
static | generatePassword ( $config) |
Returns a (raw, unhashed) random password string. | |
static | getDB ( $db) |
Get a database connection for the bot passwords database. | |
static | getSeparator () |
Get the separator for combined user name + app ID. | |
static | invalidateAllPasswordsForCentralId ( $centralId) |
Invalidate all passwords for a user, by central ID. | |
static | invalidateAllPasswordsForUser ( $username) |
Invalidate all passwords for a user, by name. | |
static | login ( $username, $password, WebRequest $request) |
Try to log the user in. | |
static | newFromCentralId ( $centralId, $appId, $flags=self::READ_NORMAL) |
Load a BotPassword from the database. | |
static | newFromUser (User $user, $appId, $flags=self::READ_NORMAL) |
Load a BotPassword from the database. | |
static | newUnsaved (array $data, $flags=self::READ_NORMAL) |
Create an unsaved BotPassword. | |
static | removeAllPasswordsForCentralId ( $centralId) |
Remove all passwords for a user, by central ID. | |
static | removeAllPasswordsForUser ( $username) |
Remove all passwords for a user, by name. | |
Public Attributes | |
const | APPID_MAXLENGTH = 32 |
const | GRANTS_MAXLENGTH = 65535 |
Maximum length of the json representation of grants. | |
const | RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions. | |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = 3 |
Constants for object loading bitfield flags (higher => higher QoS) | |
const | READ_NONE = -1 |
Protected Member Functions | |
__construct ( $row, $isSaved, $flags=self::READ_NORMAL) | |
getPassword () | |
Get the password. | |
Private Attributes | |
string | $appId |
int | $centralId |
int | $flags = self::READ_NORMAL |
string[] | $grants |
bool | $isSaved |
MWRestrictions | $restrictions |
string | $token |
|
protected |
object | $row | bot_passwords database row |
bool | $isSaved | Whether the bot password was read from the database |
int | $flags | IDBAccessObject read flags |
Definition at line 71 of file BotPassword.php.
References flags, isSaved(), and MWRestrictions\newFromJson().
|
static |
There are two ways to login with a bot password: "username@appId", "password" and "username", "appId@password".
Transform it so it is always in the first form. Returns [bot username, bot password, could be normal password?] where the last one is a flag meaning this could either be a bot password or a normal password, it cannot be decided for certain (although in such cases it almost always will be a bot password). If this cannot be a bot password login just return false.
string | $username | |
string | $password |
Definition at line 463 of file BotPassword.php.
BotPassword::delete | ( | ) |
Delete the BotPassword from the database.
Definition at line 360 of file BotPassword.php.
|
static |
Returns a (raw, unhashed) random password string.
Config | $config |
Definition at line 447 of file BotPassword.php.
BotPassword::getAppId | ( | ) |
Get the app ID.
Definition at line 212 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
static |
Get a database connection for the bot passwords database.
int | $db | Index of the connection to get, e.g. DB_MASTER or DB_REPLICA. |
Definition at line 87 of file BotPassword.php.
References $wgBotPasswordsCluster, $wgBotPasswordsDatabase, and global.
BotPassword::getGrants | ( | ) |
Get the grants.
Definition at line 236 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
protected |
Get the password.
Definition at line 253 of file BotPassword.php.
References $options, flags, RequestContext\getMain(), and list.
Referenced by isInvalid().
BotPassword::getRestrictions | ( | ) |
|
static |
Get the separator for combined user name + app ID.
Definition at line 244 of file BotPassword.php.
References $wgUserrightsInterwikiDelimiter, and global.
BotPassword::getToken | ( | ) |
Get the token.
Definition at line 220 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
BotPassword::getUserCentralId | ( | ) |
Get the central user ID.
Definition at line 204 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
static |
Invalidate all passwords for a user, by central ID.
int | $centralId |
Definition at line 392 of file BotPassword.php.
References $wgEnableBotPasswords, DB_MASTER, and global.
|
static |
Invalidate all passwords for a user, by name.
string | $username | User name |
Definition at line 380 of file BotPassword.php.
References $username.
BotPassword::isInvalid | ( | ) |
Whether the password is currently invalid.
Definition at line 281 of file BotPassword.php.
References getPassword().
BotPassword::isSaved | ( | ) |
Indicate whether this is known to be saved.
Definition at line 196 of file BotPassword.php.
Referenced by __construct(), delete(), and save().
|
static |
Try to log the user in.
string | $username | Combined user name and app ID |
string | $password | Supplied password |
WebRequest | $request |
Definition at line 489 of file BotPassword.php.
References $name, $request, $user, $username, $wgEnableBotPasswords, $wgPasswordAttemptThrottle, global, list, User\newFromName(), and wfMessage().
|
static |
Load a BotPassword from the database.
int | $centralId | from CentralIdLookup |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 118 of file BotPassword.php.
References $options, $wgEnableBotPasswords, global, and list.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\refreshSessionInfo().
|
static |
Load a BotPassword from the database.
User | $user | |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 104 of file BotPassword.php.
References $user.
|
static |
Create an unsaved BotPassword.
array | $data | Data to use to create the bot password. Keys are:
|
int | $flags | IDBAccessObject read flags |
Definition at line 149 of file BotPassword.php.
References MWRestrictions\newDefault(), and object.
|
static |
Remove all passwords for a user, by central ID.
int | $centralId |
Definition at line 426 of file BotPassword.php.
References $wgEnableBotPasswords, DB_MASTER, and global.
|
static |
Remove all passwords for a user, by name.
string | $username | User name |
Definition at line 414 of file BotPassword.php.
References $username.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\preventSessionsForUser().
BotPassword::save | ( | $operation, | |
Password | $password = null |
||
) |
Save the BotPassword to the database.
UnexpectedValueException |
Definition at line 292 of file BotPassword.php.
References $res, DB_MASTER, MWCryptRand\generateHex(), isSaved(), MWRestrictions\toJson(), and User\TOKEN_LENGTH.
|
private |
Definition at line 52 of file BotPassword.php.
|
private |
Definition at line 49 of file BotPassword.php.
|
private |
Definition at line 64 of file BotPassword.php.
|
private |
Definition at line 61 of file BotPassword.php.
|
private |
Definition at line 46 of file BotPassword.php.
|
private |
Definition at line 58 of file BotPassword.php.
|
private |
Definition at line 55 of file BotPassword.php.
const BotPassword::APPID_MAXLENGTH = 32 |
Definition at line 31 of file BotPassword.php.
const BotPassword::GRANTS_MAXLENGTH = 65535 |
Maximum length of the json representation of grants.
Definition at line 43 of file BotPassword.php.
const BotPassword::RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions.
Definition at line 37 of file BotPassword.php.