-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WIP] Do not expose routing 404 exception for protected route #11480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,10 @@ | |
|
||
namespace Symfony\Component\Security\Http; | ||
|
||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; | ||
use Symfony\Component\HttpKernel\Event\KernelEvent; | ||
use Symfony\Component\HttpKernel\Exception\HttpException; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | ||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
@@ -49,9 +51,9 @@ public function __construct(FirewallMapInterface $map, EventDispatcherInterface | |
/** | ||
* Handles security. | ||
* | ||
* @param GetResponseEvent $event An GetResponseEvent instance | ||
* @param KernelEvent $event An GetResponseEvent instance | ||
*/ | ||
public function onKernelRequest(GetResponseEvent $event) | ||
public function onKernelRequest(KernelEvent $event) | ||
{ | ||
if (!$event->isMasterRequest()) { | ||
return; | ||
|
@@ -84,6 +86,14 @@ public function onKernelFinishRequest(FinishRequestEvent $event) | |
} | ||
} | ||
|
||
public function onKernelException(GetResponseForExceptionEvent $event) | ||
{ | ||
$exception = $event->getException(); | ||
if ($exception instanceof HttpException && 404 === $exception->getStatusCode()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you might be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The framework normally uses the status codes directly afair. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, sorry for noise |
||
$this->onKernelRequest($event); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
@@ -92,6 +102,7 @@ public static function getSubscribedEvents() | |
return array( | ||
KernelEvents::REQUEST => array('onKernelRequest', 8), | ||
KernelEvents::FINISH_REQUEST => 'onKernelFinishRequest', | ||
KernelEvents::EXCEPTION => array('onKernelException', 900), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony code usually checks if the OS is Windows using this snippet:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied this from the test above this one, should I change it everywhere?