Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eae4a3c

Browse filesBrowse files
committed
Reword
1 parent d430972 commit eae4a3c
Copy full SHA for eae4a3c

File tree

1 file changed

+4
-21
lines changed
Filter options

1 file changed

+4
-21
lines changed

‎testing/http_authentication.rst

Copy file name to clipboardExpand all lines: testing/http_authentication.rst
+4-21Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.