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  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
44  }
45 
50  public function postAuthentication( $user, AuthenticationResponse $response ) {
51  }
52 
57  public function testUserCanAuthenticate( $username ) {
58  // Assume it can authenticate if it exists
59  return $this->testUserExists( $username );
60  }
61 
69  public function providerNormalizeUsername( $username ) {
70  $name = $this->userNameUtils->getCanonical( $username );
71  return $name === false ? null : $name;
72  }
73 
80  public function providerRevokeAccessForUser( $username ) {
81  $reqs = $this->getAuthenticationRequests(
82  AuthManager::ACTION_REMOVE, [ 'username' => $username ]
83  );
84  foreach ( $reqs as $req ) {
85  $req->username = $username;
86  $req->action = AuthManager::ACTION_REMOVE;
87  $this->providerChangeAuthenticationData( $req );
88  }
89  }
90 
95  public function providerAllowsPropertyChange( $property ) {
96  return true;
97  }
98 
103  public function testForAccountCreation( $user, $creator, array $reqs ) {
104  return \StatusValue::newGood();
105  }
106 
111  public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
112  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
113  }
114 
119  public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ) {
120  return null;
121  }
122 
127  public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
128  }
129 
134  public function testUserForCreation( $user, $autocreate, array $options = [] ) {
135  return \StatusValue::newGood();
136  }
137 
142  public function autoCreatedAccount( $user, $source ) {
143  }
144 
149  public function beginPrimaryAccountLink( $user, array $reqs ) {
150  if ( $this->accountCreationType() === self::TYPE_LINK ) {
151  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
152  } else {
153  throw new \BadMethodCallException(
154  __METHOD__ . ' should not be called on a non-link provider.'
155  );
156  }
157  }
158 
163  public function continuePrimaryAccountLink( $user, array $reqs ) {
164  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
165  }
166 
171  public function postAccountLink( $user, AuthenticationResponse $response ) {
172  }
173 
174 }
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:50
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:111
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\autoCreatedAccount
autoCreatedAccount( $user, $source)
Post-auto-creation callback.User being created (has been added to the database now)....
Definition: AbstractPrimaryAuthenticationProvider.php:142
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:163
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:103
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:127
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:69
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:57
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:120
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:119
MediaWiki\Auth\AbstractPrimaryAuthenticationProvider\providerAllowsPropertyChange
providerAllowsPropertyChange( $property)
Determine whether a property can change.AuthManager::allowsPropertyChange() bool
Definition: AbstractPrimaryAuthenticationProvider.php:95
$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:134
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:149
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:80
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:171
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