24use Wikimedia\CommonPasswords\CommonPasswords;
47 $status = Status::newGood();
48 if ( $policyVal > strlen( $password ) ) {
49 $status->error(
'passwordtooshort', $policyVal );
64 $status = Status::newGood();
65 if ( $policyVal > strlen( $password ) ) {
66 $status->fatal(
'passwordtooshort', $policyVal );
80 $status = Status::newGood();
81 if ( $policyVal < strlen( $password ) ) {
82 $status->fatal(
'passwordtoolong', $policyVal );
95 $status = Status::newGood();
97 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
99 $policyVal && hash_equals( $contLang->lc( $username ), $contLang->lc( $password ) )
101 $status->error(
'password-name-match' );
118 $status = Status::newGood();
120 if ( $policyVal && stripos( $username, $password ) !==
false ) {
121 $status->error(
'password-substring-username-match' );
134 static $blockedLogins = [
136 'Useruser' =>
'Passpass',
137 'Useruser1' =>
'Passpass1',
139 'Apitestsysop' =>
'testpass',
140 'Apitestuser' =>
'testpass',
143 $status = Status::newGood();
147 isset( $blockedLogins[$username] ) &&
148 hash_equals( $blockedLogins[$username], $password )
150 $status->error(
'password-login-forbidden' );
154 if ( hash_equals(
'ExamplePassword', $password ) ) {
155 $status->error(
'password-login-forbidden' );
176 $status = Status::newGood();
177 if ( $policyVal && CommonPasswords::isCommon( $password ) ) {
178 $status->error(
'passwordincommonlist' );
Functions to check passwords against a policy requirement.
static checkPasswordCannotMatchUsername( $policyVal, User $user, $password)
Check if username and password are a (case-insensitive) match.
static checkPasswordCannotBeSubstringInUsername( $policyVal, User $user, $password)
Check if password is a (case-insensitive) substring within the username.
static checkMinimalPasswordLength( $policyVal, User $user, $password)
Check password is longer than minimum, not fatal.
static checkPasswordCannotMatchDefaults( $policyVal, User $user, $password)
Check if username and password are on a list of past MediaWiki default passwords.
static checkPasswordNotInCommonList( $policyVal, User $user, $password)
Ensure the password isn't in the list of common passwords by the wikimedia/common-passwords library,...
static checkMinimumPasswordLengthToLogin( $policyVal, User $user, $password)
Check password is longer than minimum, fatal.
static checkMaximalPasswordLength( $policyVal, User $user, $password)
Check password is shorter than maximum, fatal.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.