@@ -5,11 +5,11 @@ How to Create and Enable Custom User Checkers
5
5
=============================================
6
6
7
7
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.
10
10
11
11
.. 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.
13
13
14
14
15
15
Creating a Custom User Checker
@@ -80,8 +80,7 @@ other service:
80
80
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
81
81
82
82
<services >
83
- <service id =" app.user_checker" class =" App\Security\UserChecker" >
84
- </service >
83
+ <service id =" app.user_checker" class =" App\Security\UserChecker" />
85
84
</services >
86
85
</container >
87
86
@@ -107,7 +106,7 @@ is the service id of your user checker:
107
106
firewalls :
108
107
secured_area :
109
108
pattern : ^/
110
- user_checkers : [" app.user_checker"]
109
+ user_checker : app.user_checker
111
110
# ...
112
111
113
112
.. code-block :: xml
@@ -123,7 +122,7 @@ is the service id of your user checker:
123
122
<config >
124
123
<!-- ... -->
125
124
<firewall name =" secured_area" pattern =" ^/" >
126
- <user-checkers >app.user_checker</user-checkers >
125
+ <user-checker >app.user_checker</user-checker >
127
126
<!-- ... -->
128
127
</firewall >
129
128
</config >
@@ -138,80 +137,7 @@ is the service id of your user checker:
138
137
'firewalls' => array(
139
138
'secured_area' => array(
140
139
'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',
215
141
// ...
216
142
),
217
143
),
0 commit comments