vendor/symfony/security-http/EntryPoint/BasicAuthenticationEntryPoint.php line 19

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Http\EntryPoint;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  14. use Symfony\Component\Security\Http\Authenticator\HttpBasicAuthenticator;
  15. trigger_deprecation('symfony/security-http', '5.4', 'The "%s" class is deprecated, use the new security system with "%s" instead.', BasicAuthenticationEntryPoint::class, HttpBasicAuthenticator::class);
  16. /**
  17. * BasicAuthenticationEntryPoint starts an HTTP Basic authentication.
  18. *
  19. * @author Fabien Potencier <fabien@symfony.com>
  20. *
  21. * @deprecated since Symfony 5.4
  22. */
  23. class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface
  24. {
  25. private $realmName;
  26. public function __construct(string $realmName)
  27. {
  28. $this->realmName = $realmName;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function start(Request $request, ?AuthenticationException $authException = null)
  34. {
  35. $response = new Response();
  36. $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName));
  37. $response->setStatusCode(401);
  38. return $response;
  39. }
  40. }