Skip to content

Commit be992fd

Browse files
committed
minor #20459 doc(security): add firewall lazy option (94noni)
This PR was merged into the 6.4 branch. Discussion ---------- doc(security): add firewall lazy option on https://symfony.com/doc/4.x/reference/configuration/security.html, we can see the option anonymous: lazy on actual maintained version of the doc, https://symfony.com/doc/6.4/reference/configuration/security.html and + I cant find any reference to lazy This PR tries to (re)document this option (next to stateless but feel free to challenge) Please if it was removed on purposes, feel free to close but share a link/PR as I didnt find while searching Commits ------- 9eb33c8 Update security.rst
2 parents bfb0098 + 9eb33c8 commit be992fd

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

reference/configuration/security.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,58 @@ the session must not be used when authenticating users:
10011001
// ...
10021002
};
10031003
1004+
.. _reference-security-lazy:
1005+
1006+
lazy
1007+
~~~~~~~~~
1008+
1009+
Firewalls can configure a ``lazy`` boolean option in order to load the user and start the session only
1010+
if the application actually accesses the User object,
1011+
(e.g. via a is_granted() call in a template or isGranted() in a controller or service):
1012+
1013+
.. configuration-block::
1014+
1015+
.. code-block:: yaml
1016+
1017+
# config/packages/security.yaml
1018+
security:
1019+
# ...
1020+
1021+
firewalls:
1022+
main:
1023+
# ...
1024+
lazy: true
1025+
1026+
.. code-block:: xml
1027+
1028+
<!-- config/packages/security.xml -->
1029+
<?xml version="1.0" encoding="UTF-8" ?>
1030+
<srv:container xmlns="http://symfony.com/schema/dic/security"
1031+
xmlns:srv="http://symfony.com/schema/dic/services"
1032+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1033+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1034+
https://symfony.com/schema/dic/services/services-1.0.xsd
1035+
http://symfony.com/schema/dic/security
1036+
https://symfony.com/schema/dic/security/security-1.0.xsd">
1037+
1038+
<config>
1039+
<firewall name="main" lazy="true">
1040+
<!-- ... -->
1041+
</firewall>
1042+
</config>
1043+
</srv:container>
1044+
1045+
.. code-block:: php
1046+
1047+
// config/packages/security.php
1048+
use Symfony\Config\SecurityConfig;
1049+
1050+
return static function (SecurityConfig $security): void {
1051+
$mainFirewall = $security->firewall('main');
1052+
$mainFirewall->lazy(true);
1053+
// ...
1054+
};
1055+
10041056
User Checkers
10051057
~~~~~~~~~~~~~
10061058

0 commit comments

Comments
 (0)