From 62c7f2b6ba2ff1a229dc62c3b8b831cdb2378dd9 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Thu, 21 Nov 2019 22:17:29 +0100 Subject: [PATCH] Security: add example code which Maker Bundle generated See #11265 --- security.rst | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) 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