MediaWiki REL1_34
|
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 |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = self::READ_LATEST | 2 |
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. | |
Static Private Member Functions | |
static | loginHook ( $user, $bp, Status $status) |
Call AuthManagerLoginAuthenticateAudit. | |
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 60 of file BotPassword.php.
References 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]. If this cannot be a bot password login just return false.
string | $username | |
string | $password |
Definition at line 420 of file BotPassword.php.
BotPassword::delete | ( | ) |
Delete the BotPassword from the database.
Definition at line 319 of file BotPassword.php.
|
static |
Returns a (raw, unhashed) random password string.
Config | $config |
Definition at line 406 of file BotPassword.php.
BotPassword::getAppId | ( | ) |
Get the app ID.
Definition at line 199 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 76 of file BotPassword.php.
References $wgBotPasswordsCluster, and $wgBotPasswordsDatabase.
BotPassword::getGrants | ( | ) |
Get the grants.
Definition at line 223 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
protected |
Get the password.
Definition at line 240 of file BotPassword.php.
References getDB().
Referenced by isInvalid().
BotPassword::getRestrictions | ( | ) |
|
static |
Get the separator for combined user name + app ID.
Definition at line 231 of file BotPassword.php.
References $wgUserrightsInterwikiDelimiter.
BotPassword::getToken | ( | ) |
Get the token.
Definition at line 207 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
BotPassword::getUserCentralId | ( | ) |
Get the central user ID.
Definition at line 191 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 351 of file BotPassword.php.
References $wgEnableBotPasswords, DB_MASTER, and getDB().
|
static |
Invalidate all passwords for a user, by name.
string | $username | User name |
Definition at line 339 of file BotPassword.php.
BotPassword::isInvalid | ( | ) |
Whether the password is currently invalid.
Definition at line 267 of file BotPassword.php.
References getPassword().
BotPassword::isSaved | ( | ) |
Indicate whether this is known to be saved.
Definition at line 183 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 446 of file BotPassword.php.
References $wgEnableBotPasswords, $wgPasswordAttemptThrottle, WebRequest\getIP(), User\newFromName(), and wfMessage().
|
staticprivate |
Call AuthManagerLoginAuthenticateAudit.
To facilitate logging all authentications, even ones not via AuthManager, call the AuthManagerLoginAuthenticateAudit hook.
User | string | $user | User being logged in |
BotPassword | null | $bp | Bot sub-account, if it can be identified |
Status | $status | Login status |
Definition at line 532 of file BotPassword.php.
References $response, Status\getMessage(), and StatusValue\isGood().
|
static |
Load a BotPassword from the database.
int | $centralId | from CentralIdLookup |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 107 of file BotPassword.php.
References $wgEnableBotPasswords, and getDB().
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 93 of file BotPassword.php.
|
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 138 of file BotPassword.php.
References MWRestrictions\newDefault().
|
static |
Remove all passwords for a user, by central ID.
int | $centralId |
Definition at line 385 of file BotPassword.php.
References $wgEnableBotPasswords, DB_MASTER, and getDB().
|
static |
Remove all passwords for a user, by name.
string | $username | User name |
Definition at line 373 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\preventSessionsForUser().
BotPassword::save | ( | $operation, | |
Password | $password = null |
||
) |
Save the BotPassword to the database.
Definition at line 277 of file BotPassword.php.
References DB_MASTER, MWCryptRand\generateHex(), getDB(), isSaved(), and User\TOKEN_LENGTH.
|
private |
Definition at line 41 of file BotPassword.php.
|
private |
Definition at line 38 of file BotPassword.php.
|
private |
Definition at line 53 of file BotPassword.php.
|
private |
Definition at line 50 of file BotPassword.php.
|
private |
Definition at line 35 of file BotPassword.php.
|
private |
Definition at line 47 of file BotPassword.php.
|
private |
Definition at line 44 of file BotPassword.php.
const BotPassword::APPID_MAXLENGTH = 32 |
Definition at line 32 of file BotPassword.php.