Fix empty database lists for Console OAuth tokens without admin mode (#12839)

* Fix OAuth owner tokens leaving document auth enabled without admin mode

Console OAuth bearer tokens (CLI/MCP) never sent X-Appwrite-Mode: admin, so
document authorization stayed on and databases without $permissions listed empty.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Improve quality

* All admin mode patch occurances

* Do not run project READ check for OAuth owner keys

OAuth owner tokens skip the admin membership role-loading branch, so the
project READ safety net false-negatives with PROJECT_NOT_FOUND. Keep the
auth bypass without admin mode; ownership is enforced at grant time.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Rely on normalized admin mode for OAuth owner requests

Keep OAuth-specific classification at the request boundary and limit the shared API change to skipping the session-only project permission check.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Matej Bačo <matejbaco2000@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-07-10 18:19:13 +05:30
1 parent 43265d6683
commit d8b569b564
1 file changed
+1 -1
+1 -1
View File
@@ -369,7 +369,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) || $isOAuthAdminKey)) {
if ($isAdminProjectRequest && empty($apiKey)) {
$input = new Input(Database::PERMISSION_READ, $project->getPermissionsByType(Database::PERMISSION_READ));
$initialStatus = $authorization->getStatus();
$authorization->enable();