MediaWiki  master
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
24 use User;
25 
34 {
35 
36  public function continuePrimaryAuthentication( array $reqs ) {
37  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
38  }
39 
41  }
42 
43  public function testUserCanAuthenticate( $username ) {
44  // Assume it can authenticate if it exists
45  return $this->testUserExists( $username );
46  }
47 
54  public function providerNormalizeUsername( $username ) {
55  $name = User::getCanonicalName( $username );
56  return $name === false ? null : $name;
57  }
58 
64  public function providerRevokeAccessForUser( $username ) {
65  $reqs = $this->getAuthenticationRequests(
66  AuthManager::ACTION_REMOVE, [ 'username' => $username ]
67  );
68  foreach ( $reqs as $req ) {
69  $req->username = $username;
70  $req->action = AuthManager::ACTION_REMOVE;
71  $this->providerChangeAuthenticationData( $req );
72  }
73  }
74 
75  public function providerAllowsPropertyChange( $property ) {
76  return true;
77  }
78 
79  public function testForAccountCreation( $user, $creator, array $reqs ) {
80  return \StatusValue::newGood();
81  }
82 
83  public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
84  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
85  }
86 
87  public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ) {
88  return null;
89  }
90 
91  public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
92  }
93 
94  public function testUserForCreation( $user, $autocreate, array $options = [] ) {
95  return \StatusValue::newGood();
96  }
97 
98  public function autoCreatedAccount( $user, $source ) {
99  }
100 
101  public function beginPrimaryAccountLink( $user, array $reqs ) {
102  if ( $this->accountCreationType() === self::TYPE_LINK ) {
103  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
104  } else {
105  throw new \BadMethodCallException(
106  __METHOD__ . ' should not be called on a non-link provider.'
107  );
108  }
109  }
110 
111  public function continuePrimaryAccountLink( $user, array $reqs ) {
112  throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
113  }
114 
116  }
117 
118 }
$response
testForAccountCreation( $user, $creator, array $reqs)
Determine whether an account creation may begin.
finishAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.
getAuthenticationRequests( $action, array $options)
Return the applicable list of AuthenticationRequests.Possible values for $action depend on whether th...
$source
continuePrimaryAccountLink( $user, array $reqs)
Continue linking an account to an existing user.
providerAllowsPropertyChange( $property)
Determine whether a property can change.
This is a value object to hold authentication response data.
providerRevokeAccessForUser( $username)
Revoke the user&#39;s credentials.This may cause the user to no longer exist for the provider, or the user may continue to exist in a "disabled" state.The intention is that the named account will never again be usable for normal login (i.e. there is no way to undo the revocation of access).
A primary authentication provider is responsible for associating the submitted authentication data wi...
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Definition: User.php:51
postAccountLink( $user, AuthenticationResponse $response)
Post-link callback.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid...
Definition: User.php:1139
postAuthentication( $user, AuthenticationResponse $response)
Post-login callback.
continuePrimaryAccountCreation( $user, $creator, array $reqs)
Continue an account creation flow.
testUserForCreation( $user, $autocreate, array $options=[])
Determine whether an account may be created.
testUserCanAuthenticate( $username)
Test whether the named user can authenticate with this provider.
providerNormalizeUsername( $username)
Normalize the username for authentication.Any two inputs that would result in the same user being aut...
A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider.
beginPrimaryAccountLink( $user, array $reqs)
Start linking an account to an existing user.
A base class that implements some of the boilerplate for an AuthenticationProvider.
const ACTION_REMOVE
Remove a user&#39;s credentials.
accountCreationType()
Fetch the account-creation type.
continuePrimaryAuthentication(array $reqs)
Continue an authentication flow.
postAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.
providerChangeAuthenticationData(AuthenticationRequest $req)
Change or remove authentication data (e.g.
testUserExists( $username, $flags=User::READ_NORMAL)
Test whether the named user exists.