From 9c15cd0df082a553b9437639cb8d421e3c399274 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 16 Jul 2024 14:00:07 -0400 Subject: [PATCH 1/7] DOCSP-41241: Laravel Sanctum --- docs/includes/auth/Sanctum.php | 16 ++++++++++ docs/user-authentication.txt | 56 ++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 docs/includes/auth/Sanctum.php diff --git a/docs/includes/auth/Sanctum.php b/docs/includes/auth/Sanctum.php new file mode 100644 index 000000000..71cdbdedd --- /dev/null +++ b/docs/includes/auth/Sanctum.php @@ -0,0 +1,16 @@ +`__ +section of the Sanctum documentation. + +.. _laravel-user-auth-reminders: + +Password Reminders +~~~~~~~~~~~~~~~~~~ To add support for MongoDB-based password reminders, register the following service provider in your application: @@ -111,7 +161,7 @@ This service provider modifies the internal ``DatabaseReminderRepository`` to enable password reminders. Example -~~~~~~~ +``````` The following code updates the ``providers.php`` file in the ``bootstrap`` directory of a Laravel application to register the ``PasswordResetServiceProvider`` provider: From 854af2645330237bce628839932e115d2b71886c Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 16 Jul 2024 18:01:56 +0000 Subject: [PATCH 2/7] apply phpcbf formatting --- docs/includes/auth/Sanctum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/includes/auth/Sanctum.php b/docs/includes/auth/Sanctum.php index 71cdbdedd..2a3c5e29c 100644 --- a/docs/includes/auth/Sanctum.php +++ b/docs/includes/auth/Sanctum.php @@ -13,4 +13,4 @@ class PersonalAccessToken extends SanctumToken protected $collection = 'personal_access_tokens'; protected $primaryKey = '_id'; protected $keyType = 'string'; -} \ No newline at end of file +} From 8c5882c64771d2e24e82d4ae9be6e420f9bd5e27 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 16 Jul 2024 15:26:41 -0400 Subject: [PATCH 3/7] edits --- docs/user-authentication.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/user-authentication.txt b/docs/user-authentication.txt index 4562249be..cb099fe89 100644 --- a/docs/user-authentication.txt +++ b/docs/user-authentication.txt @@ -126,6 +126,12 @@ then publish and run its migration files: php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" php artisan migrate +.. tip:: + + To learn more about installing and configuring Laravel Sanctum, see the + `Installation `__ + section of the Laravel Sanctum guide. + To use Laravel Sanctum with {+odm-short+}, you must modify the ``PersonalAccessToken`` model provided by Sanctum. @@ -143,7 +149,7 @@ After modifying the ``PersonalAccessToken`` model, instruct Sanctum to use the c model by calling the ``usePersonalAccessTokenModel()`` method in one of your application's service providers. To learn more, see the `Overriding Default Models `__ -section of the Sanctum documentation. +section of the Laravel Sanctum guide. .. _laravel-user-auth-reminders: From 4122cc2809b08488670492efb66c048faa237693 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 16 Jul 2024 15:37:59 -0400 Subject: [PATCH 4/7] code edit, change depth --- .../auth/{Sanctum.php => PersonalAccessToken.php} | 0 docs/user-authentication.txt | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) rename docs/includes/auth/{Sanctum.php => PersonalAccessToken.php} (100%) diff --git a/docs/includes/auth/Sanctum.php b/docs/includes/auth/PersonalAccessToken.php similarity index 100% rename from docs/includes/auth/Sanctum.php rename to docs/includes/auth/PersonalAccessToken.php diff --git a/docs/user-authentication.txt b/docs/user-authentication.txt index cb099fe89..97a0883cf 100644 --- a/docs/user-authentication.txt +++ b/docs/user-authentication.txt @@ -14,7 +14,7 @@ User Authentication .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecol Overview @@ -120,7 +120,7 @@ uses Laravel's cookie-based authentication services. Run the following commands from your project root to install Laravel Sanctum, then publish and run its migration files: -.. code-block:: php +.. code-block:: bash composer require laravel/sanctum php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" @@ -130,8 +130,8 @@ then publish and run its migration files: To learn more about installing and configuring Laravel Sanctum, see the `Installation `__ - section of the Laravel Sanctum guide. - + section of the Laravel Sanctum guide. + To use Laravel Sanctum with {+odm-short+}, you must modify the ``PersonalAccessToken`` model provided by Sanctum. From e9b6a3c3ae0cf1d449c479f9c63a0c9090a53ee7 Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 17 Jul 2024 13:57:17 -0400 Subject: [PATCH 5/7] feedback --- docs/user-authentication.txt | 52 +++++++++++++++++------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/docs/user-authentication.txt b/docs/user-authentication.txt index 97a0883cf..c4334f073 100644 --- a/docs/user-authentication.txt +++ b/docs/user-authentication.txt @@ -100,8 +100,11 @@ manage user authentication, as shown in the following code: Customize User Authentication ----------------------------- -In this section, you can learn how to use the following features to -customize your MongoDB user authentication process: +You can customize your authentication files to align with your application's +needs and enable additional authentication features. + +This section describes how to use the following features to customize the MongoDB user +authentication process: - :ref:`laravel-user-auth-sanctum` - :ref:`laravel-user-auth-reminders` @@ -111,45 +114,40 @@ customize your MongoDB user authentication process: Laravel Sanctum ~~~~~~~~~~~~~~~ -You can install the Laravel Sanctum package to provide API tokens to users -and authenticate single-page applications. To manage API tokens, Sanctum stores -each token in a database table and authenticates incoming HTTP requests through -the ``Authorization`` header. To authenticate single-page applications, Sanctum -uses Laravel's cookie-based authentication services. +Laravel Sanctum is an authentication package that can manage API requests and +single-page application authentication. To manage API requests, Sanctum issues +API tokens that are stored in a database table and authenticates incoming HTTP +requests by using the ``Authorization`` header. To authenticate single-page applications, +Sanctum uses Laravel's cookie-based authentication services. -Run the following commands from your project root to install Laravel Sanctum, -then publish and run its migration files: +You can install Laravel Sanctum to manage your application's authentication +process. Run the following commands from your project root to install Laravel +Sanctum and publish its migration file: .. code-block:: bash composer require laravel/sanctum php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" - php artisan migrate - -.. tip:: - - To learn more about installing and configuring Laravel Sanctum, see the - `Installation `__ - section of the Laravel Sanctum guide. - -To use Laravel Sanctum with {+odm-short+}, you must modify the ``PersonalAccessToken`` -model provided by Sanctum. - -Example -``````` -The following code extends the ``PersonalAccessToken`` model provided by Sanctum +Next, modify the ``PersonalAccessToken`` model provided by Laravel Sanctum to use +Sanctum with {+odm-short+}. The following code extends the ``PersonalAccessToken`` model to enable MongoDB: .. literalinclude:: /includes/auth/PersonalAccessToken.php :language: php :dedent: -After modifying the ``PersonalAccessToken`` model, instruct Sanctum to use the custom -model by calling the ``usePersonalAccessTokenModel()`` method in one of your application's -service providers. To learn more, see the `Overriding Default Models +Then, run the following command to modify the database schema to handle API tokens: + +.. code-block:: bash + + php artisan migrate + +You can now instruct Sanctum to use the custom ``PersonalAccessToken`` model by calling +the ``usePersonalAccessTokenModel()`` method in one of your application's +service providers. To learn more, see `Overriding Default Models `__ -section of the Laravel Sanctum guide. +in the Laravel Sanctum guide. .. _laravel-user-auth-reminders: From bf4b6435250fa25c759f7d3f139058e743993446 Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 17 Jul 2024 14:05:53 -0400 Subject: [PATCH 6/7] edits --- docs/user-authentication.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/user-authentication.txt b/docs/user-authentication.txt index c4334f073..829d97b65 100644 --- a/docs/user-authentication.txt +++ b/docs/user-authentication.txt @@ -129,15 +129,15 @@ Sanctum and publish its migration file: composer require laravel/sanctum php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" -Next, modify the ``PersonalAccessToken`` model provided by Laravel Sanctum to use -Sanctum with {+odm-short+}. The following code extends the ``PersonalAccessToken`` model -to enable MongoDB: +To use Laravel Sanctum with {+odm-short+}, modify the ``PersonalAccessToken`` model provided +by Sanctum to use the ``DocumentModel`` trait from the ``MongoDB\Laravel\Eloquent`` namespace. +The following code modifies the ``PersonalAccessToken`` model to enable MongoDB: .. literalinclude:: /includes/auth/PersonalAccessToken.php :language: php :dedent: -Then, run the following command to modify the database schema to handle API tokens: +Next, run the following command to modify the database schema: .. code-block:: bash From 1e49d082eb1399d9fc1a55ef55b51bf20f9b1f62 Mon Sep 17 00:00:00 2001 From: rustagir Date: Thu, 18 Jul 2024 14:53:49 -0400 Subject: [PATCH 7/7] JM tech review 1 --- docs/user-authentication.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-authentication.txt b/docs/user-authentication.txt index 829d97b65..ec5ebc9ee 100644 --- a/docs/user-authentication.txt +++ b/docs/user-authentication.txt @@ -116,7 +116,7 @@ Laravel Sanctum Laravel Sanctum is an authentication package that can manage API requests and single-page application authentication. To manage API requests, Sanctum issues -API tokens that are stored in a database table and authenticates incoming HTTP +API tokens that are stored in the database and authenticates incoming HTTP requests by using the ``Authorization`` header. To authenticate single-page applications, Sanctum uses Laravel's cookie-based authentication services.