From 97017dd52216d94f3e105ff9a5c5ac800cd7d031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 21 Dec 2019 13:36:53 +0100 Subject: [PATCH] Passport integration documented --- docs/navigation.php | 1 + docs/source/v2/nova.blade.md | 2 +- docs/source/v2/passport.blade.md | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 docs/source/v2/passport.blade.md diff --git a/docs/navigation.php b/docs/navigation.php index 9ad2bfa..9f41272 100644 --- a/docs/navigation.php +++ b/docs/navigation.php @@ -105,6 +105,7 @@ return [ 'children' => [ 'Spatie Packages' => 'spatie', 'Horizon' => 'horizon', + 'Passport' => 'passport', 'Nova' => 'nova', 'Telescope' => 'telescope', ], diff --git a/docs/source/v2/nova.blade.md b/docs/source/v2/nova.blade.md index 78a0bc6..029a82e 100644 --- a/docs/source/v2/nova.blade.md +++ b/docs/source/v2/nova.blade.md @@ -7,7 +7,7 @@ section: content # Nova Integration {#nova-integration} -To make Nova part of your tenant application, do the following: +To use Nova inside of the tenant part of your application, do the following: - Publish the Nova migrations and move them to the `database/migrations/tenant` directory. ```none php artisan vendor:publish --tag=nova-migrations diff --git a/docs/source/v2/passport.blade.md b/docs/source/v2/passport.blade.md new file mode 100644 index 0000000..a6ad949 --- /dev/null +++ b/docs/source/v2/passport.blade.md @@ -0,0 +1,41 @@ +--- +title: Passport Integration +description: Passport Integration +extends: _layouts.documentation +section: content +--- + +# Passport Integration {#passport-integration} + +> If you just want to write an SPA, but don't need an API for some other use (e.g. mobile app), you can avoid **a lot** of the complexity of writing SPAs by using [Inertia.js](https://inertiajs.com). + +To use Passport inside the tenant part of your application, you may do the following. + +- Add this to the `register` method in your `AppServiceProvider`: + ```php + Passport::ignoreMigrations(); + Passport::routes(null, ['middleware' => 'tenancy']); + ``` +- `php artisan vendor:publish --tag=passport-migrations` & move to `database/migrations/tenant/` directory + +## Shared keys + +If you want to use the same keypair for all tenants, do the following. + +- Don't use `passport:install`, use just `passport:keys`. The install command creates keys & two clients. Instead of creating clients centrally, create `Client`s manually in your [tenant database seeder]({{ $page->link('configuration/#seed-after-migration') }}). + +## Tenant-specific keys + +If you want to use a unique keypair for each tenant, do the following. (Note: The security benefit of doing this isn't probably that big, since you're likely already using the same `APP_KEY` for all tenants.) + +There are multiple ways you can store & load tenant keys, but the most straightforward way is to store the keys in the [Tenant Storage]({{ $page->link('tenant-storage') }}) and load them into the `passport` configuration using the [Tenant Config]({{ $page->link('features/tenant-config') }}) feature: +- Uncomment the `TenantConfig` line in your `tenancy.features` config +- Add these keys to your `tenancy.storage_to_config_map` config: + ```php + 'storage_to_config_map' => [ + 'passport_public_key' => 'passport.public_key', + 'passport_private_key' => 'passport.private_key', + ], + ``` + +And again, you need to create clients in your tenant database seeding process.