我试图在Laravel上设置一个带有请求数据标识的多租户,但我找不到任何相关信息。
遵循这个快速启动https://tenancyforlaravel.com/docs/v3/quickstart就这么简单吗
然后按照以下步骤操作?https://tenancyforlaravel.com/docs/v3/tenant-identification/#请求数据标识:~:text=public%20static%20property).-,请求数据标识,-您可能想要
所以改变我的帐篷路线
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains;
/*
|--------------------------------------------------------------------------
| Tenant Routes
|--------------------------------------------------------------------------
|
| Here you can register the tenant routes for your application.
| These routes are loaded by the TenantRouteServiceProvider.
|
| Feel free to customize them however you want. Good luck!
|
*/
Route::middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
Route::get('/', function () {
return 'This is your multi-tenant application. The id of the current tenant is ' . tenant('id');
});
});
对此:
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Middleware\InitializeTenancyByRequestData;
use Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains;
/*
|--------------------------------------------------------------------------
| Tenant Routes
|--------------------------------------------------------------------------
|
| Here you can register the tenant routes for your application.
| These routes are loaded by the TenantRouteServiceProvider.
|
| Feel free to customize them however you want. Good luck!
|
*/
Route::middleware([
'web',
InitializeTenancyByRequestData::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
Route::get('/', function () {
return 'This is your multi-tenant application. The id of the current tenant is ' . tenant('id');
});
});
1条答案
按热度按时间ubof19bj1#
接下来应该做的是创建一个中间件,在其中验证头部中的x-tenant或文档中建议的查询参数。
我附上了一个例子来处理头文件,JWT应该是这样的:
当然,您必须根据应用的性质考虑其他安全方面。