Conversation
Contributor
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
Member
Author
|
Closing in favor of #29581, which covers this more thoroughly (owner-context authorization for model config, MCP servers, and workspace binding; API-key/session-minting gate; suspended/system-user handling). Linear: CODAGT-132
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
POST /api/v2/users/{user}/chats, modeled directly on the existingPOST /api/v2/users/{user}/workspaces(postUserWorkspaces): samehttpmw.ExtractOrganizationMembersParammiddleware, same "authz story" (permission checked on the owner-scoped resource, not on the User object). The target user becomes the chat's owner; the caller who made the request is the initiator recorded in the audit log. This is not chat sharing.Fixes CODAGT-132
Unlike
postUserWorkspaces, a chat's RBACObject is org-scoped (InOrg(OrganizationID)), so the owner must always belong to the requested organization, or they could never read or use their own chat afterward.postUserWorkspacestolerates an owner outside the org because a template pins the org; that doesn't apply here.A caller who can act on behalf of another user (typically a site owner) also cannot bind the resulting chat to a workspace the owner has no SSH access to, even if the caller itself administers that workspace. Ownership equality is used as a conservative proxy for "the owner can use this workspace," except when the path already resolves to the caller themselves (e.g. the
mealias), which behaves exactly like the existing self-service/chatsroute.Review notes
Spawned a Fable 5.1 review pass against the diff before opening this PR. It found two real gaps that are fixed here:
Userobject (site owners) skipped the organization-membership check entirely, so a chat could be created for an owner outside the requested org, one they could never subsequently read or use.Both are covered by new test cases (
OwnerRejectedWhenTargetOutsideRequestedOrganization,OwnerCannotBindChatToWorkspaceOwnerCannotAccess,MeAliasBehavesLikeSelfServiceForOwnWorkspace).Known gaps not addressed in this PR, called out for a follow-up: org-admin-specific test coverage (as opposed to site owner), a positive test for the
mems.User == nilfallback path, and ausername-instead-of-UUID path-param test.Testing
go build ./...go vet ./coderd/...golangci-lint run ./coderd/... ./codersdk/...go test ./coderd/ -run TestPostUserChatsand the surroundingTestPostChats/TestChats/TestPatchChatsuitesmake coderd/apidoc/.gen(swagger docs regenerated)