Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions components/security/firewall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,28 @@ steps in the process of authenticating the user have been taken successfully,
you can ask the security context if the authenticated user has access to a
certain action or resource of the application::

use Symfony\Component\Security\SecurityContext;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

// instance of Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface
$authenticationManager = ...;

$securityContext = new SecurityContext();
// instance of Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
$accessDecisionManager = ...;

$securityContext = new SecurityContext($authenticationManager, $accessDecisionManager);

// ... authenticate the user

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

.. note::

Read the dedicated sections to learn more about :doc:`/components/security/authentication`
and :doc:`/components/security/authorization`.

.. _firewall:

A Firewall for HTTP Requests
Expand Down