mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 10:14:03 +00:00
Add instructions for Passport 11.x
This commit is contained in:
parent
fe84b4186f
commit
cbc9a8c31b
1 changed files with 21 additions and 7 deletions
|
|
@ -6,8 +6,6 @@ section: content
|
||||||
|
|
||||||
# Laravel Passport {#laravel-passport}
|
# Laravel Passport {#laravel-passport}
|
||||||
|
|
||||||
> **Note:** This guide is written for Laravel Passport 10.x
|
|
||||||
|
|
||||||
> **Tip:** If you just want to write an SPA application but don't need an API for some other use (e.g., a mobile app), you can avoid a lot of the complexity of writing SPAs by using [Inertia.js](https://inertiajs.com/).
|
> **Tip:** If you just want to write an SPA application but don't need an API for some other use (e.g., a mobile app), you can avoid a lot of the complexity of writing SPAs by using [Inertia.js](https://inertiajs.com/).
|
||||||
|
|
||||||
> **Another tip:** Using Passport only in the central application doesn't require any additional configuration. You can just install it following [the official Laravel Passport documentation](https://laravel.com/docs/9.x/passport).
|
> **Another tip:** Using Passport only in the central application doesn't require any additional configuration. You can just install it following [the official Laravel Passport documentation](https://laravel.com/docs/9.x/passport).
|
||||||
|
|
@ -31,18 +29,34 @@ To use Passport inside the tenant part of your application, you may do the follo
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Prevent Passport migrations from running in the central application by adding `Passport::ignoreMigrations()` to the `register` method in your `AppServiceProvider`.
|
3. Prevent Passport migrations from running in the central application by adding `Passport::ignoreMigrations()` to the `register` method in your `AppServiceProvider`.
|
||||||
|
|
||||||
4. Apply Passport migrations by running `php artisan tenants:migrate`.
|
4. If you're using Passport 10.x, register the Passport routes in your `AuthServiceProvider` by adding the following code to the provider's `boot` method:
|
||||||
|
```php
|
||||||
5. Register the Passport routes in your `AuthServiceProvider` by adding the following code to the provider's `boot` method.
|
|
||||||
```php
|
|
||||||
Passport::routes(null, ['middleware' => [
|
Passport::routes(null, ['middleware' => [
|
||||||
InitializeTenancyByDomain::class, // Or other identification middleware of your choice
|
InitializeTenancyByDomain::class, // Or other identification middleware of your choice
|
||||||
PreventAccessFromCentralDomains::class,
|
PreventAccessFromCentralDomains::class,
|
||||||
]]);
|
]]);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
4. If you're using Passport 11.x, disable the automatic Passport route registering and register the routes manually by adding the following code to the `register` method in your `AppServiceProvider`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
Passport::$registersRoutes = false;
|
||||||
|
|
||||||
|
Route::group([
|
||||||
|
'as' => 'passport.',
|
||||||
|
'middleware' => [InitializeTenancyByDomain::class], // Use tenancy initialization middleware of your choice
|
||||||
|
'prefix' => config('passport.path', 'oauth'),
|
||||||
|
'namespace' => 'Laravel\Passport\Http\Controllers',
|
||||||
|
], function () {
|
||||||
|
$this->loadRoutesFrom(__DIR__ . "/../../vendor/laravel/passport/src/../routes/web.php");
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
5. Apply Passport migrations by running `php artisan tenants:migrate`.
|
||||||
|
|
||||||
6. Set up [the encryption keys](#passport-encryption-keys).
|
6. Set up [the encryption keys](#passport-encryption-keys).
|
||||||
|
|
||||||
## **Using Passport in both the tenant and the central application** {#using-passport-in-both-the-tenant-and-the-central-application}
|
## **Using Passport in both the tenant and the central application** {#using-passport-in-both-the-tenant-and-the-central-application}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue