/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php
49 строк
2 KB
Nicolas Grekas
Merge branch '6.4' into 7.2
11 фев 2025, 19:46
11 фев 2025, 19:46
82a12a4
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Authenticator; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\User\UserProviderInterface; /** * This authenticator authenticates a remote user. * * @author Wouter de Jong <wouter@wouterj.nl> * @author Fabien Potencier <fabien@symfony.com> * @author Maxime Douailin <maxime.douailin@gmail.com> * * @internal */ final class RemoteUserAuthenticator extends AbstractPreAuthenticatedAuthenticator { public function __construct( UserProviderInterface $userProvider, TokenStorageInterface $tokenStorage, string $firewallName, private string $userKey = 'REMOTE_USER', ?LoggerInterface $logger = null, ) { parent::__construct($userProvider, $tokenStorage, $firewallName, $logger); } protected function extractUsername(Request $request): ?string { if (!$request->server->has($this->userKey)) { throw new BadCredentialsException(\sprintf('User key was not found: "%s".', $this->userKey)); } return $request->server->get($this->userKey) ?: null; } }