Skip to content

Commit 88dda8c

Browse files
Added missing security.yaml config
I just copied this over from https://symfony.com/doc/3.4/security/guard_authentication.html - since it probably just got lost somehow. When following the instructions at https://symfony.com/doc/current/security.html , you would still have `property: email` in there.
1 parent d4bb765 commit 88dda8c

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

security/guard_authentication.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,64 @@ Don't forget to generate and execute the migration:
4949
$ php bin/console make:migration
5050
$ php bin/console doctrine:migrations:migrate
5151
52+
Next, configure your "user provider" to use this new `apiKey`property:
53+
54+
.. configuration-block::
55+
56+
.. code-block:: yaml
57+
58+
# config/packages/security.yaml
59+
security:
60+
# ...
61+
62+
providers:
63+
your_db_provider:
64+
entity:
65+
class: App\Entity\User
66+
property: apiKey
67+
68+
# ...
69+
70+
.. code-block:: xml
71+
72+
<!-- config/packages/security.xml -->
73+
<?xml version="1.0" encoding="UTF-8"?>
74+
<srv:container xmlns="http://symfony.com/schema/dic/security"
75+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
76+
xmlns:srv="http://symfony.com/schema/dic/services"
77+
xsi:schemaLocation="http://symfony.com/schema/dic/services
78+
https://symfony.com/schema/dic/services/services-1.0.xsd">
79+
80+
<config>
81+
<!-- ... -->
82+
83+
<provider name="your_db_provider">
84+
<entity class="App\Entity\User" property="apiKey"/>
85+
</provider>
86+
87+
<!-- ... -->
88+
</config>
89+
</srv:container>
90+
91+
.. code-block:: php
92+
93+
// config/packages/security.php
94+
$container->loadFromExtension('security', [
95+
// ...
96+
97+
'providers' => [
98+
'your_db_provider' => [
99+
'entity' => [
100+
'class' => 'App\Entity\User',
101+
'property' => 'apiKey',
102+
],
103+
],
104+
],
105+
106+
// ...
107+
]);
108+
109+
52110
Step 2) Create the Authenticator Class
53111
--------------------------------------
54112

0 commit comments

Comments
 (0)