File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Original file line number Diff line number Diff line change @@ -10,17 +10,28 @@ steps in the process of authenticating the user have been taken successfully,
10
10
you can ask the security context if the authenticated user has access to a
11
11
certain action or resource of the application::
12
12
13
- use Symfony\Component\Security\SecurityContext;
13
+ use Symfony\Component\Security\Core\ SecurityContext;
14
14
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
15
+
16
+ // instance of Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface
17
+ $authenticationManager = ...;
15
18
16
- $securityContext = new SecurityContext();
19
+ // instance of Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
20
+ $accessDecisionManager = ...;
21
+
22
+ $securityContext = new SecurityContext($authenticationManager, $accessDecisionManager);
17
23
18
24
// ... authenticate the user
19
25
20
26
if (!$securityContext->isGranted('ROLE_ADMIN')) {
21
27
throw new AccessDeniedException();
22
28
}
23
29
30
+ .. note ::
31
+
32
+ Read the dedicated sections to learn more about :doc: `/components/security/authentication `
33
+ and :doc: `/components/security/authorization `.
34
+
24
35
.. _firewall :
25
36
26
37
A Firewall for HTTP Requests
You can’t perform that action at this time.
0 commit comments