8000 [Cookbook, Security] Added user_checkers.rst by linaori · Pull Request #5530 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
[Cookbook, Security] Added user_checkers.rst #5530
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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Updated according to the feature modifications
Instead of multiple User Checkers, only 1 is configured
  • Loading branch information
Iltar van der Berg committed Oct 1, 2015
commit d070f5be71dfb75d8be113d7d69a47a119a0f498
41 changes: 19 additions & 22 deletions cookbook/security/user_checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ How to Create and Enable Custom User Checkers
=============================================

During the authentication of a user, additional checks might be required to verify
if the identified user is allowed to log in. By defining custom user checkers, you
can define per firewall which checkers should be used.
if the identified user is allowed to log in. By defining a custom user checker, you
can define per firewall which checker should be used.

.. versionadded:: 2.8
Adding custom user checkers was introduced in Symfony 2.8.
Defining a custom user checker was introduced in Symfony 2.8.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double empty line here

Creating a Custom User Checker
Expand Down Expand Up @@ -80,8 +80,7 @@ other service:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.user_checker" class="App\Security\UserChecker">
</service>
<service id="app.user_checker" class="App\Security\UserChecker" />
</services>
</container>

Expand All @@ -107,7 +106,7 @@ is the service id of your user checker:
firewalls:
secured_area:
pattern: ^/
user_checkers: ["app.user_checker"]
user_checker: app.user_checker
# ...

.. code-block:: xml
Expand All @@ -123,7 +122,7 @@ is the service id of your user checker:
<config>
<!-- ... -->
<firewall name="secured_area" pattern="^/">
<user-checkers>app.user_checker</user-checkers>
<user-checker>app.user_checker</user-checker>
<!-- ... -->
</firewall>
</config>
Expand All @@ -138,7 +137,7 @@ is the service id of your user checker:
'firewalls' => array(
'secured_area' => array(
'pattern' => '^/',
'user_checkers' => array('app.user_checker'),
'user_checker' => 'app.user_checker',
// ...
),
),
Expand All @@ -148,10 +147,7 @@ is the service id of your user checker:
Additional Configurations
-------------------------

It's possible to add multiple user checkers to one firewall while
configuring only one user checker for another firewall. When adding
multiple user checkers, they are executed in the same sequence as
defined in your configuration.
It's possible to have a different user checker per firewall.

.. configuration-block::

Expand All @@ -164,11 +160,11 @@ defined in your configuration.
firewalls:
admin:
pattern: ^/admin
user_checkers: ["app.user_checker", "app.admin_checker"]
user_checker: app.admin_user_checker
# ...
secured_area:
pattern: ^/
user_checkers: ["app.user_checker"]
user_checker: app.user_checker

.. code-block:: xml

Expand All @@ -183,12 +179,11 @@ defined in your configuration.
<config>
<!-- ... -->
<firewall name="admin" pattern="^/admin">
<user-checkers>app.user_checker</user-checkers>
<user-checkers>app.admin_checker</user-checkers>
<user-checker>app.admin_user_checker</user-checker>
<!-- ... -->
</firewall>
<firewall name="secured_area" pattern="^/">
<user-checkers>app.user_checker</user-checkers>
<user-checker>app.user_checker</user-checker>
<!-- ... -->
</firewall>
</config>
Expand All @@ -203,16 +198,18 @@ defined in your configuration.
'firewalls' => array(
'admin' => array(
'pattern' => '^/admin',
'user_checkers' => array(
'app.user_checker',
'app.admin_checker',
),
'user_checkers' => 'app.admin_user_checker'
// ...
),
'secured_area' => array(
'pattern' => '^/',
'user_checkers' => array('app.user_checker'),
'user_checker' => 'app.user_checker',
// ...
),
),
));

.. note::

Internally the user checkers are aliased per firewall. For `secured_area` the alias
`security.user_checker.secured_area` would point to `app.user_checker`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use double backticks instead of single ones (single backticks is markdown syntax)

0