Clarify OAuth admin key check

This commit is contained in:
Chirag Aggarwal committed 2026-06-25 13:43:47 +05:30
1 parent 0340a49bb8
commit 2ad0cbf2f8
1 file changed
+4 -5
+4 -5
View File
@@ -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();