Update passport.blade.md (#81)

I managed to get passport work with this code, not really sure if loadKeysFrom should be in boot method and if overriding passport config is proper way.
This commit is contained in:
Michał Maliński 2020-09-27 19:29:06 +02:00 committed by GitHub
parent 97b275ffba
commit 25747b5c4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,14 +22,50 @@ To use Passport inside the tenant part of your application, you may do the follo
PreventAccessFromCentralDomains::class, PreventAccessFromCentralDomains::class,
]]); ]]);
``` ```
- Add this to `boot` method in your `AppServiceProvider`:
```php
Passport::loadKeysFrom(base_path(config('passport.key_path')));
```
- `php artisan vendor:publish --tag=passport-migrations` & move to `database/migrations/tenant/` directory - `php artisan vendor:publish --tag=passport-migrations` & move to `database/migrations/tenant/` directory
- Create `passport.php` file in your config directory and add database connection and key path config. This makes passport use the default connection.
```php
<?php
return [
'storage' => [
'database' => [
'connection' => null,
],
],
'key_path' => env('OAUTH_KEY_PATH', 'storage')
];
```
You may set the OAUTH_KEY_PATH in your .env, but by default `passport:keys` puts them in `storage/` directory
## **Shared keys** ## **Shared keys**
If you want to use the same keypair for all tenants, do the following. 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#seeder-params') }}). - 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#seeder-params') }}), like this:
```php
public function run()
{
$client = new ClientRepository();
$client->createPasswordGrantClient(null, 'Default password grant client', 'http://{{your.redirect.path}}');
$client->createPersonalAccessClient(null, 'Default personal access client', 'http://{{your.redirect.path}}');
}
```
## **Tenant-specific keys** {#tenant-specific-keys} ## **Tenant-specific keys** {#tenant-specific-keys}