a707bbf090
* 2.8: (22 commits) Tests and fix for issue in array model data in EntityType field with multiple=true [Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible removed useless PHPDoc [Form] Fix FormInterface::submit() annotation PdoSessionHandler: fix advisory lock for pgsql when session.sid_bits_per_character > 4 HttpCache does not consider ESI resources in HEAD requests Fix translation for "This field was not expected" [Routing] Enhance Route(Collection) docblocks Added improvement for accuracy in MoneyToLocalizedStringTransformer. Removed unused private property Use correct verb form in the pull request template Use PHP_MAXPATHLEN in Filesystem. Added null as explicit return type (?TokenInterface) [FrameworkBundle] Fix Routing\DelegatingLoader Render all line breaks according to the exception message [Form] Fix phpdoc [DI] remove confusing code [Form] Fixed GroupSequence with "constraints" option [Validator] Clarify UUID validator behavior [Filesystem] Fixed makePathRelative ...
64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\Security\Http\EntryPoint;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
|
use Symfony\Component\Security\Http\HttpUtils;
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
|
|
/**
|
|
* FormAuthenticationEntryPoint starts an authentication via a login form.
|
|
*
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
|
*/
|
|
class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
|
|
{
|
|
private $loginPath;
|
|
private $useForward;
|
|
private $httpKernel;
|
|
private $httpUtils;
|
|
|
|
/**
|
|
* @param HttpKernelInterface $kernel
|
|
* @param HttpUtils $httpUtils An HttpUtils instance
|
|
* @param string $loginPath The path to the login form
|
|
* @param bool $useForward Whether to forward or redirect to the login form
|
|
*/
|
|
public function __construct(HttpKernelInterface $kernel, HttpUtils $httpUtils, $loginPath, $useForward = false)
|
|
{
|
|
$this->httpKernel = $kernel;
|
|
$this->httpUtils = $httpUtils;
|
|
$this->loginPath = $loginPath;
|
|
$this->useForward = (bool) $useForward;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function start(Request $request, AuthenticationException $authException = null)
|
|
{
|
|
if ($this->useForward) {
|
|
$subRequest = $this->httpUtils->createRequest($request, $this->loginPath);
|
|
|
|
$response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
|
|
if (200 === $response->getStatusCode()) {
|
|
$response->setStatusCode(401);
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
|
|
return $this->httpUtils->createRedirectResponse($request, $this->loginPath);
|
|
}
|
|
}
|