Skip to content

Commit 6e50d47

Browse files
Merge branch '5.2' into 5.3
* 5.2: [Console] Escape synopsis output [SecurityBundle] Link UserProviderListener to correct firewall dispatcher [FrameworkBundle] fix KernelBrowser::loginUser with a stateless firewall Document null support in NumberToLocalizedStringTransformer Update loader’s directory when calling ContainerConfigurator::withPath
2 parents 9919637 + 3d5b20d commit 6e50d47

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

KernelBrowser.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,14 @@ public function loginUser($user, string $firewallContext = 'main'): self
122122

123123
$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
124124
$token->setAuthenticated(true);
125-
$session = $this->getContainer()->get('test.service_container')->get('session.factory')->createSession();
125+
$container = $this->kernel->getContainer()->get('test.service_container');
126+
$container->get('security.untracked_token_storage')->setToken($token);
127+
128+
if (!$container->has('session') && !$container->has('session_factory')) {
129+
return $this;
130+
}
131+
132+
$session = $container->get($container->has('session') ? 'session' : 'session_factory');
126133
$session->set('_security_'.$firewallContext, serialize($token));
127134
$session->save();
128135

Tests/Functional/SecurityTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function getUsers()
3838
yield ['the-username', ['ROLE_FOO'], null];
3939
yield ['the-username', ['ROLE_FOO'], 'main'];
4040
yield ['other-username', ['ROLE_FOO'], 'custom'];
41+
yield ['stateless-username', ['ROLE_FOO'], 'stateless'];
4142

4243
yield ['the-username', ['ROLE_FOO'], null];
4344
yield ['no-role-username', [], null];

Tests/Functional/app/Security/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ security:
2020
memory:
2121
users:
2222
other-username: { password: the-password, roles: ['ROLE_FOO'] }
23+
stateless:
24+
memory:
25+
users:
26+
stateless-username: { password: the-password, roles: ['ROLE_FOO'] }
2327

2428
firewalls:
2529
main:
@@ -32,6 +36,11 @@ security:
3236
form_login:
3337
check_path: /custom/login/check
3438
provider: custom
39+
stateless:
40+
pattern: ^/stateless
41+
stateless: true
42+
http_basic: ~
43+
provider: stateless
3544

3645
access_control:
3746
- { path: '^/main/user_profile$', roles: IS_AUTHENTICATED_FULLY }

Tests/Functional/app/Security/routing.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ security_profile:
55
security_custom_profile:
66
path: /custom/user_profile
77
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SecurityController::profileAction }
8+
9+
security_stateless_profile:
10+
path: /stateless/user_profile
11+
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SecurityController::profileAction }

0 commit comments

Comments
 (0)