Commit 58851284 authored by Fabien Potencier's avatar Fabien Potencier

updated docs

parent f707a6dd
...@@ -19,11 +19,10 @@ Services ...@@ -19,11 +19,10 @@ Services
<http://api.symfony.com/master/Symfony/Component/Form/FormFactory.html>`_, <http://api.symfony.com/master/Symfony/Component/Form/FormFactory.html>`_,
that is used for build a form. that is used for build a form.
* **form.csrf_provider**: An instance of an implementation of the * **form.csrf_provider**: An instance of an implementation of
`CsrfProviderInterface `CsrfProviderInterface
<http://api.symfony.com/master/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.html>`_, <http://api.symfony.com/2.3/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.html>`_ for Symfony 2.3 or
defaults to a `DefaultCsrfProvider `CsrfTokenManagerInterface <http://api.symfony.com/2.7/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.html>`_ for Symfony 2.4+.
<http://api.symfony.com/master/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.html>`_.
Registering Registering
----------- -----------
...@@ -61,7 +60,8 @@ Registering ...@@ -61,7 +60,8 @@ Registering
composer require symfony/validator symfony/config symfony/translation composer require symfony/validator symfony/config symfony/translation
The Symfony Security CSRF component is used to protect forms against CSRF attacks: The Symfony Security CSRF component is used to protect forms against CSRF
attacks (as of Symfony 2.4+):
.. code-block:: bash .. code-block:: bash
......
...@@ -14,7 +14,12 @@ Services ...@@ -14,7 +14,12 @@ Services
-------- --------
* **security**: The main entry point for the security provider. Use it to get * **security**: The main entry point for the security provider. Use it to get
the current user token. the current user token (only for Symfony up to 2.5).
* **security.token_storage**: Gives access to the user token (Symfony 2.6+).
* **security.authorization_checker**: Allows to check authorizations for the
users (Symfony 2.6+).
* **security.authentication_manager**: An instance of * **security.authentication_manager**: An instance of
`AuthenticationProviderManager `AuthenticationProviderManager
...@@ -95,6 +100,10 @@ Accessing the current User ...@@ -95,6 +100,10 @@ Accessing the current User
The current user information is stored in a token that is accessible via the The current user information is stored in a token that is accessible via the
``security`` service:: ``security`` service::
// Symfony 2.6+
$token = $app['security.token_storage']->getToken();
// Symfony 2.3/2.5
$token = $app['security']->getToken(); $token = $app['security']->getToken();
If there is no information about the user, the token is ``null``. If the user If there is no information about the user, the token is ``null``. If the user
...@@ -327,6 +336,12 @@ Checking User Roles ...@@ -327,6 +336,12 @@ Checking User Roles
To check if a user is granted some role, use the ``isGranted()`` method on the To check if a user is granted some role, use the ``isGranted()`` method on the
security context:: security context::
// Symfony 2.6+
if ($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) {
// ...
}
// Symfony 2.3/2.5
if ($app['security']->isGranted('ROLE_ADMIN')) { if ($app['security']->isGranted('ROLE_ADMIN')) {
// ... // ...
} }
...@@ -566,7 +581,8 @@ use in your configuration:: ...@@ -566,7 +581,8 @@ use in your configuration::
// define the authentication listener object // define the authentication listener object
$app['security.authentication_listener.'.$name.'.wsse'] = $app->share(function () use ($app) { $app['security.authentication_listener.'.$name.'.wsse'] = $app->share(function () use ($app) {
return new WsseListener($app['security'], $app['security.authentication_manager']); // use 'security' instead of 'security.token_storage' on Symfony <2.6
return new WsseListener($app['security.token_storage'], $app['security.authentication_manager']);
}); });
return array( return array(
......
...@@ -14,7 +14,7 @@ Services ...@@ -14,7 +14,7 @@ Services
-------- --------
* **validator**: An instance of `Validator * **validator**: An instance of `Validator
<http://api.symfony.com/master/Symfony/Component/Validator/Validator.html>`_. <http://api.symfony.com/master/Symfony/Component/Validator/ValidatorInterface.html>`_.
* **validator.mapping.class_metadata_factory**: Factory for metadata loaders, * **validator.mapping.class_metadata_factory**: Factory for metadata loaders,
which can read validation constraint information from classes. Defaults to which can read validation constraint information from classes. Defaults to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment