From 90208bda6f21ab83b83f911d3f11cee95bef08c5 Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Fri, 5 Feb 2021 00:07:08 +0100 Subject: [PATCH 1/3] Document in memory user extra fields --- security/user_provider.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/security/user_provider.rst b/security/user_provider.rst index 00e7c5a58d8..53fd7914ce0 100644 --- a/security/user_provider.rst +++ b/security/user_provider.rst @@ -289,7 +289,11 @@ Now you can configure all the user information in ``config/packages/security.yam memory: users: john_admin: { password: '$2y$13$jxGxc ... IuqDju', roles: ['ROLE_ADMIN'] } - jane_admin: { password: '$2y$13$PFi1I ... rGwXCZ', roles: ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'] } + jane_admin: { password: '$2y$13$PFi1I ... rGwXCZ', roles: ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'], extra_fields: {'name': 'Jane', 'age': 42}} + +.. versionadded:: 5.3 + + The ``extra_fields`` support was introduced in Symfony 5.3. .. caution:: From 001ca929cbc39a981ae49d2bdfefd184ae8db77b Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Wed, 17 Feb 2021 09:06:18 +0100 Subject: [PATCH 2/3] Update user_provider.rst --- security/user_provider.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/security/user_provider.rst b/security/user_provider.rst index 53fd7914ce0..d59d07b5d97 100644 --- a/security/user_provider.rst +++ b/security/user_provider.rst @@ -294,6 +294,7 @@ Now you can configure all the user information in ``config/packages/security.yam .. versionadded:: 5.3 The ``extra_fields`` support was introduced in Symfony 5.3. + This allows you to retrieve some user data with ``$user->getExtraFields()['age'];`` having a ``$user`` from the Security layer. .. caution:: From 711ca105e5beeda1a12e62666c2088aff88c8825 Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Wed, 24 Feb 2021 09:42:03 +0100 Subject: [PATCH 3/3] Update user_provider.rst --- security/user_provider.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/security/user_provider.rst b/security/user_provider.rst index d59d07b5d97..68b312d8326 100644 --- a/security/user_provider.rst +++ b/security/user_provider.rst @@ -214,9 +214,9 @@ activated), the ``loadUserByUsername()`` method on ``UserRepository`` will be ca Memory User Provider -------------------- -It's not recommended to use this provider in real applications because of its -limitations and how difficult it is to manage users. It may be useful in application -prototypes and for limited applications that don't store users in databases. +It's not recommended to use this provider because of its limitations to manage users. +It nonetheless may be useful in application prototypes and for specific applications +that don't need to have a complex user modelisation. This user provider stores all user information in a configuration file, including their passwords. That's why the first step is to configure how these @@ -288,8 +288,9 @@ Now you can configure all the user information in ``config/packages/security.yam backend_users: memory: users: - john_admin: { password: '$2y$13$jxGxc ... IuqDju', roles: ['ROLE_ADMIN'] } - jane_admin: { password: '$2y$13$PFi1I ... rGwXCZ', roles: ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'], extra_fields: {'name': 'Jane', 'age': 42}} + john_admin: { password: '$2y$13$jxGxc ... IuqDju', roles: ['ROLE_ADMIN'] } + alice_admin: { password: '$2y$13$AMg7Z ... dFxRBA', roles: ['ROLE_ADMIN'], extra_fields: {'name': 'Alice', 'age': 42}} + jane_admin: { password: '$2y$13$PFi1I ... rGwXCZ', roles: ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'] } .. versionadded:: 5.3