Skip to content

Commit 47baed9

Browse files
committed
[SecurityBundle] Revert adding _stateless attribute to the request when firewall is stateless and the attribute is not already set
1 parent 56d753c commit 47baed9

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,7 @@ private function getFirewallContext(Request $request): ?FirewallContext
7272
if (null === $requestMatcher || $requestMatcher->matches($request)) {
7373
$request->attributes->set('_firewall_context', $contextId);
7474

75-
/** @var FirewallContext $context */
76-
$context = $this->container->get($contextId);
77-
78-
if ($context->getConfig()?->isStateless() && !$request->attributes->has('_stateless')) {
79-
$request->attributes->set('_stateless', true);
80-
}
81-
82-
return $context;
75+
return $this->container->get($contextId);
8376
}
8477
}
8578

src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testGetListeners(Request $request, bool $expectedState)
6363
$firewallContext = $this->createMock(FirewallContext::class);
6464

6565
$firewallConfig = new FirewallConfig('main', 'user_checker', null, true, true);
66-
$firewallContext->expects($this->exactly(2))->method('getConfig')->willReturn($firewallConfig);
66+
$firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig);
6767

6868
$listener = function () {};
6969
$firewallContext->expects($this->once())->method('getListeners')->willReturn([$listener]);
@@ -93,7 +93,7 @@ public function testGetListeners(Request $request, bool $expectedState)
9393

9494
public static function providesStatefulStatelessRequests(): \Generator
9595
{
96-
yield [new Request(), true];
96+
yield [new Request(), false];
9797
yield [new Request(attributes: ['_stateless' => false]), false];
9898
yield [new Request(attributes: ['_stateless' => true]), true];
9999
}

0 commit comments

Comments
 (0)