From 2ad0cbf2f8266c487f109a58b0adff4d52551c36 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 25 Jun 2026 13:43:47 +0530 Subject: [PATCH] Clarify OAuth admin key check --- app/controllers/shared/api.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 273c90651e..9387eaed17 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -372,12 +372,11 @@ Http::init() $isAdminProjectRequest = ! $user->isEmpty() && $project->getId() !== 'console' && $mode === APP_MODE_ADMIN; - $isOAuthAdminProjectRequest = ! empty($apiKey) + $isOAuthAdminKey = ! empty($apiKey) && $apiKey->getType() === API_KEY_OAUTH2 - && $apiKey->getRole() === User::ROLE_OWNER - && $isAdminProjectRequest; + && $apiKey->getRole() === User::ROLE_OWNER; - if ($isOAuthAdminProjectRequest) { + if ($isAdminProjectRequest && $isOAuthAdminKey) { $authorization->setDefaultStatus(false); } @@ -391,7 +390,7 @@ Http::init() * But, for actions on resources (sites, functions, etc.) in a non-console project, we explicitly check * whether the admin user has necessary permission on the project (sites, functions, etc. don't have permissions associated to them). */ - if ($isAdminProjectRequest && (empty($apiKey) || $isOAuthAdminProjectRequest)) { + if ($isAdminProjectRequest && (empty($apiKey) || $isOAuthAdminKey)) { $input = new Input(Database::PERMISSION_READ, $project->getPermissionsByType(Database::PERMISSION_READ)); $initialStatus = $authorization->getStatus(); $authorization->enable();