Skip to content

Commit 5aebc6a

Browse files
committed
Merge branch '5.0'
* 5.0: [#13171] Some small rewordings [Security] Explain lazy anonymous mode
2 parents be88d94 + 203a258 commit 5aebc6a

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

security.rst

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,33 @@ accidentally block Symfony's dev tools - which live under URLs like ``/_profiler
295295
and ``/_wdt``.
296296

297297
All *real* URLs are handled by the ``main`` firewall (no ``pattern`` key means
298-
it matches *all* URLs). But this does *not* mean that every URL requires authentication.
299-
Nope, thanks to the ``anonymous`` key, this firewall *is* accessible anonymously.
298+
it matches *all* URLs). A firewall can have many modes of authentication,
299+
in other words many ways to ask the question "Who are you?". Often, the
300+
user is unknown (i.e. not logged in) when they first visit your website. The
301+
``anonymous`` mode, if enabled, is used for these requests.
300302

301-
In fact, if you go to the homepage right now, you *will* have access and you'll see
302-
that you're "authenticated" as ``anon.``. Don't be fooled by the "Yes" next to
303-
Authenticated. The firewall verified that it does not know your identity, and so,
304-
you are anonymous:
303+
In fact, if you go to the homepage right now, you *will* have access and you'll
304+
see that you're "authenticated" as ``anon.``. The firewall verified that it
305+
does not know your identity, and so, you are anonymous:
305306

306307
.. image:: /_images/security/anonymous_wdt.png
307308
:align: center
308309

309-
You'll learn later how to deny access to certain URLs or controllers.
310+
It means any request can have an anonymous token to access some resource,
311+
while some actions (i.e. some pages or buttons) can still require specific
312+
privileges. A user can then access a form login without being authenticated
313+
as a unique user (otherwise an infinite redirection loop would happen
314+
asking the user to authenticate while trying to doing so).
315+
316+
You'll learn later how to deny access to certain URLs, controllers, or part of
317+
templates.
318+
319+
.. tip::
320+
321+
The ``lazy`` anonymous mode prevents the session from being started if
322+
there is no need for authorization (i.e. explicit check for a user
323+
privilege). This is important to keep requests cacheable (see
324+
:doc:`/http_cache`).
310325

311326
.. note::
312327

security/form_login.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ First, enable ``form_login`` under your firewall:
4747
4848
<config>
4949
<firewall name="main">
50-
<anonymous/>
50+
<anonymous lazy="true"/>
5151
<form-login login-path="login" check-path="login"/>
5252
</firewall>
5353
</config>
@@ -59,7 +59,7 @@ First, enable ``form_login`` under your firewall:
5959
$container->loadFromExtension('security', [
6060
'firewalls' => [
6161
'main' => [
62-
'anonymous' => null,
62+
'anonymous' => 'lazy',
6363
'form_login' => [
6464
'login_path' => 'login',
6565
'check_path' => 'login',

0 commit comments

Comments
 (0)