Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BestPractices][Security] revert #5271 on the 2.6 branch #5305

Merged
merged 1 commit into from
May 23, 2015
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
22 changes: 13 additions & 9 deletions best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ more advanced use-case, you can always do the same security check in PHP:

.. code-block:: php

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

// ...

/**
* @Route("/{id}/edit", name="admin_post_edit")
*/
Expand All @@ -238,7 +234,16 @@ more advanced use-case, you can always do the same security check in PHP:
}

if (!$post->isAuthor($this->getUser())) {
throw new AccessDeniedException();
$this->denyAccessUnlessGranted('edit', $post);

// or without the shortcut:
//
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
//
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
// throw $this->createAccessDeniedException();
// }
}

// ...
Expand Down Expand Up @@ -327,10 +332,6 @@ via the even easier shortcut in a controller:

.. code-block:: php

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

// ...

/**
* @Route("/{id}/edit", name="admin_post_edit")
*/
Expand All @@ -342,6 +343,9 @@ via the even easier shortcut in a controller:

// or without the shortcut:
//
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
//
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
// throw $this->createAccessDeniedException();
// }
Expand Down