MediaWiki REL1_32
AuthPlugin.php
Go to the documentation of this file.
1<?php
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 return $this->domain ?? 'invaliddomain';
100 }
101
108 public function validDomain( $domain ) {
109 # Override this!
110 return true;
111 }
112
126 public function updateUser( &$user ) {
127 # Override this and do something
128 return true;
129 }
130
144 public function autoCreate() {
145 return false;
146 }
147
157 public function allowPropChange( $prop = '' ) {
158 if ( $prop == 'realname' && is_callable( [ $this, 'allowRealNameChange' ] ) ) {
159 return $this->allowRealNameChange();
160 } elseif ( $prop == 'emailaddress' && is_callable( [ $this, 'allowEmailChange' ] ) ) {
161 return $this->allowEmailChange();
162 } elseif ( $prop == 'nickname' && is_callable( [ $this, 'allowNickChange' ] ) ) {
163 return $this->allowNickChange();
164 } else {
165 return true;
166 }
167 }
168
174 public function allowPasswordChange() {
175 return true;
176 }
177
183 public function allowSetLocalPassword() {
184 return true;
185 }
186
199 public function setPassword( $user, $password ) {
200 return true;
201 }
202
211 public function updateExternalDB( $user ) {
212 return true;
213 }
214
225 public function updateExternalDBGroups( $user, $addgroups, $delgroups = [] ) {
226 return true;
227 }
228
234 public function canCreateAccounts() {
235 return false;
236 }
237
248 public function addUser( $user, $password, $email = '', $realname = '' ) {
249 return true;
250 }
251
260 public function strict() {
261 return false;
262 }
263
271 public function strictUserAuth( $username ) {
272 return false;
273 }
274
288 public function initUser( &$user, $autocreate = false ) {
289 # Override this to do something.
290 }
291
298 public function getCanonicalName( $username ) {
299 return $username;
300 }
301
309 public function getUserInstance( User &$user ) {
310 return new AuthPluginUser( $user );
311 }
312
318 public function domainList() {
319 return [];
320 }
321}
322
327 function __construct( $user ) {
328 # Override this!
329 }
330
331 public function getId() {
332 # Override this!
333 return -1;
334 }
335
341 public function isLocked() {
342 # Override this!
343 return false;
344 }
345
351 public function isHidden() {
352 # Override this!
353 return false;
354 }
355
360 public function resetAuthToken() {
361 # Override this!
362 return true;
363 }
364}
__construct( $user)
isLocked()
Indicate whether the user is locked.
isHidden()
Indicate whether the user is hidden.
Authentication plugin interface.
updateExternalDBGroups( $user, $addgroups, $delgroups=[])
Update user groups in the external authentication database.
autoCreate()
Return true if the wiki should create a new local account automatically when asked to login a user wh...
setDomain( $domain)
Set the domain this plugin is supposed to use when authenticating.
canCreateAccounts()
Check to see if external accounts can be created.
initUser(&$user, $autocreate=false)
When creating a user account, optionally fill in preferences and such.
allowPasswordChange()
Can users change their passwords?
modifyUITemplate(&$template, &$type)
Modify options in the login template.
authenticate( $username, $password)
Check if a username+password pair is a valid login.
updateUser(&$user)
When a user logs in, optionally fill in preferences and such.
validDomain( $domain)
Check to see if the specific domain is a valid domain.
getUserInstance(User &$user)
Get an instance of a User object.
allowPropChange( $prop='')
Allow a property change? Properties are the same as preferences and use the same keys.
addUser( $user, $password, $email='', $realname='')
Add a user to the external authentication database.
getCanonicalName( $username)
If you want to munge the case of an account name before the final check, now is your chance.
allowSetLocalPassword()
Should MediaWiki store passwords in its local database?
setPassword( $user, $password)
Set the given password in the authentication database.
updateExternalDB( $user)
Update user information in the external authentication database.
domainList()
Get a list of domains (in HTMLForm options format) used.
getDomain()
Get the user's domain.
string $domain
strict()
Return true to prevent logins that don't authenticate here from being checked against the local datab...
userExists( $username)
Check whether there exists a user account with the given name.
strictUserAuth( $username)
Check if a user should authenticate locally if the global authentication fails.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:47
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:861
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:815
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:247
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