MediaWiki  master
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
24 use User;
25 
35 {
36 
44  public function continuePrimaryAuthentication( array $reqs ) {
45  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
46  }
47 
52  public function postAuthentication( $user, AuthenticationResponse $response ) {
53  }
54 
59  public function testUserCanAuthenticate( $username ) {
60  // Assume it can authenticate if it exists
61  return $this->testUserExists( $username );
62  }
63 
71  public function providerNormalizeUsername( $username ) {
72  $name = User::getCanonicalName( $username );
73  return $name === false ? null : $name;
74  }
75 
82  public function providerRevokeAccessForUser( $username ) {
83  $reqs = $this->getAuthenticationRequests(
84  AuthManager::ACTION_REMOVE, [ 'username' => $username ]
85  );
86  foreach ( $reqs as $req ) {
87  $req->username = $username;
88  $req->action = AuthManager::ACTION_REMOVE;
89  $this->providerChangeAuthenticationData( $req );
90  }
91  }
92 
97  public function providerAllowsPropertyChange( $property ) {
98  return true;
99  }
100 
105  public function testForAccountCreation( $user, $creator, array $reqs ) {
106  return \StatusValue::newGood();
107  }
108 
113  public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
114  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
115  }
116 
121  public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ) {
122  return null;
123  }
124 
129  public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
130  }
131 
136  public function testUserForCreation( $user, $autocreate, array $options = [] ) {
137  return \StatusValue::newGood();
138  }
139 
144  public function autoCreatedAccount( $user, $source ) {
145  }
146 
151  public function beginPrimaryAccountLink( $user, array $reqs ) {
152  if ( $this->accountCreationType() === self::TYPE_LINK ) {
153  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
154  } else {
155  throw new \BadMethodCallException(
156  __METHOD__ . ' should not be called on a non-link provider.'
157  );
158  }
159  }
160 
165  public function continuePrimaryAccountLink( $user, array $reqs ) {
166  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
167  }
168 
173  public function postAccountLink( $user, AuthenticationResponse $response ) {
174  }
175 
176 }
MediaWiki\Auth\PrimaryAuthenticationProvider\accountCreationType
accountCreationType()
Fetch the account-creation type.
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\postAuthentication
postAuthentication( $user, AuthenticationResponse $response)
Post-login callback.This will be called at the end of any login attempt, regardless of whether this p...
Definition: AbstractPrimaryAuthenticationProvider.php:52
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\continuePrimaryAccountCreation
continuePrimaryAccountCreation( $user, $creator, array $reqs)
Continue an account creation flow.User being created (not added to the database yet)....
Definition: AbstractPrimaryAuthenticationProvider.php:113
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\autoCreatedAccount
autoCreatedAccount( $user, $source)
Post-auto-creation callback.User being created (has been added to the database now)....
Definition: AbstractPrimaryAuthenticationProvider.php:144
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\continuePrimaryAccountLink
continuePrimaryAccountLink( $user, array $reqs)
Continue linking an account to an existing user.User being linked. This may become a "UserValue" in t...
Definition: AbstractPrimaryAuthenticationProvider.php:165
MediaWiki\Auth\PrimaryAuthenticationProvider\providerChangeAuthenticationData
providerChangeAuthenticationData(AuthenticationRequest $req)
Change or remove authentication data (e.g.
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\testForAccountCreation
testForAccountCreation( $user, $creator, array $reqs)
Determine whether an account creation may begin.Called from AuthManager::beginAccountCreation()No nee...
Definition: AbstractPrimaryAuthenticationProvider.php:105
MediaWiki\Auth\AuthenticationResponse
This is a value object to hold authentication response data.
Definition: AuthenticationResponse.php:37
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\postAccountCreation
postAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.This will be called at the end of any account creation attempt,...
Definition: AbstractPrimaryAuthenticationProvider.php:129
MediaWiki\Auth\PrimaryAuthenticationProvider\testUserExists
testUserExists( $username, $flags=User::READ_NORMAL)
Test whether the named user exists.
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\continuePrimaryAuthentication
continuePrimaryAuthentication(array $reqs)
Stable to override.
Definition: AbstractPrimaryAuthenticationProvider.php:44
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\providerNormalizeUsername
providerNormalizeUsername( $username)
Normalize the username for authentication.Any two inputs that would result in the same user being aut...
Definition: AbstractPrimaryAuthenticationProvider.php:71
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\testUserCanAuthenticate
testUserCanAuthenticate( $username)
Test whether the named user can authenticate with this provider.Should return true if the provider ha...
Definition: AbstractPrimaryAuthenticationProvider.php:59
MediaWiki\Auth\PrimaryAuthenticationProvider\getAuthenticationRequests
getAuthenticationRequests( $action, array $options)
Return the applicable list of AuthenticationRequests.Possible values for $action depend on whether th...
MediaWiki\Auth\AuthManager\ACTION_REMOVE
const ACTION_REMOVE
Remove a user's credentials.
Definition: AuthManager.php:110
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\finishAccountCreation
finishAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.Called after the user is added to the database, before secondary authenticatio...
Definition: AbstractPrimaryAuthenticationProvider.php:121
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\providerAllowsPropertyChange
providerAllowsPropertyChange( $property)
Determine whether a property can change.AuthManager::allowsPropertyChange() bool Stable to override
Definition: AbstractPrimaryAuthenticationProvider.php:97
User\getCanonicalName
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
Definition: User.php:1127
$source
$source
Definition: mwdoc-filter.php:34
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\testUserForCreation
testUserForCreation( $user, $autocreate, array $options=[])
Determine whether an account may be created.User being created (not added to the database yet)....
Definition: AbstractPrimaryAuthenticationProvider.php:136
MediaWiki\Auth\AbstractAuthenticationProvider
A base class that implements some of the boilerplate for an AuthenticationProvider Stable to extend.
Definition: AbstractAuthenticationProvider.php:35
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider
A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider.
Definition: AbstractPrimaryAuthenticationProvider.php:35
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\beginPrimaryAccountLink
beginPrimaryAccountLink( $user, array $reqs)
Start linking an account to an existing user.User being linked. This may become a "UserValue" in the ...
Definition: AbstractPrimaryAuthenticationProvider.php:151
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\providerRevokeAccessForUser
providerRevokeAccessForUser( $username)
Revoke the user's credentials.This may cause the user to no longer exist for the provider,...
Definition: AbstractPrimaryAuthenticationProvider.php:82
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\postAccountLink
postAccountLink( $user, AuthenticationResponse $response)
Post-link callback.This will be called at the end of any account linking attempt, regardless of wheth...
Definition: AbstractPrimaryAuthenticationProvider.php:173
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:55
MediaWiki\Auth\PrimaryAuthenticationProvider
A primary authentication provider is responsible for associating the submitted authentication data wi...
Definition: PrimaryAuthenticationProvider.php:75
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22