25 use Wikimedia\CommonPasswords\CommonPasswords;
48 $status = Status::newGood();
49 if ( $policyVal > strlen( $password ) ) {
50 $status->error(
'passwordtooshort', $policyVal );
65 $status = Status::newGood();
66 if ( $policyVal > strlen( $password ) ) {
67 $status->fatal(
'passwordtooshort', $policyVal );
81 $status = Status::newGood();
82 if ( $policyVal < strlen( $password ) ) {
83 $status->fatal(
'passwordtoolong', $policyVal );
100 $status = Status::newGood();
102 if ( $policyVal && stripos( $username, $password ) !==
false ) {
103 $status->error(
'password-substring-username-match' );
116 static $blockedLogins = [
118 'Useruser' =>
'Passpass',
119 'Useruser1' =>
'Passpass1',
121 'Apitestsysop' =>
'testpass',
122 'Apitestuser' =>
'testpass',
125 $status = Status::newGood();
129 isset( $blockedLogins[$username] ) &&
130 hash_equals( $blockedLogins[$username], $password )
132 $status->error(
'password-login-forbidden' );
136 if ( hash_equals(
'ExamplePassword', $password ) ) {
137 $status->error(
'password-login-forbidden' );
158 $status = Status::newGood();
159 if ( $policyVal && CommonPasswords::isCommon( $password ) ) {
160 $status->error(
'passwordincommonlist' );
Functions to check passwords against a policy requirement.
static checkMinimumPasswordLengthToLogin( $policyVal, UserIdentity $user, $password)
Check password is longer than minimum, fatal.
static checkPasswordNotInCommonList( $policyVal, UserIdentity $user, $password)
Ensure the password isn't in the list of common passwords by the wikimedia/common-passwords library,...
static checkMaximalPasswordLength( $policyVal, UserIdentity $user, $password)
Check password is shorter than maximum, fatal.
static checkPasswordCannotBeSubstringInUsername( $policyVal, UserIdentity $user, $password)
Check if password is a (case-insensitive) substring within the username.
static checkMinimalPasswordLength( $policyVal, UserIdentity $user, $password)
Check password is longer than minimum, not fatal.
static checkPasswordCannotMatchDefaults( $policyVal, UserIdentity $user, $password)
Check if username and password are on a list of past MediaWiki default passwords.