diff --git a/security.rst b/security.rst index ebeca1b9b5b..070c18b687c 100644 --- a/security.rst +++ b/security.rst @@ -96,7 +96,59 @@ optional features, like :doc:`remember me ` and :doc:`impersonation `. Fortunately, the ``make:user`` command already configured one for you in your -``security.yaml`` file under the ``providers`` key. +``security.yaml`` file under the ``providers`` key: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + # ... + + providers: + # used to reload user from session & other features (e.g. switch_user) + app_user_provider: + entity: + class: App\Entity\User + property: email + + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use App\Entity\User; + + $container->loadFromExtension('security', [ + // ... + + 'providers' => [ + // used to reload user from session & other features (e.g. switch_user) + 'app_user_provider' => [ + 'entity' => [ + 'class' => User::class, + 'property' => 'email', + ], + ], + ], + ]); If your ``User`` class is an entity, you don't need to do anything else. But if your class is *not* an entity, then ``make:user`` will also have generated a