MediaWiki  master
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
33 {
34 
42  public function continuePrimaryAuthentication( array $reqs ) {
43  // @phan-suppress-previous-line PhanPluginNeverReturnMethod
44  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
45  }
46 
51  public function postAuthentication( $user, AuthenticationResponse $response ) {
52  }
53 
58  public function testUserCanAuthenticate( $username ) {
59  // Assume it can authenticate if it exists
60  return $this->testUserExists( $username );
61  }
62 
70  public function providerNormalizeUsername( $username ) {
71  $name = $this->userNameUtils->getCanonical( $username );
72  return $name === false ? null : $name;
73  }
74 
81  public function providerRevokeAccessForUser( $username ) {
82  $reqs = $this->getAuthenticationRequests(
83  AuthManager::ACTION_REMOVE, [ 'username' => $username ]
84  );
85  foreach ( $reqs as $req ) {
86  $req->username = $username;
87  $req->action = AuthManager::ACTION_REMOVE;
88  $this->providerChangeAuthenticationData( $req );
89  }
90  }
91 
96  public function providerAllowsPropertyChange( $property ) {
97  return true;
98  }
99 
104  public function testForAccountCreation( $user, $creator, array $reqs ) {
105  return \StatusValue::newGood();
106  }
107 
112  public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
113  // @phan-suppress-previous-line PhanPluginNeverReturnMethod
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  // @phan-suppress-previous-line PhanPluginNeverReturnMethod
153  if ( $this->accountCreationType() === self::TYPE_LINK ) {
154  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
155  } else {
156  throw new \BadMethodCallException(
157  __METHOD__ . ' should not be called on a non-link provider.'
158  );
159  }
160  }
161 
166  public function continuePrimaryAccountLink( $user, array $reqs ) {
167  // @phan-suppress-previous-line PhanPluginNeverReturnMethod
168  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
169  }
170 
175  public function postAccountLink( $user, AuthenticationResponse $response ) {
176  }
177 
178 }
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:51
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:112
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:166
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:104
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)
Definition: AbstractPrimaryAuthenticationProvider.php:42
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:70
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:58
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:124
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
Definition: AbstractPrimaryAuthenticationProvider.php:96
$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.
Definition: AbstractAuthenticationProvider.php:36
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider
A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider.
Definition: AbstractPrimaryAuthenticationProvider.php:33
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:81
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:175
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