summaryrefslogtreecommitdiffstats
path: root/Http/EntryPoint
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2011-06-20 07:08:46 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2011-06-22 14:47:19 +0200
commit100bc023abb4c1908b0d468dda6869e47494e355 (patch)
tree2780db9d5ab963bd0c8216622c647771f343fc64 /Http/EntryPoint
parent2ebfd97612d3d5ef4fc6f632b27a242eed8a1f0f (diff)
downloadsymfony-security-100bc023abb4c1908b0d468dda6869e47494e355.zip
symfony-security-100bc023abb4c1908b0d468dda6869e47494e355.tar.gz
symfony-security-100bc023abb4c1908b0d468dda6869e47494e355.tar.bz2
[Security] added an HttpUtils class to manage logic related to Requests and Responses
This change removes the need for the {_locale} hack. Now, all paths in the Security component can be: * An absolute path (/login) * An absolute URL (http://symfony.com/login) * A route name (login) So, if you want to use a path that includes a global parameter (like _locale), use a route instead of a path.
Diffstat (limited to 'Http/EntryPoint')
-rw-r--r--Http/EntryPoint/FormAuthenticationEntryPoint.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/Http/EntryPoint/FormAuthenticationEntryPoint.php b/Http/EntryPoint/FormAuthenticationEntryPoint.php
index 6301606..1a35784 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;
}
@@ -48,13 +50,12 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
*/
public function start(Request $request, AuthenticationException $authException = null)
{
- $path = str_replace('{_locale}', $request->getSession()->getLocale(), $this->loginPath);
if ($this->useForward) {
- $subRequest = Request::create($path, 'get', array(), $request->cookies->all(), array(), $request->server->all());
+ $path = $this->httpUtils->createRequest($request, $this->loginPath);
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
- return new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
+ return $this->httpUtils->createRedirectResponse($request, $this->loginPath);
}
}