MediaWiki
master
|
Utility class for bot passwords. More...
Public Member Functions | |
__construct ( $row, $isSaved, $flags=self::READ_NORMAL) | |
delete () | |
Delete the BotPassword from the database. More... | |
getAppId () | |
getGrants () | |
getRestrictions () | |
getToken () | |
getUserCentralId () | |
Get the central user ID. More... | |
isInvalid () | |
Whether the password is currently invalid. More... | |
isSaved () | |
Indicate whether this is known to be saved. More... | |
save ( $operation, Password $password=null) | |
Save the BotPassword to the database. More... | |
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". More... | |
static | generatePassword ( $config) |
Returns a (raw, unhashed) random password string. More... | |
static | getDB ( $db) |
Get a database connection for the bot passwords database. More... | |
static | getSeparator () |
Get the separator for combined user name + app ID. More... | |
static | invalidateAllPasswordsForCentralId ( $centralId) |
Invalidate all passwords for a user, by central ID. More... | |
static | invalidateAllPasswordsForUser ( $username) |
Invalidate all passwords for a user, by name. More... | |
static | login ( $username, $password, WebRequest $request) |
Try to log the user in. More... | |
static | newFromCentralId ( $centralId, $appId, $flags=self::READ_NORMAL) |
Load a BotPassword from the database. More... | |
static | newFromUser (UserIdentity $userIdentity, $appId, $flags=self::READ_NORMAL) |
Load a BotPassword from the database. More... | |
static | newUnsaved (array $data, $flags=self::READ_NORMAL) |
Create an unsaved BotPassword. More... | |
static | removeAllPasswordsForCentralId ( $centralId) |
Remove all passwords for a user, by central ID. More... | |
static | removeAllPasswordsForUser ( $username) |
Remove all passwords for a user, by name. More... | |
Public Attributes | |
const | APPID_MAXLENGTH = 32 |
const | GRANTS_MAXLENGTH = 65535 |
Maximum length of the json representation of grants. More... | |
const | PASSWORD_MINLENGTH = 32 |
Minimum length for a bot password. More... | |
const | RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions. More... | |
![]() | |
const | READ_NONE = -1 |
Constants for object loading bitfield flags (higher => higher QoS) More... | |
BotPassword::__construct | ( | $row, | |
$isSaved, | |||
$flags = self::READ_NORMAL |
|||
) |
stdClass | $row | bot_passwords database row |
bool | $isSaved | Whether the bot password was read from the database |
int | $flags | IDBAccessObject read flags |
Definition at line 84 of file BotPassword.php.
References FormatJson\decode(), 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 382 of file BotPassword.php.
References getSeparator().
Referenced by ApiLogin\execute().
BotPassword::delete | ( | ) |
Delete the BotPassword from the database.
Definition at line 276 of file BotPassword.php.
References isSaved().
|
static |
Returns a (raw, unhashed) random password string.
Config | $config |
Definition at line 368 of file BotPassword.php.
References PasswordFactory\generateRandomPasswordString().
Referenced by CreateBotPassword\execute().
BotPassword::getAppId | ( | ) |
Definition at line 169 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_PRIMARY or DB_REPLICA. |
Definition at line 100 of file BotPassword.php.
Referenced by MediaWiki\Specials\SpecialBotPasswords\getFormFields(), invalidateAllPasswordsForCentralId(), and removeAllPasswordsForCentralId().
BotPassword::getGrants | ( | ) |
Definition at line 190 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
BotPassword::getRestrictions | ( | ) |
Definition at line 183 of file BotPassword.php.
|
static |
Get the separator for combined user name + app ID.
Definition at line 198 of file BotPassword.php.
Referenced by canonicalizeLoginData(), MediaWiki\Specials\SpecialBotPasswords\getFormFields(), login(), and MediaWiki\Specials\SpecialBotPasswords\onSuccess().
BotPassword::getToken | ( | ) |
Definition at line 176 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
BotPassword::getUserCentralId | ( | ) |
Get the central user ID.
Definition at line 162 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 306 of file BotPassword.php.
References DB_PRIMARY, getDB(), PasswordFactory\newInvalidPassword(), and wfDeprecated().
|
static |
Invalidate all passwords for a user, by name.
string | $username |
Definition at line 292 of file BotPassword.php.
Referenced by InvalidateBotPasswords\execute().
BotPassword::isInvalid | ( | ) |
Whether the password is currently invalid.
Definition at line 234 of file BotPassword.php.
BotPassword::isSaved | ( | ) |
Indicate whether this is known to be saved.
Definition at line 154 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 408 of file BotPassword.php.
References WebRequest\getIP(), ObjectCache\getLocalClusterInstance(), getSeparator(), StatusValue\newFatal(), User\newFromName(), newFromUser(), StatusValue\newGood(), and wfMessage().
Referenced by ApiLogin\execute().
|
static |
Load a BotPassword from the database.
int | $centralId | from CentralIdLookup |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 126 of file BotPassword.php.
Referenced by MediaWiki\Specials\SpecialBotPasswords\getFormFields(), MediaWiki\Specials\SpecialBotPasswords\onSubmit(), and MediaWiki\Session\BotPasswordSessionProvider\refreshSessionInfo().
|
static |
Load a BotPassword from the database.
UserIdentity | $userIdentity | |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 113 of file BotPassword.php.
Referenced by login().
|
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 144 of file BotPassword.php.
Referenced by CreateBotPassword\execute(), and MediaWiki\Specials\SpecialBotPasswords\getFormFields().
|
static |
Remove all passwords for a user, by central ID.
int | $centralId |
Definition at line 345 of file BotPassword.php.
References DB_PRIMARY, getDB(), and wfDeprecated().
|
static |
Remove all passwords for a user, by name.
string | $username |
Definition at line 331 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 245 of file BotPassword.php.
References isSaved(), StatusValue\newGood(), and Status\wrap().
const BotPassword::APPID_MAXLENGTH = 32 |
Definition at line 37 of file BotPassword.php.
Referenced by MediaWiki\Specials\SpecialBotPasswords\execute(), and MediaWiki\Specials\SpecialBotPasswords\getFormFields().
const BotPassword::GRANTS_MAXLENGTH = 65535 |
Maximum length of the json representation of grants.
Definition at line 54 of file BotPassword.php.
const BotPassword::PASSWORD_MINLENGTH = 32 |
Minimum length for a bot password.
Definition at line 42 of file BotPassword.php.
Referenced by CreateBotPassword\execute().
const BotPassword::RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions.
Definition at line 48 of file BotPassword.php.