8000 Reword · symfony/symfony-docs@eae4a3c · GitHub
[go: up one dir, main page]

Skip to content

Commit eae4a3c

Browse files
committed
Reword
1 parent d430972 commit eae4a3c

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

testing/http_authentication.rst

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,14 @@ needs::
109109
$this->assertSame('Admin Dashboard', $crawler->filter('h1')->text());
110110
}
111111

112-
private function logIn()
113-
{
114-
$session = $this->client->getContainer()->get('session');
115-
116-
// the firewall context defaults to the firewall name
117-
$firewallContext = 'secured_area';
118-
119-
$token = new UsernamePasswordToken('admin', null, $firewallContext, array('ROLE_ADMIN'));
120-
$session->set('_security_'.$firewallContext, serialize($token));
121-
$session->save();
122-
123-
$cookie = new Cookie($session->getName(), $session->getId());
124-
$this->client->getCookieJar()->set($cookie);
125-
}
126-
}
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-
132112
private function logIn()
133113
{
134114
$session = $this->client->getContainer()->get('session');
135115

136116
$firewallName = 'secure_area';
137-
$firewallContext = 'firewall_context';
117+
// if you don't define multiple connected firewalls, the context defaults to the firewall name
118+
// See https://symfony.com/doc/current/reference/configuration/security.html#firewall-context
119+
$firewallContext = 'secured_area';
138120

139121
$token = new UsernamePasswordToken('admin', null, $firewallName, array('ROLE_ADMIN'));
140122
$session->set('_security_'.$firewallContext, serialize($token));
@@ -143,3 +125,4 @@ using the firewall context name::
143125
$cookie = new Cookie($session->getName(), $session->getId());
144126
$this->client->getCookieJar()->set($cookie);
145127
}
128+
}

0 commit comments

Comments
 (0)
0