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 9328da9

Browse filesBrowse files
committed
Merge pull request symfony#2838 from xabbuh/issue-2837
fix security context example code
2 parents f6eec74 + 6501e95 commit 9328da9
Copy full SHA for 9328da9

File tree

Expand file treeCollapse file tree

1 file changed

+13
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-2
lines changed

‎components/security/firewall.rst

Copy file name to clipboardExpand all lines: components/security/firewall.rst
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,28 @@ steps in the process of authenticating the user have been taken successfully,
1010
you can ask the security context if the authenticated user has access to a
1111
certain action or resource of the application::
1212

13-
use Symfony\Component\Security\SecurityContext;
13+
use Symfony\Component\Security\Core\SecurityContext;
1414
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
15+
16+
// instance of Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface
17+
$authenticationManager = ...;
1518

16-
$securityContext = new SecurityContext();
19+
// instance of Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
20+
$accessDecisionManager = ...;
21+
22+
$securityContext = new SecurityContext($authenticationManager, $accessDecisionManager);
1723

1824
// ... authenticate the user
1925

2026
if (!$securityContext->isGranted('ROLE_ADMIN')) {
2127
throw new AccessDeniedException();
2228
}
2329

30+
.. note::
31+
32+
Read the dedicated sections to learn more about :doc:`/components/security/authentication`
33+
and :doc:`/components/security/authorization`.
34+
2435
.. _firewall:
2536

2637
A Firewall for HTTP Requests

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.