Skip to content

Commit

Permalink
minor #6740 Add little comment indicating meaning of $firewall variab…
Browse files Browse the repository at this point in the history
…le (ruslan-fidesio, WouterJ)

This PR was merged into the 2.7 branch.

Discussion
----------

Add little comment indicating meaning of $firewall variable

Finishes #5981

Commits
-------

2a702c3 Improve comment
2545203 If context is defined, it is used instead of the firewall
  • Loading branch information
wouterj committed Jul 9, 2016
2 parents 812dbfd + 2a702c3 commit ea9574c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cookbook/testing/simulating_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ It could become an issue especially when ``form_login`` is used, since
it requires additional requests to fill in and submit the form.

One of the solutions is to configure your firewall to use ``http_basic`` in
the test environment as explained in
:doc:`/cookbook/testing/http_authentication`.
the test environment as explained in :doc:`/cookbook/testing/http_authentication`.
Another way would be to create a token yourself and store it in a session.
While doing this, you have to make sure that an appropriate cookie is sent
with a request. The following example demonstrates this technique::
Expand Down Expand Up @@ -45,7 +44,9 @@ with a request. The following example demonstrates this technique::
{
$session = $this->client->getContainer()->get('session');

// the firewall context (defaults to the firewall name)
$firewall = 'secured_area';

$token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_ADMIN'));
$session->set('_security_'.$firewall, serialize($token));
$session->save();
Expand Down

0 comments on commit ea9574c

Please sign in to comment.