Skip to content

Commit cadf459

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: Tweaks Update security.rst
2 parents a75e099 + 5014c66 commit cadf459

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

reference/configuration/security.rst

+52
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,58 @@ the session must not be used when authenticating users:
989989
// ...
990990
};
991991
992+
.. _reference-security-lazy:
993+
994+
lazy
995+
~~~~
996+
997+
Firewalls can configure a ``lazy`` boolean option to load the user and start the
998+
session only if the application actually accesses the User object, (e.g. calling
999+
``is_granted()`` in a template or ``isGranted()`` in a controller or service):
1000+
1001+
.. configuration-block::
1002+
1003+
.. code-block:: yaml
1004+
1005+
# config/packages/security.yaml
1006+
security:
1007+
# ...
1008+
1009+
firewalls:
1010+
main:
1011+
# ...
1012+
lazy: true
1013+
1014+
.. code-block:: xml
1015+
1016+
<!-- config/packages/security.xml -->
1017+
<?xml version="1.0" encoding="UTF-8" ?>
1018+
<srv:container xmlns="http://symfony.com/schema/dic/security"
1019+
xmlns:srv="http://symfony.com/schema/dic/services"
1020+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1021+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1022+
https://symfony.com/schema/dic/services/services-1.0.xsd
1023+
http://symfony.com/schema/dic/security
1024+
https://symfony.com/schema/dic/security/security-1.0.xsd">
1025+
1026+
<config>
1027+
<firewall name="main" lazy="true">
1028+
<!-- ... -->
1029+
</firewall>
1030+
</config>
1031+
</srv:container>
1032+
1033+
.. code-block:: php
1034+
1035+
// config/packages/security.php
1036+
use Symfony\Config\SecurityConfig;
1037+
1038+
return static function (SecurityConfig $security): void {
1039+
$security->firewall('main')
1040+
->lazy(true);
1041+
// ...
1042+
};
1043+
9921044
User Checkers
9931045
~~~~~~~~~~~~~
9941046

0 commit comments

Comments
 (0)