Skip to content

Commit 3e95bca

Browse files
authored
Update form_login_setup.rst
Add access_control property in security.yml file in order to allow anonymous authenticated users to access the /login route
1 parent bd68890 commit 3e95bca

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

security/form_login_setup.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,51 @@ class that processes the login submit and 4) updates the main security config fi
7373
}
7474
}
7575

76+
Edit the security.yml file in order to allow access to the ``/login``route ::
77+
78+
.. configuration-block::
79+
80+
.. code-block:: yaml
81+
82+
# config/packages/security.yaml
83+
security:
84+
# ...
85+
86+
access_control:
87+
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
88+
# ...
89+
90+
.. code-block:: xml
91+
92+
<!-- config/packages/security.xml -->
93+
<?xml version="1.0" encoding="UTF-8"?>
94+
<srv:container xmlns="http://symfony.com/schema/dic/security"
95+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
96+
xmlns:srv="http://symfony.com/schema/dic/services"
97+
xsi:schemaLocation="http://symfony.com/schema/dic/services
98+
http://symfony.com/schema/dic/services/services-1.0.xsd">
99+
100+
<config>
101+
<rule path="^/login" role="IS_AUTHENTICATED_ANONYMOUSLY" />
102+
<!-- ... -->
103+
</config>
104+
</srv:container>
105+
106+
.. code-block:: php
107+
108+
// config/packages/security.php
109+
$container->loadFromExtension('security', [
110+
// ...
111+
'access_control' => [
112+
[
113+
'path' => '^/login',
114+
'role' => 'IS_AUTHENTICATED_ANONYMOUSLY',
115+
],
116+
// ...
117+
],
118+
]);
119+
120+
76121
**Step 2.** The template has very little to do with security: it just generates
77122
a traditional HTML form that submits to ``/login``:
78123

0 commit comments

Comments
 (0)