Skip to content

Commit

Permalink
Always store referrer for backend _scope
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed May 18, 2024
1 parent 5c6558a commit cadf65a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core-bundle/src/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_token_check" = true})
* @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_token_check" = true, "_store_referrer" = false})
*
* @internal
*/
class BackendController extends AbstractController
{
/**
* @Route("", name="contao_backend")
* @Route("", name="contao_backend", defaults={"_store_referrer" = true})
*/
public function mainAction(): Response
{
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/Controller/BackendPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* requested front end page while ensuring that the /preview.php entry point is
* used. When requested, the front end user gets authenticated.
*
* @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_allow_preview" = true})
* @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_allow_preview" = true, "_store_referrer" = false})
*/
class BackendPreviewController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* b) Provide the member usernames for the datalist
* c) Process the switch action (i.e. log in a specific front end user).
*
* @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_allow_preview" = true})
* @Route(path="%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_allow_preview" = true, "_store_referrer" = false})
*/
class BackendPreviewSwitchController
{
Expand Down
3 changes: 2 additions & 1 deletion core-bundle/src/EventListener/StoreRefererListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private function canModifyBackendSession(Request $request): bool
&& !$request->query->has('token')
&& !$request->query->has('state')
&& 'feRedirect' !== $request->query->get('do')
&& 'contao_backend' === $request->attributes->get('_route')
&& 'backend' === $request->attributes->get('_scope')
&& false !== $request->attributes->get('_store_referrer')
&& !$request->isXmlHttpRequest();
}

Expand Down
2 changes: 2 additions & 0 deletions core-bundle/src/Resources/config/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contao_backend_redirect:
defaults:
_scope: backend
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
_store_referrer: false
route: contao_backend
permanent: true

Expand All @@ -20,6 +21,7 @@ contao_backend_fallback:
defaults:
_scope: backend
_controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
_store_referrer: false
template: '@ContaoCore\Error\backend.html.twig'
context:
template: '@ContaoCore\Error\backend.html.twig'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public function testDoesNotStoreTheRefererIfTheBackEndSessionCannotBeModified():
$request = new Request();
$request->setSession($session);
$request->attributes->set('_scope', ContaoCoreBundle::SCOPE_BACKEND);
$request->attributes->set('_store_referrer', false);

$listener = $this->getListener($this->createMock(User::class));
$listener($this->getResponseEvent($request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_token_check" = true})
* @Route("%contao.backend.route_prefix%", defaults={"_scope" = "backend", "_token_check" = true, "_store_referrer" = false})
*
* @internal
*/
Expand Down

0 comments on commit cadf65a

Please sign in to comment.