Skip to content

Commit 9c819b4

Browse files
committed
bug #4713 [Security] Removed deprecated example about SecurityContext (iltar)
This PR was submitted for the master branch but it was merged into the 2.6 branch instead (closes #4713). Discussion ---------- [Security] Removed deprecated example about SecurityContext | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | ~2.6 | Fixed tickets | ~ @Einenlum noticed that there was still some documentation referring to the `SecurityContext`. This PR should remove the reference. It also fixes two occurrences where the namespace to the `AuthorizationChecker` in `versionadd` was inccorect, causing broken links to non-existing API pages. I wasn't sure how to formulate the intro. If there are any suggestions, feel free to provide. Commits ------- 91db61a [Security] Removed deprecated example about SecurityContext
2 parents 02d594c + 91db61a commit 9c819b4

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

components/security/firewall.rst

Lines 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

Lines 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)