Skip to content

Commit 9d2d604

Browse files
author
Iltar van der Berg
committed
Updated according to the feature modifications
Instead of multiple User Checkers, only 1 is configured
1 parent 2a85e4f commit 9d2d604

File tree

1 file changed

+7
-81
lines changed

1 file changed

+7
-81
lines changed

cookbook/security/user_checkers.rst

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ How to Create and Enable Custom User Checkers
55
=============================================
66

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

1111
.. versionadded:: 2.8
12-
Adding custom user checkers was introduced in Symfony 2.8.
12+
Defining a custom user checker was introduced in Symfony 2.8.
1313

1414

1515
Creating a Custom User Checker
@@ -80,8 +80,7 @@ other service:
8080
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
8181
8282
<services>
83-
<service id="app.user_checker" class="App\Security\UserChecker">
84-
</service>
83+
<service id="app.user_checker" class="App\Security\UserChecker" />
8584
</services>
8685
</container>
8786
@@ -107,7 +106,7 @@ is the service id of your user checker:
107106
firewalls:
108107
secured_area:
109108
pattern: ^/
110-
user_checkers: ["app.user_checker"]
109+
user_checker: app.user_checker
111110
# ...
112111
113112
.. code-block:: xml
@@ -123,7 +122,7 @@ is the service id of your user checker:
123122
<config>
124123
<!-- ... -->
125124
<firewall name="secured_area" pattern="^/">
126-
<user-checkers>app.user_checker</user-checkers>
125+
<user-checker>app.user_checker</user-checker>
127126
<!-- ... -->
128127
</firewall>
129128
</config>
@@ -138,80 +137,7 @@ is the service id of your user checker:
138137
'firewalls' => array(
139138
'secured_area' => array(
140139
'pattern' => '^/',
141-
'user_checkers' => array('app.user_checker'),
142-
// ...
143-
),
144-
),
145-
));
146-
147-
148-
Additional Configurations
149-
-------------------------
150-
151-
It's possible to add multiple user checkers to one firewall while
152-
configuring only one user checker for another firewall. When adding
153-
multiple user checkers, they are executed in the same sequence as
154-
defined in your configuration.
155-
156-
.. configuration-block::
157-
158-
.. code-block:: yaml
159-
160-
# app/config/security.yml
161-
162-
# ...
163-
security:
164-
firewalls:
165-
admin:
166-
pattern: ^/admin
167-
user_checkers: ["app.user_checker", "app.admin_checker"]
168-
# ...
169-
secured_area:
170-
pattern: ^/
171-
user_checkers: ["app.user_checker"]
172-
173-
.. code-block:: xml
174-
175-
<!-- app/config/security.xml -->
176-
<?xml version="1.0" encoding="UTF-8"?>
177-
<srv:container xmlns="http://symfony.com/schema/dic/security"
178-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
179-
xmlns:srv="http://symfony.com/schema/dic/services"
180-
xsi:schemaLocation="http://symfony.com/schema/dic/services
181-
http://symfony.com/schema/dic/services/services-1.0.xsd">
182-
183-
<config>
184-
<!-- ... -->
185-
<firewall name="admin" pattern="^/admin">
186-
<user-checkers>app.user_checker</user-checkers>
187-
<user-checkers>app.admin_checker</user-checkers>
188-
<!-- ... -->
189-
</firewall>
190-
<firewall name="secured_area" pattern="^/">
191-
<user-checkers>app.user_checker</user-checkers>
192-
<!-- ... -->
193-
</firewall>
194-
</config>
195-
</srv:container>
196-
197-
.. code-block:: php
198-
199-
// app/config/security.php
200-
201-
// ...
202-
$container->loadFromExtension('security', array(
203-
'firewalls' => array(
204-
'admin' => array(
205-
'pattern' => '^/admin',
206-
'user_checkers' => array(
207-
'app.user_checker',
208-
'app.admin_checker',
209-
),
210-
// ...
211-
),
212-
'secured_area' => array(
213-
'pattern' => '^/',
214-
'user_checkers' => array('app.user_checker'),
140+
'user_checker' => 'app.user_checker',
215141
// ...
216142
),
217143
),

0 commit comments

Comments
 (0)