Skip to content

fix(organization): evaluate project roles against the project in the path - #14787

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/organization-project-roles
Oct 22, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/organization-project-roles

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Console members can hold roles limited to one project (project-<id>-owner, project-<id>-developer). Organization project routes (/v1/organization/projects/:projectId/...) now grant those roles only for the project named in the path, so a member restricted to one project can manage that project and no other project in the organization.

Changes

  • projectIdFromPath also recognises /v1/organization/projects/:projectId, so the shared API hook binds the request's project header and context project to the path project, as it already does for /v1/projects/:projectId. The deprecated-alias project resolution ignores organization routes.
  • In the admin branch of the shared API hook, organization project routes evaluate project-specific roles against the path project; organization-level routes (list, create) grant only team-wide roles.
  • GET /v1/organization/projects and GET /v1/organization/projects/:projectId keep database authorization on, like /v1/projects, so a member only lists and reads projects they have access to.

Tests

  • ProjectsConsoleClientTest::testProjectSpecificPermissionsForOrganizationProjects: a member with project-A-developer can create keys for, read and update project A through both the console project (with x-appwrite-organization) and admin mode on A, and gets 401 on key create/list, update, delete and project create for sibling project B, a non-200 on reading B, and a project list without B. E2E is verified by CI.

Related: appwrite-labs/cloud#6666

…path

Organization project routes take the target project from the path, but
project-specific console roles were matched against the context project,
so a role on one project counted for sibling projects. Bind the request to
the path project, grant project-specific roles only for that project, and
keep authorization on for organization project reads so lists and gets
return only projects the member can access.

Co-Authored-By: Claude <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Weak assertNotSame(200) masks 5xx as pass (ProjectsConsoleClientTest.php:6819) — The FAILURE assertion for GET /organization/projects/{projectIdB} uses assertNotSame(200, ...) (tests/e2e/Services/Projects/ProjectsConsoleClientTest.php:6819), so a 500/502 crash — e.g. the scoping check throwing instead of returning 401/404 — counts as a pass.

This PR teaches the shared API authorization hook and the project-ID resolution resource to recognize the /v1/organization/projects route family, resolving the project from the path (falling back to console when absent) and enabling authorization checks on GET reads of organization projects, mirroring the existing /v1/projects behavior.

Files Change
app/controllers/shared/api.php Adds organization-project path matching to set the acting project ID and to enable authorization on GET reads.
app/init/resources/request.php Extends project-ID-from-path parsing and deprecated-alias detection to the /v1/organization/projects/ prefix.
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php Adds a console-client E2E test covering project-specific permissions on organization project routes.

Reviewed commit: 1305bae

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Organization project requests now resolve project-specific roles from the project ID in the route, while organization-level project operations continue to require team-wide roles. The project resolver avoids treating these routes as deprecated aliases, and organization project reads use database authorization to filter projects by access.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
app/controllers/shared/api.php Bind organization-project role checks to the path project and enable authorization for organization project reads.
app/init/resources/request.php Recognize organization project paths when resolving project IDs and exclude them from deprecated-alias resolution.
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php Cover project-specific access to organization project and key routes in console and admin modes.

Reviewed 1305bae · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/organization-project-roles (after).

Metric Before After Change
🚀 Requests/sec 213.18 215.2 ⚪ +0.9%
⏱️ Latency P50 81.32 ms 78.83 ms ⚪ -3.1%
⏱️ Latency P95 186.44 ms 193.86 ms ⚪ +4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 78.83 193.86 13,680 215.2 +7.42
Account 160.98 326.35 720 12.03 +70.3
TablesDB 75.66 144.79 7,440 119.33 +2.34
Storage 72.21 172.04 3,600 59.46 -18.85
Functions 118.23 237.86 1,920 32.29 -8.33

Top API waits (after)

API request Max wait (ms)
account.name.update 459.87
account.prefs.update 430.33
tablesdb.rows.create 414.63
functions.delete 391.46
functions.variables.create 373.2

@ChiragAgg5k
ChiragAgg5k merged commit 3f79291 into main Oct 22, 2026
2 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/organization-project-roles branch October 22, 2026 15:17
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
… (backport #14787)

Organization project routes now grant project-specific roles only for the project named in the path, and organization-level routes grant only team-wide roles. Organization project reads keep database authorization on. 1.9 has no projectIdFromPath resource, so the path project is read from the URI inline; the organization key routes do not exist on 1.9 and their test calls are dropped.

(cherry picked from commit 3f79291)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
… (backport #14787)

Organization project routes now grant project-specific roles only for the project named in the path, and organization-level routes grant only team-wide roles. Organization project reads keep database authorization on. 1.9 has no projectIdFromPath resource, so the path project is read from the URI inline; the organization key routes do not exist on 1.9 and their test calls are dropped.

(cherry picked from commit 3f79291)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…ect-roles

fix(organization): evaluate project roles against the project in the path

(cherry picked from commit 3f79291)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant