From 6fd3f93201ec093d20b12f13f035373ac5a0bec0 Mon Sep 17 00:00:00 2001 From: Klaus Silveira Date: Fri, 17 Jan 2014 10:51:53 -0200 Subject: [PATCH 1/4] Documenting createAccessDeniedException() method Updating documentation to reflect the changes added in https://github.com/symfony/symfony/pull/9405. --- book/security.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/book/security.rst b/book/security.rst index fa9958dca1e..f9a8e97e887 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1072,12 +1072,11 @@ fine-grained enough in certain cases. When necessary, you can easily force authorization from inside a controller:: // ... - use Symfony\Component\Security\Core\Exception\AccessDeniedException; public function helloAction($name) { if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) { - throw new AccessDeniedException(); + throw $this->createAccessDeniedException('Unable to access this page!'); } // ... @@ -1085,6 +1084,9 @@ authorization from inside a controller:: .. _book-security-securing-controller-annotations: +The ``createAccessDeniedException()`` method creates a special ``AccessDeniedException`` +object, which ultimately triggers a 403 HTTP response inside Symfony. + Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations:: // ... From 53f156c6fd104cb0d0719fcd4d66d5f32b522906 Mon Sep 17 00:00:00 2001 From: Klaus Silveira Date: Fri, 17 Jan 2014 15:07:11 -0200 Subject: [PATCH 2/4] Updating references to match doc format --- book/security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/security.rst b/book/security.rst index f9a8e97e887..8cff1560a0a 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1084,7 +1084,7 @@ authorization from inside a controller:: .. _book-security-securing-controller-annotations: -The ``createAccessDeniedException()`` method creates a special ``AccessDeniedException`` +The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createAccessDeniedException()` method creates a special :class:`Symfony\\Component\\Security\\Core\Exception\\AccessDeniedException` object, which ultimately triggers a 403 HTTP response inside Symfony. Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations:: From b1b9090452a6141fa7763f711fde1a99f9e79e71 Mon Sep 17 00:00:00 2001 From: Klaus Silveira Date: Fri, 17 Jan 2014 16:06:35 -0200 Subject: [PATCH 3/4] Adding versionadded detail --- book/security.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/book/security.rst b/book/security.rst index 8cff1560a0a..3d0a26dc3b1 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1084,6 +1084,9 @@ authorization from inside a controller:: .. _book-security-securing-controller-annotations: +.. versionadded:: 2.5 + The ``createAccessDeniedException`` method was introduced in Symfony 2.5. + The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createAccessDeniedException()` method creates a special :class:`Symfony\\Component\\Security\\Core\Exception\\AccessDeniedException` object, which ultimately triggers a 403 HTTP response inside Symfony. From da6002d65ea8468875306c10eec6e5a115543c1a Mon Sep 17 00:00:00 2001 From: Klaus Silveira Date: Fri, 17 Jan 2014 17:01:57 -0200 Subject: [PATCH 4/4] Wrapping line --- book/security.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/book/security.rst b/book/security.rst index 3d0a26dc3b1..9603fb92a15 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1087,7 +1087,8 @@ authorization from inside a controller:: .. versionadded:: 2.5 The ``createAccessDeniedException`` method was introduced in Symfony 2.5. -The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createAccessDeniedException()` method creates a special :class:`Symfony\\Component\\Security\\Core\Exception\\AccessDeniedException` +The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createAccessDeniedException()` +method creates a special :class:`Symfony\\Component\\Security\\Core\Exception\\AccessDeniedException` object, which ultimately triggers a 403 HTTP response inside Symfony. Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations::