Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / includes / auth / AuthenticationProvider.php
blob11f3e226ad43b455ef1adb05716bd9310156b716
1 <?php
2 /**
3 * 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
20 * @file
21 * @ingroup Auth
24 namespace MediaWiki\Auth;
26 use Config;
27 use Psr\Log\LoggerAwareInterface;
29 /**
30 * An AuthenticationProvider is used by AuthManager when authenticating users.
32 * This interface should not be implemented directly; use one of its children.
34 * Authentication providers can be registered via $wgAuthManagerAutoConfig.
36 * @ingroup Auth
37 * @since 1.27
39 interface AuthenticationProvider extends LoggerAwareInterface {
41 /**
42 * Set AuthManager
43 * @param AuthManager $manager
45 public function setManager( AuthManager $manager );
47 /**
48 * Set configuration
49 * @param Config $config
51 public function setConfig( Config $config );
53 /**
54 * Return a unique identifier for this instance
56 * This must be the same across requests. If multiple instances return the
57 * same ID, exceptions will be thrown from AuthManager.
59 * @return string
61 public function getUniqueId();
63 /**
64 * Return the applicable list of AuthenticationRequests
66 * Possible values for $action depend on whether the implementing class is
67 * also a PreAuthenticationProvider, PrimaryAuthenticationProvider, or
68 * SecondaryAuthenticationProvider.
69 * - ACTION_LOGIN: Valid for passing to beginAuthentication. Called on all
70 * providers.
71 * - ACTION_CREATE: Valid for passing to beginAccountCreation. Called on
72 * all providers.
73 * - ACTION_LINK: Valid for passing to beginAccountLink. Called on linking
74 * primary providers only.
75 * - ACTION_CHANGE: Valid for passing to AuthManager::changeAuthenticationData
76 * to change credentials. Called on primary and secondary providers.
77 * - ACTION_REMOVE: Valid for passing to AuthManager::changeAuthenticationData
78 * to remove credentials. Must work without additional user input (i.e.
79 * without calling loadFromSubmission). Called on primary and secondary
80 * providers.
82 * @see AuthManager::getAuthenticationRequests()
83 * @param string $action
84 * @param array $options Options are:
85 * - username: User name related to the action, or null/unset if anon.
86 * - ACTION_LOGIN: The currently logged-in user, if any.
87 * - ACTION_CREATE: The account creator, if non-anonymous.
88 * - ACTION_LINK: The local user being linked to.
89 * - ACTION_CHANGE: The user having data changed.
90 * - ACTION_REMOVE: The user having data removed.
91 * If you leave the username property of the returned requests empty, this
92 * will automatically be copied there (except for ACTION_CREATE where it
93 * wouldn't really make sense).
94 * @return AuthenticationRequest[]
96 public function getAuthenticationRequests( $action, array $options );