From c31340bff0219f4ae2f1b7f01d37aa4f93b1653d Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 14 Jun 2023 08:30:33 +0200 Subject: [PATCH] Only grant the permissions from the static property in the user creation job --- src/Jobs/CreatePostgresUserForTenant.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Jobs/CreatePostgresUserForTenant.php b/src/Jobs/CreatePostgresUserForTenant.php index d4afe78b..8818bed0 100644 --- a/src/Jobs/CreatePostgresUserForTenant.php +++ b/src/Jobs/CreatePostgresUserForTenant.php @@ -17,6 +17,8 @@ class CreatePostgresUserForTenant implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + public static array $permissions = ['ALL']; + /** * Create a new job instance. * @@ -57,7 +59,10 @@ class CreatePostgresUserForTenant implements ShouldQueue foreach ($tenantModels as $model) { $table = $model->getTable(); - $databaseManager->database()->statement("GRANT ALL ON {$table} TO \"{$userName}\""); + foreach (static::$permissions as $permission) { + $databaseManager->database()->statement("GRANT {$permission} ON {$table} TO \"{$userName}\""); + } + $databaseManager->database()->statement("GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO \"{$userName}\""); } });