MediaWiki REL1_35
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
24use User;
25
35{
36
44 public function continuePrimaryAuthentication( array $reqs ) {
45 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
46 }
47
52 public function postAuthentication( $user, AuthenticationResponse $response ) {
53 }
54
59 public function testUserCanAuthenticate( $username ) {
60 // Assume it can authenticate if it exists
61 return $this->testUserExists( $username );
62 }
63
71 public function providerNormalizeUsername( $username ) {
72 $name = User::getCanonicalName( $username );
73 return $name === false ? null : $name;
74 }
75
82 public function providerRevokeAccessForUser( $username ) {
83 $reqs = $this->getAuthenticationRequests(
84 AuthManager::ACTION_REMOVE, [ 'username' => $username ]
85 );
86 foreach ( $reqs as $req ) {
87 $req->username = $username;
88 $req->action = AuthManager::ACTION_REMOVE;
90 }
91 }
92
97 public function providerAllowsPropertyChange( $property ) {
98 return true;
99 }
100
105 public function testForAccountCreation( $user, $creator, array $reqs ) {
106 return \StatusValue::newGood();
107 }
108
113 public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
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 if ( $this->accountCreationType() === self::TYPE_LINK ) {
153 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
154 } else {
155 throw new \BadMethodCallException(
156 __METHOD__ . ' should not be called on a non-link provider.'
157 );
158 }
159 }
160
165 public function continuePrimaryAccountLink( $user, array $reqs ) {
166 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
167 }
168
173 public function postAccountLink( $user, AuthenticationResponse $response ) {
174 }
175
176}
A base class that implements some of the boilerplate for an AuthenticationProvider Stable to extend.
A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider.
autoCreatedAccount( $user, $source)
Post-auto-creation callback. Stable to override
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 Stable to override
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 Stable to override
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.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:60
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
Definition User.php:1130
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