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 );
99 $status = Status::newGood();
101 if ( $policyVal && stripos( $username, $password ) !==
false ) {
102 $status->error(
'password-substring-username-match' );
115 static $blockedLogins = [
117 'Useruser' =>
'Passpass',
118 'Useruser1' =>
'Passpass1',
120 'Apitestsysop' =>
'testpass',
121 'Apitestuser' =>
'testpass',
124 $status = Status::newGood();
128 isset( $blockedLogins[$username] ) &&
129 hash_equals( $blockedLogins[$username], $password )
131 $status->error(
'password-login-forbidden' );
135 if ( hash_equals(
'ExamplePassword', $password ) ) {
136 $status->error(
'password-login-forbidden' );
157 $status = Status::newGood();
158 if ( $policyVal && CommonPasswords::isCommon( $password ) ) {
159 $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.