MediaWiki REL1_28
Go to the documentation of this file.
23use \Cdb\Reader as CdbReader;
38 public static function checkMinimalPasswordLength( $policyVal, User $user, $password ) {
39 $status = Status::newGood();
40 if ( $policyVal > strlen( $password ) ) {
41 $status->error( 'passwordtooshort', $policyVal );
42 }
43 return $status;
44 }
53 public static function checkMinimumPasswordLengthToLogin( $policyVal, User $user, $password ) {
54 $status = Status::newGood();
55 if ( $policyVal > strlen( $password ) ) {
56 $status->fatal( 'passwordtooshort', $policyVal );
57 }
58 return $status;
59 }
68 public static function checkMaximalPasswordLength( $policyVal, User $user, $password ) {
69 $status = Status::newGood();
70 if ( $policyVal < strlen( $password ) ) {
71 $status->fatal( 'passwordtoolong', $policyVal );
72 }
73 return $status;
74 }
83 public static function checkPasswordCannotMatchUsername( $policyVal, User $user, $password ) {
85 $status = Status::newGood();
86 $username = $user->getName();
87 if ( $policyVal && $wgContLang->lc( $password ) === $wgContLang->lc( $username ) ) {
88 $status->error( 'password-name-match' );
89 }
90 return $status;
91 }
100 public static function checkPasswordCannotMatchBlacklist( $policyVal, User $user, $password ) {
101 static $blockedLogins = [
102 'Useruser' => 'Passpass', 'Useruser1' => 'Passpass1', # r75589
103 'Apitestsysop' => 'testpass', 'Apitestuser' => 'testpass' # r75605
104 ];
106 $status = Status::newGood();
107 $username = $user->getName();
108 if ( $policyVal ) {
109 if ( isset( $blockedLogins[$username] ) && $password == $blockedLogins[$username] ) {
110 $status->error( 'password-login-forbidden' );
111 }
113 // Example from ApiChangeAuthenticationRequest
114 if ( $password === 'ExamplePassword' ) {
115 $status->error( 'password-login-forbidden' );
116 }
117 }
118 return $status;
119 }
132 public static function checkPopularPasswordBlacklist( $policyVal, User $user, $password ) {
134 $status = Status::newGood();
135 if ( $policyVal > 0 ) {
136 $langEn = Language::factory( 'en' );
137 $passwordKey = $langEn->lc( trim( $password ) );
139 // People often use the name of the current site, which won't be
140 // in the common password file. Also check '' for people who use
141 // just whitespace.
142 $sitename = $langEn->lc( trim( $wgSitename ) );
143 $hardcodedCommonPasswords = [ '', 'wiki', 'mediawiki', $sitename ];
144 if ( in_array( $passwordKey, $hardcodedCommonPasswords ) ) {
145 $status->error( 'passwordtoopopular' );
146 return $status;
147 }
149 // This could throw an exception, but there's not a good way
150 // of failing gracefully, if say the file is missing, so just
151 // let the exception fall through.
152 // Format of cdb file is mapping password => popularity rank.
153 // See maintenance/createCommonPasswordCdb.php
154 $db = CdbReader::open( $wgPopularPasswordFile );
156 $res = $db->get( $passwordKey );
157 if ( $res && (int)$res <= $policyVal ) {
158 // Note: If you want to find the true number of common
159 // passwords stored (for reporting the error), you have to take
160 // the max of the policyVal and $db->get( '_TOTALENTRIES' ).
161 $status->error( 'passwordtoopopular' );
162 }
163 }
164 return $status;
165 }
string $wgPopularPasswordFile
Where popular password file is located.
Name of the site.
Functions to check passwords against a policy requirement.
static checkPasswordCannotMatchUsername( $policyVal, User $user, $password)
Check if username and password match.
static checkMinimalPasswordLength( $policyVal, User $user, $password)
Check password is longer than minimum, not fatal.
static checkPasswordCannotMatchBlacklist( $policyVal, User $user, $password)
Check if username and password are on a blacklist.
static checkPopularPasswordBlacklist( $policyVal, User $user, $password)
Ensure that password isn't in top X most popular passwords.
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,...
Definition User.php:48
Definition database.txt:21
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:807
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37