mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Clarify OAuth admin key check
This commit is contained in:
1 file changed
+4
-5
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user