@@ -26,9 +26,7 @@ First, enable form login under your firewall:
26
26
main :
27
27
anonymous : ~
28
28
json_login :
29
- check_path : login
30
- username_path : user.login
31
- password_path : user.password
29
+ check_path : login
32
30
33
31
.. code-block :: xml
34
32
@@ -43,7 +41,7 @@ First, enable form login under your firewall:
43
41
<config >
44
42
<firewall name =" main" >
45
43
<anonymous />
46
- <json-login check-path =" login" username-path = " user.login " password-path = " user.password " />
44
+ <json-login check-path =" login" />
47
45
</firewall >
48
46
</config >
49
47
</srv : container >
@@ -57,8 +55,6 @@ First, enable form login under your firewall:
57
55
'anonymous' => null,
58
56
'json_login' => array(
59
57
'check_path' => 'login',
60
- 'username_path' => 'user.login',
61
- 'password_path' => 'user.password',
62
58
),
63
59
),
64
60
),
@@ -155,14 +151,79 @@ check the user's credentials and either authenticate the user or throw an error:
155
151
.. code-block :: json
156
152
157
153
{
158
- "user" : {
159
- "login" : " dunglas" ,
160
- "password" : " MyPassword"
154
+ "login" : " dunglas" ,
155
+ "password" : " MyPassword"
156
+ }
157
+
158
+ If the JSON document has a different structure, you can specify the path to
159
+ access to the user and password properties using the ``username_path `` and
160
+ ``password_path `` keys (they default respectively to ``username `` and ``password ``).
161
+
162
+ For example, if the JSON document has the following structure:
163
+
164
+ .. code-block :: json
165
+
166
+ {
167
+ "security" :
168
+ "credentials" : {
169
+ "login" : " dunglas" ,
170
+ "password" : " MyPassword"
171
+ }
161
172
}
162
173
}
163
174
164
- You can specify the path to access to the user and password in the JSON document
165
- using the ``username_path `` and the ``password_path `` keys. They default respectively
166
- to ``username `` and ``password ``.
175
+ The security configuration should be:
176
+
177
+ .. configuration-block ::
178
+
179
+ .. code-block :: yaml
180
+
181
+ # app/config/security.yml
182
+ security :
183
+ # ...
184
+
185
+ firewalls :
186
+ main :
187
+ anonymous : ~
188
+ json_login :
189
+ check_path : login
190
+ username_path : security.credentials.login
191
+ password_path : security.credentials.password
192
+
193
+ .. code-block :: xml
194
+
195
+ <!-- app/config/security.xml -->
196
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
197
+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
198
+ xmlns : srv =" http://symfony.com/schema/dic/services"
199
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
200
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
201
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
202
+
203
+ <config >
204
+ <firewall name =" main" >
205
+ <anonymous />
206
+ <json-login check-path =" login"
207
+ username-path =" security.credentials.login"
208
+ password-path =" security.credentials.password" />
209
+ </firewall >
210
+ </config >
211
+ </srv : container >
212
+
213
+ .. code-block :: php
214
+
215
+ // app/config/security.php
216
+ $container->loadFromExtension('security', array(
217
+ 'firewalls' => array(
218
+ 'main' => array(
219
+ 'anonymous' => null,
220
+ 'json_login' => array(
221
+ 'check_path' => 'login',
222
+ 'username_path' => 'security.credentials.login',
223
+ 'password_path' => 'security.credentials.password',
224
+ ),
225
+ ),
226
+ ),
227
+ ));
167
228
168
229
.. _`FOSUserBundle` : https://github.com/FriendsOfSymfony/FOSUserBundle
0 commit comments