MediaWiki REL1_39
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1<?php
22namespace 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;
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}
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.
A primary authentication provider is responsible for associating the submitted authentication data wi...
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=User::READ_NORMAL)
Test whether the named user exists.
accountCreationType()
Fetch the account-creation type.
$source