3 * Pre-authentication provider interface
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 namespace MediaWiki\Auth
;
30 * A pre-authentication provider is a check that must pass for authentication
33 * A PreAuthenticationProvider is used to supply arbitrary checks to be
34 * performed before the PrimaryAuthenticationProviders are consulted during the
35 * login process. Possible uses include checking that a per-IP throttle has not
36 * been reached or that a captcha has been solved.
41 interface PreAuthenticationProvider
extends AuthenticationProvider
{
44 * Determine whether an authentication may begin
46 * Called from AuthManager::beginAuthentication()
48 * @param AuthenticationRequest[] $reqs
51 public function testForAuthentication( array $reqs );
55 * @param User|null $user User that was attempted to be logged in, if known.
56 * This may become a "UserValue" in the future, or User may be refactored
58 * @param AuthenticationResponse $response Authentication response that will be returned
60 public function postAuthentication( $user, AuthenticationResponse
$response );
63 * Determine whether an account creation may begin
65 * Called from AuthManager::beginAccountCreation()
67 * @note No need to test if the account exists, AuthManager checks that
68 * @param User $user User being created (not added to the database yet).
69 * This may become a "UserValue" in the future, or User may be refactored
71 * @param User $creator User doing the creation. This may become a
72 * "UserValue" in the future, or User may be refactored into such.
73 * @param AuthenticationRequest[] $reqs
76 public function testForAccountCreation( $user, $creator, array $reqs );
79 * Determine whether an account may be created
81 * @param User $user User being created (not added to the database yet).
82 * This may become a "UserValue" in the future, or User may be refactored
84 * @param bool|string $autocreate False if this is not an auto-creation, or
85 * the source of the auto-creation passed to AuthManager::autoCreateUser().
86 * @param array $options
87 * - flags: (int) Bitfield of User:READ_* constants, default User::READ_NORMAL
88 * - creating: (bool) If false (or missing), this call is only testing if
89 * a user could be created. If set, this (non-autocreation) is for
90 * actually creating an account and will be followed by a call to
91 * testForAccountCreation(). In this case, the provider might return
92 * StatusValue::newGood() here and let the later call to
93 * testForAccountCreation() do a more thorough test.
96 public function testUserForCreation( $user, $autocreate, array $options = [] );
99 * Post-creation callback
100 * @param User $user User that was attempted to be created.
101 * This may become a "UserValue" in the future, or User may be refactored
103 * @param User $creator User doing the creation. This may become a
104 * "UserValue" in the future, or User may be refactored into such.
105 * @param AuthenticationResponse $response Authentication response that will be returned
107 public function postAccountCreation( $user, $creator, AuthenticationResponse
$response );
110 * Determine whether an account may linked to another authentication method
112 * @param User $user User being linked.
113 * This may become a "UserValue" in the future, or User may be refactored
115 * @return StatusValue
117 public function testForAccountLink( $user );
121 * @param User $user User that was attempted to be linked.
122 * This may become a "UserValue" in the future, or User may be refactored
124 * @param AuthenticationResponse $response Authentication response that will be returned
126 public function postAccountLink( $user, AuthenticationResponse
$response );