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
22 namespace MediaWiki\Auth
;
24 use MediaWiki\Config\Config
;
25 use MediaWiki\HookContainer\HookContainer
;
26 use MediaWiki\HookContainer\HookRunner
;
27 use MediaWiki\User\UserNameUtils
;
28 use Psr\Log\LoggerInterface
;
31 * A base class that implements some of the boilerplate for an AuthenticationProvider
36 abstract class AbstractAuthenticationProvider
implements AuthenticationProvider
{
37 protected LoggerInterface
$logger;
38 protected AuthManager
$manager;
39 protected Config
$config;
40 private HookContainer
$hookContainer;
41 private HookRunner
$hookRunner;
42 protected UserNameUtils
$userNameUtils;
45 * Initialise with dependencies of an AuthenticationProvider
48 * @internal In production code AuthManager will initialize the
49 * AbstractAuthenticationProvider, in tests
50 * AuthenticationProviderTestTrait must be used.
53 LoggerInterface
$logger,
55 HookContainer
$hookContainer,
57 UserNameUtils
$userNameUtils
59 $this->logger
= $logger;
60 $this->manager
= $manager;
61 $this->hookContainer
= $hookContainer;
62 $this->hookRunner
= new HookRunner( $hookContainer );
63 $this->config
= $config;
64 $this->userNameUtils
= $userNameUtils;
65 $this->postInitSetup();
69 * A provider can override this to do any necessary setup after init()
75 protected function postInitSetup() {
80 * @note Override this if it makes sense to support more than one instance
82 public function getUniqueId() {
88 * @return HookContainer
90 protected function getHookContainer(): HookContainer
{
91 return $this->hookContainer
;
95 * @internal This is for use by core only. Hook interfaces may be removed
100 protected function getHookRunner(): HookRunner
{
101 return $this->hookRunner
;