Merge "mediawiki.jqueryMsg: Implement `<nowiki>` support"
[lhc/web/wiklou.git] / includes / auth / PreAuthenticationProvider.php
1 <?php
2 /**
3 * Pre-authentication provider interface
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup Auth
22 */
23
24 namespace MediaWiki\Auth;
25
26 use StatusValue;
27 use User;
28
29 /**
30 * A pre-authentication provider is a check that must pass for authentication
31 * to proceed.
32 *
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.
37 *
38 * @ingroup Auth
39 * @since 1.27
40 */
41 interface PreAuthenticationProvider extends AuthenticationProvider {
42
43 /**
44 * Determine whether an authentication may begin
45 *
46 * Called from AuthManager::beginAuthentication()
47 *
48 * @param AuthenticationRequest[] $reqs
49 * @return StatusValue
50 */
51 public function testForAuthentication( array $reqs );
52
53 /**
54 * Post-login callback
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
57 * into such.
58 * @param AuthenticationResponse $response Authentication response that will be returned
59 */
60 public function postAuthentication( $user, AuthenticationResponse $response );
61
62 /**
63 * Determine whether an account creation may begin
64 *
65 * Called from AuthManager::beginAccountCreation()
66 *
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
70 * into such.
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
74 * @return StatusValue
75 */
76 public function testForAccountCreation( $user, $creator, array $reqs );
77
78 /**
79 * Determine whether an account may be created
80 *
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
83 * into such.
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 * @return StatusValue
87 */
88 public function testUserForCreation( $user, $autocreate );
89
90 /**
91 * Post-creation callback
92 * @param User $user User that was attempted to be created.
93 * This may become a "UserValue" in the future, or User may be refactored
94 * into such.
95 * @param User $creator User doing the creation. This may become a
96 * "UserValue" in the future, or User may be refactored into such.
97 * @param AuthenticationResponse $response Authentication response that will be returned
98 */
99 public function postAccountCreation( $user, $creator, AuthenticationResponse $response );
100
101 /**
102 * Determine whether an account may linked to another authentication method
103 *
104 * @param User $user User being linked.
105 * This may become a "UserValue" in the future, or User may be refactored
106 * into such.
107 * @return StatusValue
108 */
109 public function testForAccountLink( $user );
110
111 /**
112 * Post-link callback
113 * @param User $user User that was attempted to be linked.
114 * This may become a "UserValue" in the future, or User may be refactored
115 * into such.
116 * @param AuthenticationResponse $response Authentication response that will be returned
117 */
118 public function postAccountLink( $user, AuthenticationResponse $response );
119
120 }