File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -1075,6 +1075,58 @@ the session must not be used when authenticating users:
10751075 // ...
10761076 };
10771077
1078+ .. _reference-security-lazy :
1079+
1080+ lazy
1081+ ~~~~~~~~~
1082+
1083+ Firewalls can configure a ``lazy `` boolean option in order to load the user and start the session only
1084+ if the application actually accesses the User object,
1085+ (e.g. via a is_granted() call in a template or isGranted() in a controller or service):
1086+
1087+ .. configuration-block ::
1088+
1089+ .. code-block :: yaml
1090+
1091+ # config/packages/security.yaml
1092+ security :
1093+ # ...
1094+
1095+ firewalls :
1096+ main :
1097+ # ...
1098+ lazy : true
1099+
1100+ .. code-block :: xml
1101+
1102+ <!-- config/packages/security.xml -->
1103+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1104+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
1105+ xmlns : srv =" http://symfony.com/schema/dic/services"
1106+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1107+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1108+ https://symfony.com/schema/dic/services/services-1.0.xsd
1109+ http://symfony.com/schema/dic/security
1110+ https://symfony.com/schema/dic/security/security-1.0.xsd" >
1111+
1112+ <config >
1113+ <firewall name =" main" lazy =" true" >
1114+ <!-- ... -->
1115+ </firewall >
1116+ </config >
1117+ </srv : container >
1118+
1119+ .. code-block :: php
1120+
1121+ // config/packages/security.php
1122+ use Symfony\Config\SecurityConfig;
1123+
1124+ return static function (SecurityConfig $security): void {
1125+ $mainFirewall = $security->firewall('main');
1126+ $mainFirewall->lazy(true);
1127+ // ...
1128+ };
1129+
10781130 User Checkers
10791131~~~~~~~~~~~~~
10801132
You can’t perform that action at this time.
0 commit comments