From 0340a49bb8659b0182fac16b5edc00113610d31d Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 25 Jun 2026 13:41:15 +0530 Subject: [PATCH] Move OAuth admin request check after key auth --- app/controllers/shared/api.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 5d3643875d..273c90651e 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -165,13 +165,6 @@ Http::init() // Step 4: Get scopes for the role $scopes = $roles[$role]['scopes']; - $isAdminProjectRequest = ! $user->isEmpty() - && $project->getId() !== 'console' - && $mode === APP_MODE_ADMIN; - $isOAuthAdminProjectRequest = ! empty($apiKey) - && $apiKey->getType() === API_KEY_OAUTH2 - && $apiKey->getRole() === User::ROLE_OWNER - && $isAdminProjectRequest; // Step 5: API Key Authentication if (! empty($apiKey)) { @@ -376,6 +369,14 @@ Http::init() $authorization->addRole($authRole); } + $isAdminProjectRequest = ! $user->isEmpty() + && $project->getId() !== 'console' + && $mode === APP_MODE_ADMIN; + $isOAuthAdminProjectRequest = ! empty($apiKey) + && $apiKey->getType() === API_KEY_OAUTH2 + && $apiKey->getRole() === User::ROLE_OWNER + && $isAdminProjectRequest; + if ($isOAuthAdminProjectRequest) { $authorization->setDefaultStatus(false); }