Skip to content

Commit f9a0913

Browse files
committed
Mention @Security() annotation instead of @secure()
1 parent 3d88312 commit f9a0913

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

cookbook/security/remember_me.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ might ultimately looks like this:
9090
<!-- src/Acme/SecurityBundle/Resources/views/Security/login.html.php -->
9191
<?php if ($error): ?>
9292
<div><?php echo $error->getMessage() ?></div>
93-
<?php endif; ?>
93+
<?php endif ?>
9494

9595
<form action="<?php echo $view['router']->generate('login_check') ?>" method="post">
9696
<label for="username">Username:</label>
@@ -162,7 +162,7 @@ In the following example, the action is only allowed if the user has the
162162
163163
public function editAction()
164164
{
165-
if (false === $this->get('security.context')->isGranted(
165+
if (false === $this->get('security.authorization_checker')->isGranted(
166166
'IS_AUTHENTICATED_FULLY'
167167
)) {
168168
throw new AccessDeniedException();
@@ -171,21 +171,29 @@ In the following example, the action is only allowed if the user has the
171171
// ...
172172
}
173173
174-
You can also choose to install and use the optional JMSSecurityExtraBundle_,
175-
which can secure your controller using annotations:
174+
.. versionadded:: 2.6
175+
The ``security.authorization_checker`` service was introduced in Symfony 2.6. Prior
176+
to Symfony 2.6, you had to use the ``isGranted()`` method of the ``security.context`` service.
177+
178+
If your application is based on the Symfony Standard Edition, you can also secure
179+
your controller using annotations:
176180

177181
.. code-block:: php
178182
179-
use JMS\SecurityExtraBundle\Annotation\Secure;
183+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
180184
181185
/**
182-
* @Secure(roles="IS_AUTHENTICATED_FULLY")
186+
* @Security("has_role('IS_AUTHENTICATED_FULLY')")
183187
*/
184188
public function editAction($name)
185189
{
186190
// ...
187191
}
188192
193+
.. versionadded:: 2.4
194+
The ``@Security`` annotation was introduced in SensioFrameworkExtraBundle 3.0,
195+
which can only be used with Symfony 2.4 or later.
196+
189197
.. tip::
190198

191199
If you also had an access control in your security configuration that
@@ -208,5 +216,3 @@ which can secure your controller using annotations:
208216

209217
For more information on securing services or methods in this way,
210218
see :doc:`/cookbook/security/securing_services`.
211-
212-
.. _JMSSecurityExtraBundle: https://github.com/schmittjoh/JMSSecurityExtraBundle

0 commit comments

Comments
 (0)