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 @@ -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
You can’t perform that action at this time.
0 commit comments