Skip to content

Commit

Permalink
[#5453] Minor tweaks - mostly thanks to Javier
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Jul 16, 2015
1 parent 589828d commit d4afd3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ other users. Also, as the admin user, you yourself want to be able to edit

To accomplish this you have 2 options:

* :doc:`Voters </cookbook/security/voters>` allow you to use business logic
* :doc:`Voters </cookbook/security/voters>` allow you to write own business logic
(e.g. the user can edit this post because they were the creator) to determine
access. You'll probably want this option - it's flexible enough to solve the
above situation.
Expand Down
14 changes: 6 additions & 8 deletions cookbook/security/voters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ All voters are called each time you use the ``isGranted()`` method on Symfony's
security context (i.e. the ``security.context`` service). Each one decides
if the current user should have access to some resource.

Ultimately, Symfony uses one of three different approaches on what to do
with the feedback from all voters: affirmative, consensus and unanimous.
Ultimately, Symfony takes the responses from all voters and makes the final
decission (to allow or deny access to the resource) according to the strategy defined
in the application, which can be: affirmative, consensus or unanimous.

For more information take a look at
:ref:`the section about access decision managers <components-security-access-decision-manager>`.
Expand All @@ -49,7 +50,7 @@ method is used to check if the voter supports the given user attribute (i.e:
a role like ``ROLE_USER``, an ACL ``EDIT``, etc.).

The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsClass`
method is used to check if the voter supports the class of the object whose
method checks whether the voter supports the class of the object whose
access is being checked.

The :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::vote`
Expand Down Expand Up @@ -87,10 +88,7 @@ edit a particular object. Here's an example implementation::

public function supportsAttribute($attribute)
{
return in_array($attribute, array(
self::VIEW,
self::EDIT,
));
return in_array($attribute, array(self::VIEW, self::EDIT));
}

public function supportsClass($class)
Expand Down Expand Up @@ -229,7 +227,7 @@ from the security context is called.
// keep in mind, this will call all registered security voters
if (false === $this->get('security.context')->isGranted('view', $post)) {
throw new AccessDeniedException('Unauthorised access!');
throw new AccessDeniedException('Unauthorized access!');
}
return new Response('<h1>'.$post->getName().'</h1>');
Expand Down

0 comments on commit d4afd3a

Please sign in to comment.