MediaWiki master
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Auth;
8
18{
19
27 public function continuePrimaryAuthentication( array $reqs ) {
28 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
29 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
30 }
31
36 public function postAuthentication( $user, AuthenticationResponse $response ) {
37 }
38
43 public function testUserCanAuthenticate( $username ) {
44 // Assume it can authenticate if it exists
45 return $this->testUserExists( $username );
46 }
47
55 public function providerNormalizeUsername( $username ) {
56 $name = $this->userNameUtils->getCanonical( $username );
57 return $name === false ? null : $name;
58 }
59
66 public function providerRevokeAccessForUser( $username ) {
67 $reqs = $this->getAuthenticationRequests(
68 AuthManager::ACTION_REMOVE, [ 'username' => $username ]
69 );
70 foreach ( $reqs as $req ) {
71 $req->username = $username;
72 $req->action = AuthManager::ACTION_REMOVE;
74 }
75 }
76
81 public function providerAllowsPropertyChange( $property ) {
82 return true;
83 }
84
89 public function testForAccountCreation( $user, $creator, array $reqs ) {
90 return \StatusValue::newGood();
91 }
92
97 public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
98 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
99 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
100 }
101
106 public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ) {
107 return null;
108 }
109
114 public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
115 }
116
121 public function testUserForCreation( $user, $autocreate, array $options = [] ) {
122 return \StatusValue::newGood();
123 }
124
129 public function autoCreatedAccount( $user, $source ) {
130 }
131
136 public function beginPrimaryAccountLink( $user, array $reqs ) {
137 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
138 if ( $this->accountCreationType() === self::TYPE_LINK ) {
139 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
140 } else {
141 throw new \BadMethodCallException(
142 __METHOD__ . ' should not be called on a non-link provider.'
143 );
144 }
145 }
146
151 public function continuePrimaryAccountLink( $user, array $reqs ) {
152 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
153 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
154 }
155
160 public function postAccountLink( $user, AuthenticationResponse $response ) {
161 }
162
163}
A base class that implements some of the boilerplate for an AuthenticationProvider.
A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider.
beginPrimaryAccountLink( $user, array $reqs)
Start linking an account to an existing user.AuthenticationResponse Expected responses:PASS: The user...
postAuthentication( $user, AuthenticationResponse $response)
Post-login callback.This will be called at the end of any login attempt, regardless of whether this p...
testUserCanAuthenticate( $username)
Test whether the named user can authenticate with this provider.Should return true if the provider ha...
continuePrimaryAccountCreation( $user, $creator, array $reqs)
Continue an account creation flow.AuthenticationResponse Expected responses:PASS: The user may be cre...
testUserForCreation( $user, $autocreate, array $options=[])
Determine whether an account may be created.StatusValue
providerNormalizeUsername( $username)
Normalize the username for authentication.Any two inputs that would result in the same user being aut...
providerAllowsPropertyChange( $property)
Determine whether a property can change.AuthManager::allowsPropertyChange() bool
postAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.This will be called at the end of any account creation attempt,...
continuePrimaryAccountLink( $user, array $reqs)
Continue linking an account to an existing user.AuthenticationResponse Expected responses:PASS: The u...
finishAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.Called after the user is added to the database, before secondary authenticatio...
postAccountLink( $user, AuthenticationResponse $response)
Post-link callback.This will be called at the end of any account linking attempt, regardless of wheth...
providerRevokeAccessForUser( $username)
Revoke the user's credentials.This may cause the user to no longer exist for the provider,...
testForAccountCreation( $user, $creator, array $reqs)
Determine whether an account creation may begin.Called from AuthManager::beginAccountCreation()No nee...
const ACTION_REMOVE
Remove a user's credentials.
This is a value object to hold authentication response data.
Primary authentication providers associate submitted input data with a MediaWiki account.
getAuthenticationRequests( $action, array $options)
Return the applicable list of AuthenticationRequests.Possible values for $action depend on whether th...
providerChangeAuthenticationData(AuthenticationRequest $req)
Change or remove authentication data (e.g.
testUserExists( $username, $flags=IDBAccessObject::READ_NORMAL)
Test whether the named user exists.
accountCreationType()
Fetch the account-creation type.
$source