|
MediaWiki master
|
Utility class for bot passwords. More...
Public Member Functions | |
| __construct (stdClass $row, private bool $isSaved, private readonly int $flags=IDBAccessObject::READ_NORMAL,) | |
| delete () | |
| Delete the BotPassword from the database. | |
| getAppId () | |
| getGrants () | |
| getRestrictions () | |
| getToken () | |
| 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 (string $username, string $password) |
| There are two ways to login with a bot password: "username@appId", "password" and "username", "appId@password". | |
| static | generatePassword () |
| Returns a (raw, unhashed) random password string. | |
| static | getPrimaryDatabase () |
| static | getReplicaDatabase () |
| static | getSeparator () |
| Get the separator for combined username + app ID. | |
| static | invalidateAllPasswordsForUser (string $username) |
| Invalidate all passwords for a user, by name. | |
| static | login (string $username, string $password, WebRequest $request) |
| Try to log the user in. | |
| static | newFromCentralId ( $centralId, $appId, $flags=IDBAccessObject::READ_NORMAL) |
| Load a BotPassword from the database. | |
| static | newFromUser (UserIdentity $userIdentity, $appId, $flags=IDBAccessObject::READ_NORMAL) |
| Load a BotPassword from the database. | |
| static | newUnsaved (array $data, $flags=IDBAccessObject::READ_NORMAL) |
| Create an unsaved BotPassword. | |
| static | removeAllPasswordsForUser (string $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. | |
| MediaWiki\User\BotPassword::__construct | ( | stdClass | $row, |
| private bool | $isSaved, | ||
| private readonly int | $flags = IDBAccessObject::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 70 of file BotPassword.php.
|
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 299 of file BotPassword.php.
Referenced by MediaWiki\Api\ApiLogin\execute().
| MediaWiki\User\BotPassword::delete | ( | ) |
Delete the BotPassword from the database.
Definition at line 250 of file BotPassword.php.
References MediaWiki\MediaWikiServices\getInstance(), and isSaved().
|
static |
Returns a (raw, unhashed) random password string.
Definition at line 286 of file BotPassword.php.
References PASSWORD_MINLENGTH, and return.
Referenced by CreateBotPassword\execute().
| MediaWiki\User\BotPassword::getAppId | ( | ) |
Definition at line 152 of file BotPassword.php.
References return.
Referenced by MediaWiki\User\BotPasswordStore\insertBotPassword(), and MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
| MediaWiki\User\BotPassword::getGrants | ( | ) |
Definition at line 167 of file BotPassword.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
static |
Definition at line 88 of file BotPassword.php.
References getPrimaryDatabase(), and return.
Referenced by getPrimaryDatabase().
|
static |
Definition at line 82 of file BotPassword.php.
References getReplicaDatabase(), and return.
Referenced by getReplicaDatabase().
| MediaWiki\User\BotPassword::getRestrictions | ( | ) |
Definition at line 160 of file BotPassword.php.
References return.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
static |
Get the separator for combined username + app ID.
Definition at line 174 of file BotPassword.php.
References return.
| MediaWiki\User\BotPassword::getToken | ( | ) |
Definition at line 156 of file BotPassword.php.
References return.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
| MediaWiki\User\BotPassword::getUserCentralId | ( | ) |
Get the central user ID.
Definition at line 148 of file BotPassword.php.
References return.
Referenced by MediaWiki\User\BotPasswordStore\insertBotPassword(), and MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
|
static |
Invalidate all passwords for a user, by name.
| string | $username |
Definition at line 266 of file BotPassword.php.
References return.
Referenced by InvalidateBotPasswords\execute().
| MediaWiki\User\BotPassword::isInvalid | ( | ) |
Whether the password is currently invalid.
Definition at line 208 of file BotPassword.php.
References return.
| MediaWiki\User\BotPassword::isSaved | ( | ) |
|
static |
Try to log the user in.
| string | $username | Combined username and app ID |
| string | $password | Supplied password |
| WebRequest | $request |
Definition at line 325 of file BotPassword.php.
References $request, MediaWiki\MainConfigNames\EnableBotPasswords, MediaWiki\MediaWikiServices\getInstance(), MediaWiki\User\User\newFromName(), MediaWiki\MainConfigNames\PasswordAttemptThrottle, and wfMessage().
Referenced by MediaWiki\Api\ApiLogin\execute().
|
static |
Load a BotPassword from the database.
| int | $centralId | from CentralIdLookup |
| string | $appId | |
| int | $flags | IDBAccessObject read flags |
Definition at line 114 of file BotPassword.php.
References MediaWiki\MediaWikiServices\getInstance().
|
static |
Load a BotPassword from the database.
| UserIdentity | $userIdentity | |
| string | $appId | |
| int | $flags | IDBAccessObject read flags |
Definition at line 101 of file BotPassword.php.
References MediaWiki\MediaWikiServices\getInstance().
|
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 132 of file BotPassword.php.
References MediaWiki\MediaWikiServices\getInstance().
Referenced by CreateBotPassword\execute().
|
static |
Remove all passwords for a user, by name.
| string | $username |
Definition at line 277 of file BotPassword.php.
References return.
| MediaWiki\User\BotPassword::save | ( | $operation, | |
| ?Password | $password = null ) |
Save the BotPassword to the database.
| string | $operation | 'update' or 'insert' |
| Password | null | $password | Password to set. |
| UnexpectedValueException |
Definition at line 219 of file BotPassword.php.
References MediaWiki\MediaWikiServices\getInstance(), and isSaved().
| const MediaWiki\User\BotPassword::APPID_MAXLENGTH = 32 |
Definition at line 36 of file BotPassword.php.
| const MediaWiki\User\BotPassword::GRANTS_MAXLENGTH = 65535 |
Maximum length of the json representation of grants.
Definition at line 53 of file BotPassword.php.
| const MediaWiki\User\BotPassword::PASSWORD_MINLENGTH = 32 |
Minimum length for a bot password.
Definition at line 41 of file BotPassword.php.
Referenced by CreateBotPassword\execute(), and generatePassword().
| const MediaWiki\User\BotPassword::RESTRICTIONS_MAXLENGTH = 65535 |
Maximum length of the json representation of restrictions.
Definition at line 47 of file BotPassword.php.