diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index b89aab67608..ac9e0382fa5 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -1075,6 +1075,58 @@ the session must not be used when authenticating users: // ... }; +.. _reference-security-lazy: + +lazy +~~~~~~~~~ + +Firewalls can configure a ``lazy`` boolean option in order to load the user and start the session only +if the application actually accesses the User object, +(e.g. via a is_granted() call in a template or isGranted() in a controller or service): + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + # ... + + firewalls: + main: + # ... + lazy: true + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security): void { + $mainFirewall = $security->firewall('main'); + $mainFirewall->lazy(true); + // ... + }; + User Checkers ~~~~~~~~~~~~~