MediaWiki
1.32.5
|
Utility class for bot passwords. More...
Public Member Functions | |
delete () | |
Delete the BotPassword from the database. More... | |
getAppId () | |
Get the app ID. More... | |
getGrants () | |
Get the grants. More... | |
getRestrictions () | |
Get the restrictions. More... | |
getToken () | |
Get the token. More... | |
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 (User $user, $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 |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = self::READ_LATEST | 2 |
Constants for object loading bitfield flags (higher => higher QoS) More... | |
const | READ_NONE = -1 |
Protected Member Functions | |
__construct ( $row, $isSaved, $flags=self::READ_NORMAL) | |
getPassword () | |
Get the password. More... | |
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 59 of file BotPassword.php.
References $flags, $isSaved, 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 419 of file BotPassword.php.
References $appId, $username, and getSeparator().
Referenced by ApiLogin\execute(), and BotPasswordTest\testCanonicalizeLoginData().
BotPassword::delete | ( | ) |
Delete the BotPassword from the database.
Definition at line 318 of file BotPassword.php.
References $appId, $centralId, DB_MASTER, getDB(), and isSaved().
|
static |
Returns a (raw, unhashed) random password string.
Config | $config |
Definition at line 405 of file BotPassword.php.
References PasswordFactory\generateRandomPasswordString().
Referenced by SpecialBotPasswords\save().
BotPassword::getAppId | ( | ) |
Get the app ID.
Definition at line 198 of file BotPassword.php.
References $appId.
Referenced by MediaWiki\Session\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 75 of file BotPassword.php.
References $wgBotPasswordsCluster, and $wgBotPasswordsDatabase.
Referenced by delete(), SpecialBotPasswords\getFormFields(), getPassword(), invalidateAllPasswordsForCentralId(), newFromCentralId(), removeAllPasswordsForCentralId(), and save().
BotPassword::getGrants | ( | ) |
Get the grants.
Definition at line 222 of file BotPassword.php.
References $grants.
Referenced by MediaWiki\Session\Session\BotPasswordSessionProvider\newSessionForRequest().
|
protected |
Get the password.
Definition at line 239 of file BotPassword.php.
References $options, getDB(), DBAccessObjectUtils\getDBOptions(), list, and PasswordFactory\newInvalidPassword().
Referenced by isInvalid().
BotPassword::getRestrictions | ( | ) |
Get the restrictions.
Definition at line 214 of file BotPassword.php.
References $restrictions.
|
static |
Get the separator for combined user name + app ID.
Definition at line 230 of file BotPassword.php.
References $wgUserrightsInterwikiDelimiter.
Referenced by canonicalizeLoginData(), SpecialBotPasswords\getFormFields(), login(), SpecialBotPasswords\onSuccess(), ApiLoginTest\setUpForBotPassword(), and BotPasswordTest\testBasics().
BotPassword::getToken | ( | ) |
Get the token.
Definition at line 206 of file BotPassword.php.
References $token.
Referenced by MediaWiki\Session\Session\BotPasswordSessionProvider\newSessionForRequest().
BotPassword::getUserCentralId | ( | ) |
Get the central user ID.
Definition at line 190 of file BotPassword.php.
References $centralId.
Referenced by MediaWiki\Session\Session\BotPasswordSessionProvider\newSessionForRequest().
|
static |
Invalidate all passwords for a user, by central ID.
int | $centralId |
Definition at line 350 of file BotPassword.php.
References $centralId, $wgEnableBotPasswords, DB_MASTER, getDB(), and PasswordFactory\newInvalidPassword().
Referenced by invalidateAllPasswordsForUser().
|
static |
Invalidate all passwords for a user, by name.
string | $username | User name |
Definition at line 338 of file BotPassword.php.
References $centralId, $username, CentralIdLookup\AUDIENCE_RAW, CentralIdLookup\factory(), and invalidateAllPasswordsForCentralId().
Referenced by MediaWiki\Auth\AuthManager\changeAuthenticationData(), and BotPasswordTest\testInvalidateAllPasswordsForUser().
BotPassword::isInvalid | ( | ) |
Whether the password is currently invalid.
Definition at line 266 of file BotPassword.php.
References getPassword().
BotPassword::isSaved | ( | ) |
Indicate whether this is known to be saved.
Definition at line 182 of file BotPassword.php.
References $isSaved.
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 445 of file BotPassword.php.
References $appId, $name, $request, $user, $username, $wgEnableBotPasswords, $wgPasswordAttemptThrottle, class, ObjectCache\getLocalClusterInstance(), getSeparator(), list, StatusValue\newFatal(), User\newFromName(), newFromUser(), StatusValue\newGood(), MediaWiki\Session\SessionManager\singleton(), and wfMessage().
Referenced by ApiLogin\execute(), and BotPasswordTest\testLogin().
|
static |
Load a BotPassword from the database.
int | $centralId | from CentralIdLookup |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 106 of file BotPassword.php.
References $appId, $centralId, $flags, $options, $wgEnableBotPasswords, getDB(), DBAccessObjectUtils\getDBOptions(), and list.
Referenced by SpecialBotPasswords\getFormFields(), newFromUser(), SpecialBotPasswords\onSubmit(), MediaWiki\Session\Session\BotPasswordSessionProvider\refreshSessionInfo(), BotPasswordTest\testGetPassword(), BotPasswordTest\testInvalidateAllPasswordsForUser(), BotPasswordTest\testRemoveAllPasswordsForUser(), and BotPasswordTest\testSave().
|
static |
Load a BotPassword from the database.
User | $user | |
string | $appId | |
int | $flags | IDBAccessObject read flags |
Definition at line 92 of file BotPassword.php.
References $appId, $centralId, $flags, $user, CentralIdLookup\AUDIENCE_RAW, CentralIdLookup\factory(), and newFromCentralId().
Referenced by login(), BotPasswordTest\testBasics(), MediaWiki\Session\BotPasswordSessionProviderTest\testCheckSessionInfo(), and MediaWiki\Session\BotPasswordSessionProviderTest\testNewSessionInfoForRequest().
|
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 137 of file BotPassword.php.
References $flags, CentralIdLookup\AUDIENCE_RAW, FormatJson\encode(), CentralIdLookup\factory(), MWRestrictions\newDefault(), and object.
Referenced by SpecialBotPasswords\getFormFields(), SpecialBotPasswords\save(), BotPasswordTest\testSave(), and BotPasswordTest\testUnsaved().
|
static |
Remove all passwords for a user, by central ID.
int | $centralId |
Definition at line 384 of file BotPassword.php.
References $centralId, $wgEnableBotPasswords, DB_MASTER, and getDB().
Referenced by removeAllPasswordsForUser().
|
static |
Remove all passwords for a user, by name.
string | $username | User name |
Definition at line 372 of file BotPassword.php.
References $centralId, $username, CentralIdLookup\AUDIENCE_RAW, CentralIdLookup\factory(), and removeAllPasswordsForCentralId().
Referenced by MediaWiki\Session\Session\BotPasswordSessionProvider\preventSessionsForUser(), and BotPasswordTest\testRemoveAllPasswordsForUser().
BotPassword::save | ( | $operation, | |
Password | $password = null |
||
) |
Save the BotPassword to the database.
Definition at line 276 of file BotPassword.php.
References $appId, $centralId, DB_MASTER, FormatJson\encode(), MWCryptRand\generateHex(), getDB(), isSaved(), PasswordFactory\newInvalidPassword(), and User\TOKEN_LENGTH.
|
private |
Definition at line 40 of file BotPassword.php.
Referenced by canonicalizeLoginData(), delete(), getAppId(), login(), newFromCentralId(), newFromUser(), and save().
|
private |
Definition at line 37 of file BotPassword.php.
Referenced by delete(), getUserCentralId(), invalidateAllPasswordsForCentralId(), invalidateAllPasswordsForUser(), newFromCentralId(), newFromUser(), removeAllPasswordsForCentralId(), removeAllPasswordsForUser(), and save().
|
private |
Definition at line 52 of file BotPassword.php.
Referenced by __construct(), newFromCentralId(), newFromUser(), and newUnsaved().
|
private |
Definition at line 49 of file BotPassword.php.
Referenced by getGrants().
|
private |
Definition at line 34 of file BotPassword.php.
Referenced by __construct(), and isSaved().
|
private |
Definition at line 46 of file BotPassword.php.
Referenced by getRestrictions().
|
private |
Definition at line 43 of file BotPassword.php.
Referenced by getToken().
const BotPassword::APPID_MAXLENGTH = 32 |
Definition at line 31 of file BotPassword.php.
Referenced by SpecialBotPasswords\execute(), SpecialBotPasswords\getFormFields(), and BotPasswordTest\testUnsaved().