diff options
author | realmfoo <konstantin.leboev@gmail.com> | 2011-08-10 10:59:19 +0400 |
---|---|---|
committer | realmfoo <konstantin.leboev@gmail.com> | 2011-08-10 10:59:19 +0400 |
commit | b33e8d2376f20761911faa654d85790d61a29019 (patch) | |
tree | 91ef528a24e416523bb25859a702d8d859a0e2af /Http/EntryPoint | |
parent | 111f1e758a0919556c2c2fdd8fd8779303113f30 (diff) | |
parent | 77b520411cafe3f32f1f52d27dd806ee6110504d (diff) | |
download | symfony-security-b33e8d2376f20761911faa654d85790d61a29019.zip symfony-security-b33e8d2376f20761911faa654d85790d61a29019.tar.gz symfony-security-b33e8d2376f20761911faa654d85790d61a29019.tar.bz2 |
merge from master
Diffstat (limited to 'Http/EntryPoint')
4 files changed, 12 insertions, 8 deletions
diff --git a/Http/EntryPoint/BasicAuthenticationEntryPoint.php b/Http/EntryPoint/BasicAuthenticationEntryPoint.php index 4f13c90..6ba3872 100644 --- a/Http/EntryPoint/BasicAuthenticationEntryPoint.php +++ b/Http/EntryPoint/BasicAuthenticationEntryPoint.php @@ -34,7 +34,7 @@ class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface { $response = new Response(); $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName)); - $response->setStatusCode(401, $authException->getMessage()); + $response->setStatusCode(401, $authException ? $authException->getMessage() : null); return $response; } diff --git a/Http/EntryPoint/DigestAuthenticationEntryPoint.php b/Http/EntryPoint/DigestAuthenticationEntryPoint.php index e422cb0..66f1e42 100644 --- a/Http/EntryPoint/DigestAuthenticationEntryPoint.php +++ b/Http/EntryPoint/DigestAuthenticationEntryPoint.php @@ -57,7 +57,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac $response = new Response(); $response->headers->set('WWW-Authenticate', $authenticateHeader); - $response->setStatusCode(401, $authException->getMessage()); + $response->setStatusCode(401, $authException ? $authException->getMessage() : null); return $response; } diff --git a/Http/EntryPoint/FormAuthenticationEntryPoint.php b/Http/EntryPoint/FormAuthenticationEntryPoint.php index 12f077f..2170e9e 100644 --- a/Http/EntryPoint/FormAuthenticationEntryPoint.php +++ b/Http/EntryPoint/FormAuthenticationEntryPoint.php @@ -12,10 +12,9 @@ namespace Symfony\Component\Security\Http\EntryPoint; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; +use Symfony\Component\Security\Http\HttpUtils; use Symfony\Component\HttpKernel\HttpKernelInterface; /** @@ -28,17 +27,20 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface private $loginPath; private $useForward; private $httpKernel; + private $httpUtils; /** * Constructor * * @param HttpKernelInterface $kernel + * @param HttpUtils $httpUtils An HttpUtils instance * @param string $loginPath The path to the login form * @param Boolean $useForward Whether to forward or redirect to the login form */ - public function __construct(HttpKernelInterface $kernel, $loginPath, $useForward = false) + public function __construct(HttpKernelInterface $kernel, HttpUtils $httpUtils, $loginPath, $useForward = false) { $this->httpKernel = $kernel; + $this->httpUtils = $httpUtils; $this->loginPath = $loginPath; $this->useForward = (Boolean) $useForward; } @@ -49,9 +51,11 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface public function start(Request $request, AuthenticationException $authException = null) { if ($this->useForward) { - return $this->httpKernel->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST); + $subRequest = $this->httpUtils->createRequest($request, $this->loginPath); + + return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } - return new RedirectResponse(0 !== strpos($this->loginPath, 'http') ? $request->getUriForPath($this->loginPath) : $this->loginPath, 302); + return $this->httpUtils->createRedirectResponse($request, $this->loginPath); } } diff --git a/Http/EntryPoint/RetryAuthenticationEntryPoint.php b/Http/EntryPoint/RetryAuthenticationEntryPoint.php index cb549e6..12ba538 100644 --- a/Http/EntryPoint/RetryAuthenticationEntryPoint.php +++ b/Http/EntryPoint/RetryAuthenticationEntryPoint.php @@ -40,7 +40,7 @@ class RetryAuthenticationEntryPoint implements AuthenticationEntryPointInterface $scheme = $request->isSecure() ? 'http' : 'https'; if ('http' === $scheme && 80 != $this->httpPort) { $port = ':'.$this->httpPort; - } elseif ('https' === $scheme && 443 != $this->httpPort) { + } elseif ('https' === $scheme && 443 != $this->httpsPort) { $port = ':'.$this->httpsPort; } else { $port = ''; |