diff --git a/app/Http/Controllers/Admin/ApiController.php b/app/Http/Controllers/Admin/ApiController.php index e74dcc9918..de7d541549 100644 --- a/app/Http/Controllers/Admin/ApiController.php +++ b/app/Http/Controllers/Admin/ApiController.php @@ -68,7 +68,8 @@ public function store(StoreApplicationApiKeyRequest $request): RedirectResponse $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([ 'memo' => $request->input('memo'), 'user_id' => $request->user()->id, - ], $request->getKeyPermissions()); + 'permissions' => $request->getKeyPermissions(), + ]); $this->alert->success('A new application API key has been generated for your account.')->flash(); diff --git a/app/Services/Api/KeyCreationService.php b/app/Services/Api/KeyCreationService.php index 66151d28a7..d2649fb22b 100644 --- a/app/Services/Api/KeyCreationService.php +++ b/app/Services/Api/KeyCreationService.php @@ -26,7 +26,7 @@ public function setKeyType(int $type): self * * @throws \App\Exceptions\Model\DataValidationException */ - public function handle(array $data, array $permissions = []): ApiKey + public function handle(array $data): ApiKey { $data = array_merge($data, [ 'key_type' => $this->keyType, @@ -34,8 +34,8 @@ public function handle(array $data, array $permissions = []): ApiKey 'token' => str_random(ApiKey::KEY_LENGTH), ]); - if ($this->keyType === ApiKey::TYPE_APPLICATION) { - $data['permissions'] = array_merge($data['permissions'], $permissions); + if ($this->keyType !== ApiKey::TYPE_APPLICATION) { + unset($data['permissions']); } return ApiKey::query()->forceCreate($data); diff --git a/app/Services/Nodes/NodeAutoDeployService.php b/app/Services/Nodes/NodeAutoDeployService.php index ace7fd199b..5ebeeca505 100644 --- a/app/Services/Nodes/NodeAutoDeployService.php +++ b/app/Services/Nodes/NodeAutoDeployService.php @@ -38,7 +38,8 @@ public function handle(Request $request, Node $node, ?bool $docker = false): ?st $key = $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([ 'memo' => 'Automatically generated node deployment key.', 'user_id' => $request->user()->id, - ], ['permissions' => [Node::RESOURCE_NAME => AdminAcl::READ]]); + 'permissions' => [Node::RESOURCE_NAME => AdminAcl::READ], + ]); } $token = $key->identifier . $key->token;