MediaWiki REL1_35
|
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 | PASSWORD_MINLENGTH = 32 |
Minimum length for a bot password. | |
const | RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions. | |
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 77 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 463 of file BotPassword.php.
BotPassword::delete | ( | ) |
Delete the BotPassword from the database.
Definition at line 362 of file BotPassword.php.
|
static |
Returns a (raw, unhashed) random password string.
Config | $config |
Definition at line 449 of file BotPassword.php.
BotPassword::getAppId | ( | ) |
Get the app ID.
Definition at line 216 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 93 of file BotPassword.php.
References $wgBotPasswordsCluster, and $wgBotPasswordsDatabase.
BotPassword::getGrants | ( | ) |
Get the grants.
Definition at line 240 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
protected |
Get the password.
Definition at line 257 of file BotPassword.php.
References getDB().
Referenced by isInvalid().
BotPassword::getRestrictions | ( | ) |
|
static |
Get the separator for combined user name + app ID.
Definition at line 248 of file BotPassword.php.
References $wgUserrightsInterwikiDelimiter.
BotPassword::getToken | ( | ) |
Get the token.
Definition at line 224 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
BotPassword::getUserCentralId | ( | ) |
Get the central user ID.
Definition at line 208 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 394 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 382 of file BotPassword.php.
BotPassword::isInvalid | ( | ) |
Whether the password is currently invalid.
Definition at line 284 of file BotPassword.php.
References getPassword().
BotPassword::isSaved | ( | ) |
Indicate whether this is known to be saved.
Definition at line 200 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 $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 575 of file BotPassword.php.
References 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 124 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 110 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 155 of file BotPassword.php.
References MWRestrictions\newDefault().
|
static |
Remove all passwords for a user, by central ID.
int | $centralId |
Definition at line 428 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 416 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\preventSessionsForUser().
BotPassword::save | ( | $operation, | |
Password | $password = null |
||
) |
Save the BotPassword to the database.
UnexpectedValueException |
Definition at line 295 of file BotPassword.php.
References $res, DB_MASTER, MWCryptRand\generateHex(), getDB(), isSaved(), MWRestrictions\toJson(), and User\TOKEN_LENGTH.
|
private |
Definition at line 58 of file BotPassword.php.
|
private |
Definition at line 55 of file BotPassword.php.
|
private |
Definition at line 70 of file BotPassword.php.
|
private |
Definition at line 67 of file BotPassword.php.
|
private |
Definition at line 52 of file BotPassword.php.
|
private |
Definition at line 64 of file BotPassword.php.
|
private |
Definition at line 61 of file BotPassword.php.
const BotPassword::APPID_MAXLENGTH = 32 |
Definition at line 32 of file BotPassword.php.
const BotPassword::GRANTS_MAXLENGTH = 65535 |
Maximum length of the json representation of grants.
Definition at line 49 of file BotPassword.php.
const BotPassword::PASSWORD_MINLENGTH = 32 |
Minimum length for a bot password.
Definition at line 37 of file BotPassword.php.
const BotPassword::RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions.
Definition at line 43 of file BotPassword.php.