summaryrefslogtreecommitdiffstats
path: root/Http/EntryPoint/FormAuthenticationEntryPoint.php
diff options
context:
space:
mode:
Diffstat (limited to 'Http/EntryPoint/FormAuthenticationEntryPoint.php')
-rw-r--r--Http/EntryPoint/FormAuthenticationEntryPoint.php14
1 files changed, 9 insertions, 5 deletions
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);
}
}