MediaWiki  REL1_31
AuthPlugin.php
Go to the documentation of this file.
1 <?php
38 class AuthPlugin {
42  protected $domain;
43 
53  public function userExists( $username ) {
54  # Override this!
55  return false;
56  }
57 
68  public function authenticate( $username, $password ) {
69  # Override this!
70  return false;
71  }
72 
79  public function modifyUITemplate( &$template, &$type ) {
80  # Override this!
81  $template->set( 'usedomain', false );
82  }
83 
89  public function setDomain( $domain ) {
90  $this->domain = $domain;
91  }
92 
98  public function getDomain() {
99  if ( isset( $this->domain ) ) {
100  return $this->domain;
101  } else {
102  return 'invaliddomain';
103  }
104  }
105 
112  public function validDomain( $domain ) {
113  # Override this!
114  return true;
115  }
116 
130  public function updateUser( &$user ) {
131  # Override this and do something
132  return true;
133  }
134 
148  public function autoCreate() {
149  return false;
150  }
151 
161  public function allowPropChange( $prop = '' ) {
162  if ( $prop == 'realname' && is_callable( [ $this, 'allowRealNameChange' ] ) ) {
163  return $this->allowRealNameChange();
164  } elseif ( $prop == 'emailaddress' && is_callable( [ $this, 'allowEmailChange' ] ) ) {
165  return $this->allowEmailChange();
166  } elseif ( $prop == 'nickname' && is_callable( [ $this, 'allowNickChange' ] ) ) {
167  return $this->allowNickChange();
168  } else {
169  return true;
170  }
171  }
172 
178  public function allowPasswordChange() {
179  return true;
180  }
181 
187  public function allowSetLocalPassword() {
188  return true;
189  }
190 
203  public function setPassword( $user, $password ) {
204  return true;
205  }
206 
215  public function updateExternalDB( $user ) {
216  return true;
217  }
218 
229  public function updateExternalDBGroups( $user, $addgroups, $delgroups = [] ) {
230  return true;
231  }
232 
238  public function canCreateAccounts() {
239  return false;
240  }
241 
252  public function addUser( $user, $password, $email = '', $realname = '' ) {
253  return true;
254  }
255 
264  public function strict() {
265  return false;
266  }
267 
275  public function strictUserAuth( $username ) {
276  return false;
277  }
278 
292  public function initUser( &$user, $autocreate = false ) {
293  # Override this to do something.
294  }
295 
302  public function getCanonicalName( $username ) {
303  return $username;
304  }
305 
313  public function getUserInstance( User &$user ) {
314  return new AuthPluginUser( $user );
315  }
316 
322  public function domainList() {
323  return [];
324  }
325 }
326 
331  function __construct( $user ) {
332  # Override this!
333  }
334 
335  public function getId() {
336  # Override this!
337  return -1;
338  }
339 
345  public function isLocked() {
346  # Override this!
347  return false;
348  }
349 
355  public function isHidden() {
356  # Override this!
357  return false;
358  }
359 
364  public function resetAuthToken() {
365  # Override this!
366  return true;
367  }
368 }
AuthPlugin\$domain
string $domain
Definition: AuthPlugin.php:42
$user
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 account $user
Definition: hooks.txt:247
AuthPlugin\allowSetLocalPassword
allowSetLocalPassword()
Should MediaWiki store passwords in its local database?
Definition: AuthPlugin.php:187
AuthPlugin\getDomain
getDomain()
Get the user's domain.
Definition: AuthPlugin.php:98
AuthPluginUser\resetAuthToken
resetAuthToken()
Definition: AuthPlugin.php:364
AuthPluginUser\isHidden
isHidden()
Indicate whether the user is hidden.
Definition: AuthPlugin.php:355
AuthPlugin\setDomain
setDomain( $domain)
Set the domain this plugin is supposed to use when authenticating.
Definition: AuthPlugin.php:89
AuthPluginUser\__construct
__construct( $user)
Definition: AuthPlugin.php:331
$template
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
Definition: hooks.txt:831
AuthPlugin\allowPropChange
allowPropChange( $prop='')
Allow a property change? Properties are the same as preferences and use the same keys.
Definition: AuthPlugin.php:161
AuthPlugin\updateExternalDBGroups
updateExternalDBGroups( $user, $addgroups, $delgroups=[])
Update user groups in the external authentication database.
Definition: AuthPlugin.php:229
AuthPlugin\authenticate
authenticate( $username, $password)
Check if a username+password pair is a valid login.
Definition: AuthPlugin.php:68
AuthPlugin\addUser
addUser( $user, $password, $email='', $realname='')
Add a user to the external authentication database.
Definition: AuthPlugin.php:252
AuthPlugin\getCanonicalName
getCanonicalName( $username)
If you want to munge the case of an account name before the final check, now is your chance.
Definition: AuthPlugin.php:302
php
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
AuthPlugin\getUserInstance
getUserInstance(User &$user)
Get an instance of a User object.
Definition: AuthPlugin.php:313
AuthPlugin\allowPasswordChange
allowPasswordChange()
Can users change their passwords?
Definition: AuthPlugin.php:178
AuthPlugin\updateUser
updateUser(&$user)
When a user logs in, optionally fill in preferences and such.
Definition: AuthPlugin.php:130
AuthPlugin\canCreateAccounts
canCreateAccounts()
Check to see if external accounts can be created.
Definition: AuthPlugin.php:238
AuthPlugin\updateExternalDB
updateExternalDB( $user)
Update user information in the external authentication database.
Definition: AuthPlugin.php:215
AuthPlugin\strictUserAuth
strictUserAuth( $username)
Check if a user should authenticate locally if the global authentication fails.
Definition: AuthPlugin.php:275
AuthPlugin\initUser
initUser(&$user, $autocreate=false)
When creating a user account, optionally fill in preferences and such.
Definition: AuthPlugin.php:292
AuthPlugin\userExists
userExists( $username)
Check whether there exists a user account with the given name.
Definition: AuthPlugin.php:53
AuthPlugin\autoCreate
autoCreate()
Return true if the wiki should create a new local account automatically when asked to login a user wh...
Definition: AuthPlugin.php:148
AuthPluginUser
Definition: AuthPlugin.php:330
AuthPlugin\strict
strict()
Return true to prevent logins that don't authenticate here from being checked against the local datab...
Definition: AuthPlugin.php:264
AuthPluginUser\getId
getId()
Definition: AuthPlugin.php:335
AuthPlugin\domainList
domainList()
Get a list of domains (in HTMLForm options format) used.
Definition: AuthPlugin.php:322
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:785
AuthPlugin\setPassword
setPassword( $user, $password)
Set the given password in the authentication database.
Definition: AuthPlugin.php:203
AuthPlugin\modifyUITemplate
modifyUITemplate(&$template, &$type)
Modify options in the login template.
Definition: AuthPlugin.php:79
AuthPlugin\validDomain
validDomain( $domain)
Check to see if the specific domain is a valid domain.
Definition: AuthPlugin.php:112
AuthPluginUser\isLocked
isLocked()
Indicate whether the user is locked.
Definition: AuthPlugin.php:345
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
AuthPlugin
Authentication plugin interface.
Definition: AuthPlugin.php:38
$type
$type
Definition: testCompression.php:48