Merge "API: Avoid duplicate IDs in API documentation"
[lhc/web/wiklou.git] / includes / auth / AuthenticationProvider.php
1 <?php
2 /**
3 * 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 Config;
27 use Psr\Log\LoggerAwareInterface;
28
29 /**
30 * An AuthenticationProvider is used by AuthManager when authenticating users.
31 * @ingroup Auth
32 * @since 1.27
33 */
34 interface AuthenticationProvider extends LoggerAwareInterface {
35
36 /**
37 * Set AuthManager
38 * @param AuthManager $manager
39 */
40 public function setManager( AuthManager $manager );
41
42 /**
43 * Set configuration
44 * @param Config $config
45 */
46 public function setConfig( Config $config );
47
48 /**
49 * Return a unique identifier for this instance
50 *
51 * This must be the same across requests. If multiple instances return the
52 * same ID, exceptions will be thrown from AuthManager.
53 *
54 * @return string
55 */
56 public function getUniqueId();
57
58 /**
59 * Return the applicable list of AuthenticationRequests
60 *
61 * Possible values for $action depend on whether the implementing class is
62 * also a PreAuthenticationProvider, PrimaryAuthenticationProvider, or
63 * SecondaryAuthenticationProvider.
64 * - ACTION_LOGIN: Valid for passing to beginAuthentication. Called on all
65 * providers.
66 * - ACTION_CREATE: Valid for passing to beginAccountCreation. Called on
67 * all providers.
68 * - ACTION_LINK: Valid for passing to beginAccountLink. Called on linking
69 * primary providers only.
70 * - ACTION_CHANGE: Valid for passing to AuthManager::changeAuthenticationData
71 * to change credentials. Called on primary and secondary providers.
72 * - ACTION_REMOVE: Valid for passing to AuthManager::changeAuthenticationData
73 * to remove credentials. Must work without additional user input (i.e.
74 * without calling loadFromSubmission). Called on primary and secondary
75 * providers.
76 *
77 * @see AuthManager::getAuthenticationRequests()
78 * @param string $action
79 * @param array $options Options are:
80 * - username: User name related to the action, or null/unset if anon.
81 * - ACTION_LOGIN: The currently logged-in user, if any.
82 * - ACTION_CREATE: The account creator, if non-anonymous.
83 * - ACTION_LINK: The local user being linked to.
84 * - ACTION_CHANGE: The user having data changed.
85 * - ACTION_REMOVE: The user having data removed.
86 * This does not need to be copied into the returned requests, you only
87 * need to pay attention to it if the set of requests differs based on
88 * the user.
89 * @return AuthenticationRequest[]
90 */
91 public function getAuthenticationRequests( $action, array $options );
92
93 }