From e8483e6e6792e8df13a633cdb4ceb3c32f049e66 Mon Sep 17 00:00:00 2001 From: Vincent Amstoutz Date: Mon, 9 Dec 2024 11:55:52 +0100 Subject: [PATCH] docs(fosuser-bundle): move from core to symfony and update --- core/jwt.md | 2 +- outline.yaml | 2 +- {core => symfony}/fosuser-bundle.md | 23 ++++++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-) rename {core => symfony}/fosuser-bundle.md (61%) diff --git a/core/jwt.md b/core/jwt.md index 2ecf6a633cc..8f619ba3aeb 100644 --- a/core/jwt.md +++ b/core/jwt.md @@ -65,7 +65,7 @@ We're not done yet! Let's move on to configuring the Symfony SecurityBundle for It is necessary to configure a user provider. You can either use the [Doctrine entity user provider](https://symfony.com/doc/current/security/user_provider.html#entity-user-provider) provided by Symfony (recommended), [create a custom user provider](https://symfony.com/doc/current/security/user_provider.html#creating-a-custom-user-provider) -or use [API Platform's FOSUserBundle integration](fosuser-bundle.md) (not recommended). +or use [API Platform's FOSUserBundle integration](../symfony/fosuser-bundle.md) (not recommended). If you choose to use the Doctrine entity user provider, start by [creating your `User` class](https://symfony.com/doc/current/security.html#a-create-your-user-class). diff --git a/outline.yaml b/outline.yaml index e76d8dcba6f..0e36b3614b9 100644 --- a/outline.yaml +++ b/outline.yaml @@ -10,6 +10,7 @@ chapters: - debugging - caddy - migrate-from-fosrestbundle + - fosuser-bundle - title: "API Platform for Laravel" path: laravel items: @@ -65,7 +66,6 @@ chapters: - user - form-data - angularjs-integration - - fosuser-bundle - nelmio-api-doc - bootstrap - configuration diff --git a/core/fosuser-bundle.md b/symfony/fosuser-bundle.md similarity index 61% rename from core/fosuser-bundle.md rename to symfony/fosuser-bundle.md index dc5cbdb8c81..ce8378ad8b4 100644 --- a/core/fosuser-bundle.md +++ b/symfony/fosuser-bundle.md @@ -1,15 +1,20 @@ -# FOSUserBundle Integration +# FOSUserBundle Integration with Symfony + +> [!WARNING] +> The use of FOSUserBundle is no longer recommended for better flexibility and security. It is advised to switch to the +> [Doctrine entity user provider](https://symfony.com/doc/current/security/user_provider.html#entity-user-provider) (recommended) +> or consider [creating a custom user provider](https://symfony.com/doc/current/security/user_provider.html#creating-a-custom-user-provider). ## Installing the Bundle -The installation procedure of the FOSUserBundle is described [in the main Symfony docs](https://symfony.com/doc/master/bundles/FOSUserBundle/index.html) +The installation procedure of the FOSUserBundle is described [in the FOSUserBundle documentation](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/docs/index.rst). You can: -- Skip [step 3 (Create your User class)](https://symfony.com/doc/master/bundles/FOSUserBundle/index.html#step-3-create-your-user-class) +- Skip [step 3 (Create your User class)](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/docs/index.rst#step-3-create-your-user-class) and use the class provided in the next paragraph to set up serialization groups the correct way -- Skip [step 4 (Configure your application's security.yml)](https://symfony.com/doc/master/bundles/FOSUserBundle/index.html#step-4-configure-your-application-s-security-yml) - if you are planning to [use a JWT-based authentication using `LexikJWTAuthenticationBundle`](jwt.md) +- Skip [step 4 (Configure your application's security.yml)](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/docs/index.rst#step-4-configure-your-applications-securityyml) + if you are planning to [use a JWT-based authentication using `LexikJWTAuthenticationBundle`](../core/jwt.md) If you are using the API Platform Standard Edition, you will need to enable the form services in the symfony framework configuration options: @@ -22,11 +27,11 @@ framework: ## Creating a `User` Entity with Serialization Groups -Here's an example of declaration of a [Doctrine ORM User class](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.rst#a-doctrine-orm-user-class). -There's also an example for a [Doctrine MongoDB ODM](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.rst#b-mongodb-user-class). +Here's an example of declaration of a [Doctrine ORM User class](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/docs/index.rst#a-doctrine-orm-user-class). +There's also an example for a [Doctrine MongoDB ODM](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/docs/index.rst#b-mongodb-user-class). You need to use serialization groups to hide some properties like `plainPassword` (only in read) and `password`. The properties -shown are handled with [`normalizationContext`](serialization.md#normalization), while the properties -you can modify are handled with [`denormalizationContext`](serialization.md#denormalization). +shown are handled with [`normalizationContext`](../core/serialization.md#normalization), while the properties +you can modify are handled with [`denormalizationContext`](../core/serialization.md#denormalization). Create your User entity with serialization groups: