-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Security] doc(security): add firewall lazy option #20459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1075,6 +1075,58 @@ | |||||||||
// ... | ||||||||||
}; | ||||||||||
|
||||||||||
.. _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 | ||||||||||
|
||||||||||
<!-- config/packages/security.xml --> | ||||||||||
<?xml version="1.0" encoding="UTF-8" ?> | ||||||||||
<srv:container xmlns="http://symfony.com/schema/dic/security" | ||||||||||
xmlns:srv="http://symfony.com/schema/dic/services" | ||||||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||||||||||
https://symfony.com/schema/dic/services/services-1.0.xsd | ||||||||||
http://symfony.com/schema/dic/security | ||||||||||
https://symfony.com/schema/dic/security/security-1.0.xsd"> | ||||||||||
|
||||||||||
<config> | ||||||||||
<firewall name="main" lazy="true"> | ||||||||||
<!-- ... --> | ||||||||||
</firewall> | ||||||||||
</config> | ||||||||||
</srv:container> | ||||||||||
|
||||||||||
.. code-block:: php | ||||||||||
|
||||||||||
// config/packages/security.php | ||||||||||
use Symfony\Config\SecurityConfig; | ||||||||||
|
||||||||||
return static function (SecurityConfig $security): void { | ||||||||||
$mainFirewall = $security->firewall('main'); | ||||||||||
$mainFirewall->lazy(true); | ||||||||||
Comment on lines
+1125
to
+1126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
What do you think about this syntax ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, will cs fix if the PR is accepted and we decide how to document this option :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made this change while merging. |
||||||||||
// ... | ||||||||||
}; | ||||||||||
|
||||||||||
User Checkers | ||||||||||
~~~~~~~~~~~~~ | ||||||||||
|
||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that used somewhere or mandatory for any reason ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a simple copy/paste from "stateless" doc part for now :s