8000 minor #11108 Update form_login_setup.rst (Deveosys) · symfony/symfony-docs@95ff38f · GitHub
[go: up one dir, main page]

Skip to content

Commit 95ff38f

Browse files
committed
minor #11108 Update form_login_setup.rst (Deveosys)
This PR was squashed before being merged into the 4.2 branch (closes #11108). Discussion ---------- 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 Commits ------- c16923d Update form_login_setup.rst
2 parents b400a65 + c16923d commit 95ff38f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

security/form_login_setup.rst

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

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

0 commit comments

Comments
 (0)
0