fix(site): include owner context in Agents org picker permission check - #28076
fix(site): include owner context in Agents org picker permission check#28076ibetitsmike wants to merge 2 commits into
Conversation
The per-org authcheck behind the Agents org picker checked chat:create without owner_id, but the agents-access role grants chat permissions at org-member scope, which requires the checked object to be owned by the caller. Every org check returned false, so the picker never rendered and the workspace attach list stayed filtered to the default org, showing "No workspaces found" for users whose workspaces live in another org. Pass owner_id: "me" so the per-org check matches the page-level createChat check semantics.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 831c62fc62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Export permittedOrganizationsKey from api/queries/organizations and use it in the stories instead of hand-building the private query key (FE7). Exercise the picker in the regression story: open it, assert both orgs are offered, and select the non-default org (FE1).
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes the Agents org picker and workspace attach menu for users whose only chat grant comes from the member-scoped "Coder Agents User" (
agents-access) org role (PRODUCT-552).Problem
The per-org authcheck behind the org picker checked
chat:createwith onlyorganization_id. Theagents-accessrole grants chat permissions at org-member scope, which requires the checked object to be owned by the caller (policy.regoorg_memberrequires a non-empty owner matching the subject). With noowner_id, every org check returnedfalse, so:permittedOrgs.length > 1gate),The page-level
createChatcheck already includesowner_id: "me", which is why the same user could load the page and create chats via the API.Fix
Pass
owner_id: "me"in thepermittedOrganizationsseed check inAgentCreateForm, matching the page-level check's semantics. ThepermittedOrganizationshelper spreads the check object through, so each per-org check now carries owner context and the backend substitutes the caller's user ID.The other
permittedOrganizationscallsites (organization_member:create,template:create) check org-scoped admin permissions and correctly omitowner_id.Adds a regression story whose
checkAuthorizationmock only allows checks carryingowner_id: "me"(mirroring the RBAC member-scope behavior); it fails without the fix and passes with it (red-green verified).Validation
pnpm -C site checkandpnpm -C site lint:typesclean.chat:createwithowner_id: "me"returns true, without it returns false.