Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad9faa2

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

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Allow configuring the secret used to sign login links
8+
* Revert adding `_stateless` attribute to the request when firewall is stateless and the attribute is not already set
89

910
7.1
1011
---

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

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

66-
/** @var FirewallContext $context */
67-
$context = $this->container->get($contextId);
68-
69-
if ($context->getConfig()?->isStateless() && !$request->attributes->has('_stateless')) {
70-
$request->attributes->set('_stateless', true);
71-
}
72-
73-
return $context;
66+
return $this->container->get($contextId);
7467
}
7568
}
7669

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)