vendor/symfony/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php
equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\Security\Http\EntryPoint; |
|
13 |
|
14 use Symfony\Component\Security\Core\Exception\AuthenticationException; |
|
15 use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; |
|
16 use Symfony\Component\HttpFoundation\Response; |
|
17 use Symfony\Component\HttpFoundation\Request; |
|
18 |
|
19 /** |
|
20 * BasicAuthenticationEntryPoint starts an HTTP Basic authentication. |
|
21 * |
|
22 * @author Fabien Potencier <fabien@symfony.com> |
|
23 */ |
|
24 class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface |
|
25 { |
|
26 private $realmName; |
|
27 |
|
28 public function __construct($realmName) |
|
29 { |
|
30 $this->realmName = $realmName; |
|
31 } |
|
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, $authException ? $authException->getMessage() : null); |
|
38 |
|
39 return $response; |
|
40 } |
|
41 } |