8000 Added documentation about authentication for multiple firewalls under… · symfony/symfony-docs@d430972 · GitHub
[go: up one dir, main page]

Skip to content

Commit d430972

Browse files
Valantis Koutsoumposjaviereguiluz
Valantis Koutsoumpos
authored andcommitted
Added documentation about authentication for multiple firewalls under the same firewall context
1 parent 6b0549a commit d430972

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

testing/http_authentication.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,22 @@ needs::
124124
$this->client->getCookieJar()->set($cookie);
125125
}
126126
}
127+
128+
If your setup contains multiple firewalls sharing the same firewall context, you need to generate the
129+
*authentication token* by using one of the firewall names as provider key and set the security session
130+
using the firewall context name::
131+
132+
private function logIn()
133+
{
134+
$session = $this->client->getContainer()->get('session');
135+
136+
$firewallName = 'secure_area';
137+
$firewallContext = 'firewall_context';
138+
139+
$token = new UsernamePasswordToken('admin', null, $firewallName, array('ROLE_ADMIN'));
140+
$session->set('_security_'.$firewallContext, serialize($token));
141+
$session->save();
142+
143+
$cookie = new Cookie($session->getName(), $session->getId());
144+
$this->client->getCookieJar()->set($cookie);
145+
}

0 commit comments

Comments
 (0)
0