changed priorities for kernel.request listeners
The Firewall is now executed after the Router. This was needed to have access to the locale and other request attributes that are set by the Router. This change implies that all Firewall specific URLs have proper (empty) routes like `/login_check` and `/logout`.
This commit is contained in:
parent
46e5fa5c87
commit
e3655f3a5c
@ -36,6 +36,9 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
||||
|
||||
### SecurityBundle
|
||||
|
||||
* [BC BREAK] The Firewall listener is now registered after the Router one.
|
||||
It means that specific Firewall URLs (like /login_check and /logout must now have proper
|
||||
route defined in your routing configuration)
|
||||
* added a validator for the user password
|
||||
|
||||
### SwiftmailerBundle
|
||||
|
@ -102,7 +102,7 @@
|
||||
|
||||
<!-- Firewall related services -->
|
||||
<service id="security.firewall" class="%security.firewall.class%">
|
||||
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="64" />
|
||||
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="8" />
|
||||
<argument type="service" id="security.firewall.map" />
|
||||
<argument type="service" id="event_dispatcher" />
|
||||
</service>
|
||||
|
@ -76,8 +76,11 @@ class LocaleListener implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
KernelEvents::REQUEST => array(
|
||||
array('onEarlyKernelRequest', 253),
|
||||
array('onKernelRequest', -1)
|
||||
// must be registered after the session listener
|
||||
array('onEarlyKernelRequest', 255),
|
||||
|
||||
// must be registered after the Router to have access to the _locale
|
||||
array('onKernelRequest', 16),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -130,7 +130,10 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
static public function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
// kernel.request must be registered as early as possible to not break
|
||||
// when an exception is thrown in any other kernel.request listener
|
||||
KernelEvents::REQUEST => array('onKernelRequest', 1024),
|
||||
|
||||
KernelEvents::RESPONSE => array('onKernelResponse', -100),
|
||||
KernelEvents::EXCEPTION => 'onKernelException',
|
||||
);
|
||||
|
@ -94,8 +94,9 @@ class RouterListener implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
KernelEvents::REQUEST => array(
|
||||
array('onEarlyKernelRequest', 255),
|
||||
array('onKernelRequest', 10)
|
||||
// the early method must be called before the Firewall to be able to generate URLs correctly
|
||||
array('onEarlyKernelRequest', 128),
|
||||
array('onKernelRequest', 32),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ class HttpUtils
|
||||
if ('/' === $path[0]) {
|
||||
$path = $request->getUriForPath($path);
|
||||
} elseif (0 !== strpos($path, 'http')) {
|
||||
$this->resetLocale($request);
|
||||
$path = $this->generateUrl($path, true);
|
||||
}
|
||||
|
||||
@ -70,7 +69,6 @@ class HttpUtils
|
||||
public function createRequest(Request $request, $path)
|
||||
{
|
||||
if ($path && '/' !== $path[0] && 0 !== strpos($path, 'http')) {
|
||||
$this->resetLocale($request);
|
||||
$path = $this->generateUrl($path, true);
|
||||
}
|
||||
if (0 !== strpos($path, 'http')) {
|
||||
@ -120,23 +118,6 @@ class HttpUtils
|
||||
return $path === $request->getPathInfo();
|
||||
}
|
||||
|
||||
// hack (don't have a better solution for now)
|
||||
private function resetLocale(Request $request)
|
||||
{
|
||||
$context = $this->router->getContext();
|
||||
if ($context->getParameter('_locale')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$parameters = $this->router->match($request->getPathInfo());
|
||||
|
||||
$context->setParameter('_locale', isset($parameters['_locale']) ? $parameters['_locale'] : $request->getLocale());
|
||||
} catch (\Exception $e) {
|
||||
// let's hope user doesn't use the locale in the path
|
||||
}
|
||||
}
|
||||
|
||||
private function generateUrl($route, $absolute = false)
|
||||
{
|
||||
if (null === $this->router) {
|
||||
|
Reference in New Issue
Block a user