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 d33820a

Browse filesBrowse files
author
Iltar van der Berg
committed
[Security] Removed deprecated example about SecurityContext
1 parent 8131844 commit d33820a
Copy full SHA for d33820a

File tree

Expand file treeCollapse file tree

2 files changed

+16
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-12
lines changed

‎components/security/firewall.rst

Copy file name to clipboardExpand all lines: components/security/firewall.rst
+15-11Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
.. index::
22
single: Security, Firewall
33

4-
The Firewall and Security Context
5-
=================================
4+
The Firewall and Authorization
5+
==============================
66

7-
Central to the Security component is the security context, which is an instance
8-
of :class:`Symfony\\Component\\Security\\Core\\SecurityContextInterface`. When all
9-
steps in the process of authenticating the user have been taken successfully,
10-
you can ask the security context if the authenticated user has access to a
7+
Central to the Security component is authorization. This is handled by an instance
8+
of :class:`Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface`.
9+
When all steps in the process of authenticating the user have been taken successfully,
10+
you can ask the authorization checker if the authenticated user has access to a
1111
certain action or resource of the application::
1212

13-
use Symfony\Component\Security\Core\SecurityContext;
13+
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
1414
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
1515

16+
// instance of Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
17+
$tokenStorage = ...;
18+
1619
// instance of Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface
1720
$authenticationManager = ...;
1821

1922
// instance of Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
2023
$accessDecisionManager = ...;
2124

22-
$securityContext = new SecurityContext(
25+
$authorizationChecker = new AuthorizationChecker(
26+
$tokenStorage,
2327
$authenticationManager,
2428
$accessDecisionManager
2529
);
2630

2731
// ... authenticate the user
2832

29-
if (!$securityContext->isGranted('ROLE_ADMIN')) {
33+
if (!$authorizationChecker->isGranted('ROLE_ADMIN')) {
3034
throw new AccessDeniedException();
3135
}
3236

3337
.. versionadded:: 2.6
34-
As of Symfony 2.6, the :class:`Symfony\\Component\\Security\\Core\\SecurityContext` class was split
35-
in the :class:`Symfony\\Component\\Security\\Core\\Authentication\\Authorization\\AuthorizationChecker` and
38+
As of Symfony 2.6, the :class:`Symfony\\Component\\Security\\Core\\SecurityContext` class was split
39+
in the :class:`Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationChecker` and
3640
:class:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorage` classes.
3741

3842
.. note::

‎cookbook/profiler/matchers.rst

Copy file name to clipboardExpand all lines: cookbook/profiler/matchers.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ something like::
9090
}
9191

9292
.. versionadded:: 2.6
93-
The :class:`Symfony\\Component\\Security\\Core\\Authentication\\Authorization\\AuthorizationCheckerInterface` was
93+
The :class:`Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface` was
9494
introduced in Symfony 2.6. Prior, you had to use the ``isGranted`` method of
9595
:class:`Symfony\\Component\\Security\\Core\\SecurityContextInterface`.
9696

0 commit comments

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