mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 10:14:03 +00:00
Add routes example for 11.x, use AuthServiceProvider instead of AppServiceProvider
This commit is contained in:
parent
4c5bb1f8bc
commit
768a03b0d9
1 changed files with 26 additions and 9 deletions
|
|
@ -29,7 +29,7 @@ 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 `AuthServiceProvider`.
|
||||||
|
|
||||||
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:
|
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
|
```php
|
||||||
|
|
@ -40,7 +40,7 @@ To use Passport inside the tenant part of your application, you may do the follo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
5. 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`:
|
5. 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 `AuthServiceProvider`:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
Passport::$registersRoutes = false;
|
Passport::$registersRoutes = false;
|
||||||
|
|
@ -60,18 +60,35 @@ To use Passport inside the tenant part of your application, you may do the follo
|
||||||
7. Set up [the encryption keys](#passport-encryption-keys).
|
7. 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}
|
||||||
To use Passport in both the tenant and the central application, follow [the steps for using Passport in the tenant appliction](#using-passport-in-the-tenant-application-only) with the following adjustments:
|
To use Passport in both the tenant and the central application:
|
||||||
|
|
||||||
1. Copy the Passport migrations to the central application, so that the Passport migrations are in both the central and the tenant application.
|
1. Follow [the steps for using Passport in the tenant appliction](#using-passport-in-the-tenant-application-only).
|
||||||
2. Remove `Passport::ignoreMigrations()` from the `register` method in your `AppServiceProvider` (if it is there).
|
2. Copy the Passport migrations to the central application, so that the Passport migrations are in both the central and the tenant application.
|
||||||
3. In your `AuthServiceProvider`'s `boot` method, add the `'universal'` middleware to the Passport routes, and remove the `PreventAccessFromCentralDomains::class` middleware (if it is there). The routes should look like this:
|
3. Remove `Passport::ignoreMigrations()` from the `register` method in your `AuthServiceProvider` (if it is there).
|
||||||
|
4. In your `AuthServiceProvider`, add the `'universal'` middleware to the Passport routes, and remove the `PreventAccessFromCentralDomains::class` middleware (if it is there). The routes should look like this:
|
||||||
```php
|
```php
|
||||||
|
// Passport 10.x
|
||||||
Passport::routes(null, ['middleware' => [
|
Passport::routes(null, ['middleware' => [
|
||||||
'universal',
|
'universal',
|
||||||
InitializeTenancyByDomain::class
|
InitializeTenancyByDomain::class
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
|
// Passport 11.x
|
||||||
|
Passport::$registersRoutes = false;
|
||||||
|
|
||||||
|
Route::group([
|
||||||
|
'as' => 'passport.',
|
||||||
|
'middleware' => [
|
||||||
|
'universal',
|
||||||
|
InitializeTenancyByDomain::class
|
||||||
|
],
|
||||||
|
'prefix' => config('passport.path', 'oauth'),
|
||||||
|
'namespace' => 'Laravel\Passport\Http\Controllers',
|
||||||
|
], function () {
|
||||||
|
$this->loadRoutesFrom(__DIR__ . "/../../vendor/laravel/passport/src/../routes/web.php");
|
||||||
|
});
|
||||||
```
|
```
|
||||||
4. Enable [universal routes]({{ $page->link('features/universal-routes') }}) to make Passport routes accessible to both apps.
|
5. Enable [universal routes]({{ $page->link('features/universal-routes') }}) to make Passport routes accessible to both apps.
|
||||||
|
|
||||||
## **Passport encryption keys** {#passport-encryption-keys}
|
## **Passport encryption keys** {#passport-encryption-keys}
|
||||||
### **Shared keys** {#shared-keys}
|
### **Shared keys** {#shared-keys}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue