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 /** @var LoggerInterface */
40 /** @var AuthManager */
46 /** @var HookContainer */
47 private $hookContainer;
49 /** @var HookRunner */
52 /** @var UserNameUtils */
53 protected $userNameUtils;
56 * Initialise with dependencies of an AuthenticationProvider
59 * @internal In production code AuthManager will initialize the
60 * AbstractAuthenticationProvider, in tests
61 * AuthenticationProviderTestTrait must be used.
63 * @param LoggerInterface $logger
64 * @param AuthManager $manager
65 * @param HookContainer $hookContainer
66 * @param Config $config
67 * @param UserNameUtils $userNameUtils
70 LoggerInterface
$logger,
72 HookContainer
$hookContainer,
74 UserNameUtils
$userNameUtils
76 $this->logger
= $logger;
77 $this->manager
= $manager;
78 $this->hookContainer
= $hookContainer;
79 $this->hookRunner
= new HookRunner( $hookContainer );
80 $this->config
= $config;
81 $this->userNameUtils
= $userNameUtils;
82 $this->postInitSetup();
86 * A provider can override this to do any necessary setup after init()
92 protected function postInitSetup() {
97 * @note Override this if it makes sense to support more than one instance
99 public function getUniqueId() {
100 return static::class;
105 * @return HookContainer
107 protected function getHookContainer(): HookContainer
{
108 return $this->hookContainer
;
112 * @internal This is for use by core only. Hook interfaces may be removed
117 protected function getHookRunner(): HookRunner
{
118 return $this->hookRunner
;