mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
Make the links work (+ automatic formatting correction)
This commit is contained in:
parent
01d65793c0
commit
8cf0033793
1 changed files with 24 additions and 24 deletions
|
|
@ -8,7 +8,7 @@ section: content
|
|||
|
||||
> **Tip:** If you only want to write a SPA application but don't need an API for some other use (for example, a mobile application), you can avoid much of the complexity by using [Inertia.js](https://inertiajs.com/).
|
||||
|
||||
**Very important:** Don't use the command `passport:install` to avoid issues.
|
||||
**Very important:** Don't use the command `passport:install` to avoid issues.
|
||||
|
||||
## Passport use cases
|
||||
|
||||
|
|
@ -21,18 +21,18 @@ section: content
|
|||
- [**Shared keys**](#shared-keys)
|
||||
- [**Tenant-specific keys**](#tenant-specific-keys)
|
||||
|
||||
### **Using Passport only in central application**
|
||||
You don't have to do anything special in this use case, just install **Laravel Passport** as its official documentation explains:
|
||||
### **Using Passport only in central application** {#using-passport-only-in-central-application}
|
||||
You don't have to do anything special in this use case, just install **Laravel Passport** as its official documentation explains:
|
||||
[Laravel Passport official documentation](https://laravel.com/docs/9.x/passport)
|
||||
|
||||
### **Using Passport only in tenant application**
|
||||
### **Using Passport only in tenant application** {#using-passport-only-in-tenant-application}
|
||||
To use **Laravel Passport** inside the tenant application, you must follow the following steps:
|
||||
|
||||
1. Add this code to the `register` method in your `AppServiceProvider` to prevent Passport migrations from running in the central application:
|
||||
```php
|
||||
Passport::ignoreMigrations();
|
||||
```
|
||||
|
||||
|
||||
2. Register Passport routes adding this code to the `boot` method in your `AuthServiceProvider`:
|
||||
```php
|
||||
Passport::routes(null, ['middleware' => [
|
||||
|
|
@ -40,7 +40,7 @@ To use **Laravel Passport** inside the tenant application, you must follow the f
|
|||
PreventAccessFromCentralDomains::class,
|
||||
]]);
|
||||
```
|
||||
|
||||
|
||||
3. Publish Passport migrations running `php artisan vendor:publish --tag=passport-migrations` command and **move** (not copy) all of them to `database/migrations/tenant/` directory.
|
||||
|
||||
4. Publish Passport config file running `php artisan vendor:publish --tag=passport-config` command. After that, open `config/passport.php` file and set storage database connection to `null`. This will make Passport use the default connection:
|
||||
|
|
@ -59,21 +59,21 @@ To use **Laravel Passport** inside the tenant application, you must follow the f
|
|||
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');
|
||||
}
|
||||
```
|
||||
*You can set your tenants database seeder class in `config/tenancy.php` file at `seeder_parameters` key.*
|
||||
|
||||
```
|
||||
*You can set your tenants database seeder class in `config/tenancy.php` file at `seeder_parameters` key.*
|
||||
|
||||
6. Create Passport keys following [**Manage Passport keys**](#manage-passport-keys) section.
|
||||
|
||||
|
||||
### **Using Passport in both the central and tenant application**
|
||||
|
||||
### **Using Passport in both the central and tenant application** {#using-passport-in-both-the-central-and-tenant-application}
|
||||
To use **Laravel Passport** on central and tenant application, you must follow the following steps:
|
||||
|
||||
1. Enable [**Universal Routes**]({{ $page->link('universal-routes') }}) feature.
|
||||
|
||||
|
||||
2. Register Passport routes adding this code to the `boot` method in your `AuthServiceProvider`:
|
||||
```php
|
||||
Passport::routes(null, ['middleware' => [
|
||||
|
|
@ -81,7 +81,7 @@ To use **Laravel Passport** on central and tenant application, you must follow t
|
|||
PreventAccessFromCentralDomains::class,
|
||||
]]);
|
||||
```
|
||||
|
||||
|
||||
3. Publish Passport migrations running `php artisan vendor:publish --tag=passport-migrations` command and make a **copy** of all of them to `database/migrations/tenant/` directory.
|
||||
|
||||
4. Publish Passport config file running `php artisan vendor:publish --tag=passport-config` command. After that, open `config/passport.php` file and set storage database connection to `null`. This will make Passport use the default connection:
|
||||
|
|
@ -100,26 +100,26 @@ To use **Laravel Passport** on central and tenant application, you must follow t
|
|||
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');
|
||||
}
|
||||
```
|
||||
*You can set your tenants database seeder class in `config/tenancy.php` file at `seeder_parameters` key.*
|
||||
```
|
||||
*You can set your tenants database seeder class in `config/tenancy.php` file at `seeder_parameters` key.*
|
||||
|
||||
6. Create Passport keys following [**Manage Passport keys**](#manage-passport-keys) section.
|
||||
|
||||
|
||||
### **Manage Passport keys**
|
||||
#### **Shared keys**
|
||||
|
||||
### **Manage Passport keys** {#manage-passport-keys}
|
||||
#### **Shared keys** {#shared-keys}
|
||||
If you want to use the same Passport keys for all your tenants and your central application (in case you are using Passport in your central app), you only have to run `php artisan passport:keys` command and you are done.
|
||||
|
||||
#### **Tenant-specific keys**
|
||||
> **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. This is a relatively complex approach, so before implementing it, make sure you really want it.
|
||||
#### **Tenant-specific keys** {#tenant-specific-keys}
|
||||
> **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. This is a relatively complex approach, so before implementing it, make sure you really want it.
|
||||
|
||||
If you want to use an unique Passport keys for each tenant, there are multiple ways you can store and load tenant Passport keys, but the most straightforward way is to store the keys in the `Tenant model` and load them into the passport configuration using the [**Tenant Config**]({{ $page->link('features/tenant-config') }}) feature.
|
||||
If you want to use an unique Passport keys for each tenant, there are multiple ways you can store and load tenant Passport keys, but the most straightforward way is to store the keys in the `Tenant model` and load them into the passport configuration using the [**Tenant Config**]({{ $page->link('features/tenant-config') }}) feature.
|
||||
|
||||
Once the [**Tenant Config**]({{ $page->link('features/tenant-config') }}) feature is enabled, simply map your tenant Passport keys into the `boot` method of your `TenancyServiceProvider` as follows:
|
||||
Once the [**Tenant Config**]({{ $page->link('features/tenant-config') }}) feature is enabled, simply map your tenant Passport keys into the `boot` method of your `TenancyServiceProvider` as follows:
|
||||
```php
|
||||
\Stancl\Tenancy\Features\TenantConfig::$storageToConfigMap = [
|
||||
'passport_public_key' => 'passport.public_key',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue