Skip to content

Commit 707956b

Browse files
committed
Merge branch '4.1'
* 4.1: Mentioned the new file upload exception classes Fixing bad logic, caused by merge originally Update docs now that sessions are enabled automatically Mentioned user_checkers in the main security config reference If multiple guard authenticators have different providers, link to the details on chaining providers together.
2 parents a97dc74 + df3dd4a commit 707956b

File tree

7 files changed

+41
-28
lines changed

7 files changed

+41
-28
lines changed

controller.rst

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -383,24 +383,12 @@ Managing the Session
383383
--------------------
384384

385385
Symfony provides a session service that you can use to store information
386-
about the user between requests. Session storage and other configuration can
387-
be controlled under the :ref:`framework.session configuration <config-framework-session>`.
386+
about the user between requests. Session is enabled by default, but will only be
387+
started if you read or write from it.
388388

389-
First, activate the session by uncommenting the ``session`` key in ``config/packages/framework.yaml``:
390-
391-
.. code-block:: diff
392-
393-
# config/packages/framework.yaml
394-
framework:
395-
# ...
396-
397-
- #session:
398-
- # # The native PHP session handler will be used
399-
- # handler_id: ~
400-
+ session:
401-
+ # The native PHP session handler will be used
402-
+ handler_id: ~
403-
# ...
389+
Session storage and other configuration can be controlled under the
390+
:ref:`framework.session configuration <config-framework-session>` in
391+
``config/packages/framework.yaml``.
404392

405393
To get the session, add an argument and type-hint it with
406394
:class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`::

controller/upload_file.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,21 @@ logic to a separate service::
255255
}
256256
}
257257

258+
.. tip::
259+
260+
In addition to the generic :class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\FileException`
261+
class there are other exception classes to handle failed file uploads:
262+
:class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\CannotWriteFileException`,
263+
:class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\ExtensionFileException`,
264+
:class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\FormSizeFileException`,
265+
:class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\IniSizeFileException`,
266+
:class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\NoFileException`,
267+
:class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\NoTmpDirFileException`,
268+
and :class:`Symfony\\Component\\HttpFoundation\\File\\Exception\\PartialFileException`.
269+
270+
.. versionadded:: 4.1
271+
The detailed exception classes were introduced in Symfony 4.1.
272+
258273
Then, define a service for this class:
259274

260275
.. configuration-block::

reference/configuration/security.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,15 @@ multiple firewalls, the "context" could actually be shared:
493493
ignored and you won't be able to authenticate on multiple firewalls at the
494494
same time.
495495

496+
User Checkers
497+
-------------
498+
499+
During the authentication of a user, additional checks might be required to
500+
verify if the identified user is allowed to log in. Each firewall can include
501+
a ``user_checker`` option to define the service used to perform those checks.
502+
503+
Learn more about user checkers in :doc:`/security/user_checkers`.
504+
496505
.. _`PBKDF2`: https://en.wikipedia.org/wiki/PBKDF2
497506
.. _`ircmaxell/password-compat`: https://packagist.org/packages/ircmaxell/password-compat
498507
.. _`libsodium`: https://pecl.php.net/package/libsodium

security.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ security system step-by-step:
1717

1818
#. :ref:`Create your User Class <create-user-class>`;
1919

20-
#. :ref:`*Authentication* & Firewalls <security-yaml-firewalls>`;
20+
#. :ref:`Authentication & Firewalls <security-yaml-firewalls>`;
2121

22-
#. :ref:`Denying access to your app (*authorization*) <security-authorization>`;
22+
#. :ref:`Denying access to your app (authorization) <security-authorization>`;
2323

2424
#. :ref:`Fetching the current User object <retrieving-the-user-object>`.
2525

@@ -175,7 +175,7 @@ create dummy database users:
175175
.. code-block:: terminal
176176
177177
$ php bin/console make:fixtures
178-
178+
179179
The class name of the fixtures to create (e.g. AppFixtures):
180180
> UserFixture
181181
@@ -702,7 +702,7 @@ If you need to get the logged in user from a service, use the
702702
// ...
703703

704704
use Symfony\\Component\\Security\\Core\\Security;
705-
705+
706706
class ExampleService
707707
{
708708
private $security;
@@ -1001,7 +1001,7 @@ Authorization (Denying Access)
10011001
security/securing_services
10021002
security/access_control
10031003
security/access_denied_handler
1004-
security/acl
1004+
security/acl
10051005
security/force_https
10061006
security/security_checker
10071007

security/form_login_setup.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class.
1313
Generating the Login Form
1414
-------------------------
1515

16-
Creating a pwoerful login form is easy thanks to the ``make:auth`` command from
16+
Creating a powerful login form is easy thanks to the ``make:auth`` command from
1717
`MakerBundle`_. Depending on your setup, you may be asked different questions
1818
and your generated code may be slightly different:
1919

@@ -223,7 +223,7 @@ When you submit the form, the ``LoginFormAuthenticator`` will intercept the requ
223223
read the email (or whatever field you're using) & password from the form, find the
224224
``User`` object, validate the CSRF token and check the password.
225225

226-
But, wepending on your setup, you'll need to finish one or more TODOs before the
226+
But, depending on your setup, you'll need to finish one or more TODOs before the
227227
whole process works. You will *at least* need to fill in *where* you want your user to
228228
be redirected after success:
229229

security/guard_authentication.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,8 @@ can ignore this. Here is an example of good and bad behavior::
438438

439439
public function supports(Request $request)
440440
{
441-
// GOOD behavior: only authenticate on a specific route
442-
if ($request->attributes->get('_route') !== 'login_route' || !$request->isMethod('POST')) {
443-
return true;
444-
}
441+
// GOOD behavior: only authenticate (i.e. return true) on a specific route
442+
return 'login_route' === $request->attributes->get('_route') && $request->isMethod('POST');
445443

446444
// e.g. your login system authenticates by the user's IP address
447445
// BAD behavior: So, you decide to *always* return true so that

security/multiple_guard_authenticators.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ This is how your security configuration can look in action:
7878
),
7979
));
8080
81+
If your authenticators need separate providers, you will need to create a
82+
:doc:`chain of user providers </security/multiple_user_providers>`.
83+
8184
There is one limitation with this approach - you have to use exactly one entry point.
8285

8386
Multiple Authenticators with Separate Entry Points

0 commit comments

Comments
 (0)