Open boldstar opened 3 years ago
@boldstar you need to use the tenant id (auto increment) value and not the uuid of the tenant.
@bkintanar , thanks for the reply.
So changing to using the id in the terminal does not run the command properly either. Also if I try running it via Artisan:call()
, it trys running it on my system database instead of my tenant database. But prior to running the command I set my environment to the tenant like so
app(Environment::class)->tenant($website);
Artisan::call('tenancy:run', ['run' => 'passport:install', '--tenant' => [$website->id]]);
@bkintanar , I am not sure if this will help but below is an image of the sequence when it trys running the artisan command it switches to the system instead of the tenant
"traxit" is my system database where the 'oauth_clients' table does not exist.
Using Passport with hyn/multi-tenant is tricky.... I think you need to follow this Medium post (it is old, but I think it still holds true on how to make Passport work) https://medium.com/@sadnub/hyn-tenancy-5-2-and-laravel-passport-a0d11c5a08eb.
You might need to do the following: 1) create a middleware: https://gist.github.com/sadnub/cd37aaeea50ed35eac264c4729e710b3#file-enforcetenancy-php 2) Add it to your http route kernel
protected $routeMiddleware = [
//[...]
'tenancy.enforce' => \App\Http\Middleware\EnforceTenancy::class,`
];
3) In the boot function of a service provider (e.g: AuthServiceProvider) add:
```php
\Laravel\Passport\Passport::routes(static function ($router){
// Comment or uncomment depending on what you need
// $router->forAuthorization();
$router->forAccessTokens();
// $router->forTransientTokens();
// $router->forClients();
// $router->forPersonalAccessTokens();
}, ['middleware' => 'tenancy.enforce']); <--- Tell passport to use this middleware, which should force the connection on the tenant.
Hope this works.
Description
Artisan:call('passport:install') not working on hyn/multi-tenant 5.6
Actual behavior
Does not run artisan command. When I try doing it manually using the following
php artisan tenancy:run passport:install --tenant=2abd4feed4404fba85ba5462190453cb
in the terminal it tells me that command was executed on zero tenants.Expected behavior
Seeds respective passport oauth client tables on tenant databases when the
Artisan:call('passport:install')
is called or whenArtisan::call('tenancy:run', ['run' => 'passport:install', '--tenant' => [$website->uuid]]);
is calledInformation
tenancy.php config
webserver.php config
Error log