MediaWiki REL1_34
AbstractPrimaryAuthenticationProvider.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
24use 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;
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}
A base class that implements some of the boilerplate for an AuthenticationProvider.
A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider.
continuePrimaryAuthentication(array $reqs)
Continue an authentication flow.
beginPrimaryAccountLink( $user, array $reqs)
Start linking an account to an existing user.
postAuthentication( $user, AuthenticationResponse $response)
Post-login callback.
testUserCanAuthenticate( $username)
Test whether the named user can authenticate with this provider.
continuePrimaryAccountCreation( $user, $creator, array $reqs)
Continue an account creation flow.
testUserForCreation( $user, $autocreate, array $options=[])
Determine whether an account may be created.
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.
postAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.
continuePrimaryAccountLink( $user, array $reqs)
Continue linking an account to an existing user.
finishAccountCreation( $user, $creator, AuthenticationResponse $response)
Post-creation callback.
postAccountLink( $user, AuthenticationResponse $response)
Post-link callback.
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.
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:51
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
Definition User.php:1180
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