Move Blob class to Rdbms namespaces
[mediawiki.git] / includes / auth / AbstractPrimaryAuthenticationProvider.php
blobea3dfa3bd6db6e719945b256f3457c26ab3110ae
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup Auth
22 namespace MediaWiki\Auth;
24 use User;
26 /**
27 * A base class that implements some of the boilerplate for a PrimaryAuthenticationProvider
29 * @ingroup Auth
30 * @since 1.27
32 abstract class AbstractPrimaryAuthenticationProvider extends AbstractAuthenticationProvider
33 implements PrimaryAuthenticationProvider
36 public function continuePrimaryAuthentication( array $reqs ) {
37 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
40 public function postAuthentication( $user, AuthenticationResponse $response ) {
43 public function testUserCanAuthenticate( $username ) {
44 // Assume it can authenticate if it exists
45 return $this->testUserExists( $username );
48 /**
49 * @inheritdoc
50 * @note Reimplement this if you do anything other than
51 * User::getCanonicalName( $req->username ) to determine the user being
52 * authenticated.
54 public function providerNormalizeUsername( $username ) {
55 $name = User::getCanonicalName( $username );
56 return $name === false ? null : $name;
59 /**
60 * @inheritdoc
61 * @note Reimplement this if self::getAuthenticationRequests( AuthManager::ACTION_REMOVE )
62 * doesn't return requests that will revoke all access for the user.
64 public function providerRevokeAccessForUser( $username ) {
65 $reqs = $this->getAuthenticationRequests(
66 AuthManager::ACTION_REMOVE, [ 'username' => $username ]
68 foreach ( $reqs as $req ) {
69 $req->username = $username;
70 $req->action = AuthManager::ACTION_REMOVE;
71 $this->providerChangeAuthenticationData( $req );
75 public function providerAllowsPropertyChange( $property ) {
76 return true;
79 public function testForAccountCreation( $user, $creator, array $reqs ) {
80 return \StatusValue::newGood();
83 public function continuePrimaryAccountCreation( $user, $creator, array $reqs ) {
84 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
87 public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ) {
88 return null;
91 public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
94 public function testUserForCreation( $user, $autocreate, array $options = [] ) {
95 return \StatusValue::newGood();
98 public function autoCreatedAccount( $user, $source ) {
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.'
111 public function continuePrimaryAccountLink( $user, array $reqs ) {
112 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
115 public function postAccountLink( $user, AuthenticationResponse $response ) {