MediaWiki REL1_33
PasswordPolicyChecks Class Reference

Functions to check passwords against a policy requirement. More...

Static Public Member Functions

static checkMaximalPasswordLength ( $policyVal, User $user, $password)
 Check password is shorter than maximum, fatal.
 
static checkMinimalPasswordLength ( $policyVal, User $user, $password)
 Check password is longer than minimum, not fatal.
 
static checkMinimumPasswordLengthToLogin ( $policyVal, User $user, $password)
 Check password is longer than minimum, fatal.
 
static checkPasswordCannotMatchBlacklist ( $policyVal, User $user, $password)
 Check if username and password are on a blacklist of past MediaWiki default passwords.
 
static checkPasswordCannotMatchUsername ( $policyVal, User $user, $password)
 Check if username and password are a (case-insensitive) match.
 
static checkPasswordNotInLargeBlacklist ( $policyVal, User $user, $password)
 Ensure the password isn't in the list of passwords blacklisted by the wikimedia/password-blacklist library, which contains (as of 0.1.4) the 100.000 top passwords from SecLists (as a Bloom filter, with an 0.000001 false positive ratio).
 
static checkPopularPasswordBlacklist ( $policyVal, User $user, $password)
 Ensure that password isn't in top X most popular passwords, as defined by $wgPopularPasswordFile.
 

Detailed Description

Functions to check passwords against a policy requirement.

$policyVal is the value configured in $wgPasswordPolicy. If the return status is fatal, the user won't be allowed to login. If the status is not good but not fatal, the user will not be allowed to set the given password (on registration or password change), but can still log in after bypassing a warning.

Since
1.26
See also
$wgPasswordPolicy

Definition at line 38 of file PasswordPolicyChecks.php.

Member Function Documentation

◆ checkMaximalPasswordLength()

static PasswordPolicyChecks::checkMaximalPasswordLength (   $policyVal,
User  $user,
  $password 
)
static

Check password is shorter than maximum, fatal.

Intended for preventing DoS attacks when using a more expensive password hash like PBKDF2.

Parameters
int$policyValmaximum length
User$user
string$password
Returns
Status fatal if $password is shorter than $policyVal

Definition at line 80 of file PasswordPolicyChecks.php.

Referenced by PasswordPolicyChecksTest\testCheckMaximalPasswordLength().

◆ checkMinimalPasswordLength()

static PasswordPolicyChecks::checkMinimalPasswordLength (   $policyVal,
User  $user,
  $password 
)
static

Check password is longer than minimum, not fatal.

Parameters
int$policyValminimal length
User$user
string$password
Returns
Status error if $password is shorter than $policyVal

Definition at line 47 of file PasswordPolicyChecks.php.

Referenced by PasswordPolicyChecksTest\testCheckMinimalPasswordLength().

◆ checkMinimumPasswordLengthToLogin()

static PasswordPolicyChecks::checkMinimumPasswordLengthToLogin (   $policyVal,
User  $user,
  $password 
)
static

Check password is longer than minimum, fatal.

Intended for locking out users with passwords too short to trust, requiring them to recover their account by some other means.

Parameters
int$policyValminimal length
User$user
string$password
Returns
Status fatal if $password is shorter than $policyVal

Definition at line 64 of file PasswordPolicyChecks.php.

Referenced by PasswordPolicyChecksTest\testCheckMinimumPasswordLengthToLogin().

◆ checkPasswordCannotMatchBlacklist()

static PasswordPolicyChecks::checkPasswordCannotMatchBlacklist (   $policyVal,
User  $user,
  $password 
)
static

Check if username and password are on a blacklist of past MediaWiki default passwords.

Parameters
bool$policyValtrue to force compliance.
User$user
string$password
Returns
Status error if username and password match, and policy is true

Definition at line 114 of file PasswordPolicyChecks.php.

References $user, and $username.

Referenced by PasswordPolicyChecksTest\testCheckPasswordCannotMatchBlacklist().

◆ checkPasswordCannotMatchUsername()

static PasswordPolicyChecks::checkPasswordCannotMatchUsername (   $policyVal,
User  $user,
  $password 
)
static

Check if username and password are a (case-insensitive) match.

Parameters
bool$policyValtrue to force compliance.
User$user
string$password
Returns
Status error if username and password match, and policy is true

Definition at line 95 of file PasswordPolicyChecks.php.

References $user, and $username.

Referenced by PasswordPolicyChecksTest\testCheckPasswordCannotMatchUsername().

◆ checkPasswordNotInLargeBlacklist()

static PasswordPolicyChecks::checkPasswordNotInLargeBlacklist (   $policyVal,
User  $user,
  $password 
)
static

Ensure the password isn't in the list of passwords blacklisted by the wikimedia/password-blacklist library, which contains (as of 0.1.4) the 100.000 top passwords from SecLists (as a Bloom filter, with an 0.000001 false positive ratio).

Parameters
bool$policyValWhether to apply this policy
User$user
string$password
Since
1.33
Returns
Status

Definition at line 203 of file PasswordPolicyChecks.php.

Referenced by PasswordPolicyChecksTest\testCheckNotInLargeBlacklist().

◆ checkPopularPasswordBlacklist()

static PasswordPolicyChecks::checkPopularPasswordBlacklist (   $policyVal,
User  $user,
  $password 
)
static

Ensure that password isn't in top X most popular passwords, as defined by $wgPopularPasswordFile.

Parameters
int$policyValCut off to use. Will automatically shrink to the max supported for error messages if set to more than max number of passwords on file, so you can use the PHP_INT_MAX constant here safely.
User$user
string$password
Since
1.27
Deprecated:
since 1.33
Returns
Status
See also
$wgPopularPasswordFile

Definition at line 152 of file PasswordPolicyChecks.php.

References $res, $wgPopularPasswordFile, $wgSitename, and wfDeprecated().

Referenced by PasswordPolicyChecksTest\testCheckPopularPasswordBlacklist().


The documentation for this class was generated from the following file: