feat: add shared_with_group: and shared_with_user: filters to /workspaces endpoint (#19875)

Adds shared_with_user and shared_with_group filters to the /workspaces
endpoint.

- `shared_with_user`: filters workspaces shared with a specific user.
Accepts a user UUID or username.
- `shared_with_group`: filters workspaces shared with a specific group.
Accepts:
  - a group UUID, or
  - `<organization name>/<group name>`, or
  - `<group name>` (resolved in the default organization).


Closes
[coder/internal#1004](https://github.com/coder/internal/issues/1004)
This commit is contained in:
Brett Kolodny
2025-09-19 16:05:27 -04:00
committed by GitHub
parent 40ffb79057
commit 38ca98745b
8 changed files with 407 additions and 9 deletions
+12 -1
View File
@@ -384,7 +384,18 @@ WHERE
(workspaces.user_acl != '{}'::jsonb OR workspaces.group_acl != '{}'::jsonb) = sqlc.narg('shared') :: boolean
ELSE true
END
-- Filter by shared_with_user_id
AND CASE
WHEN @shared_with_user_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN
workspaces.user_acl ? (@shared_with_user_id :: uuid) :: text
ELSE true
END
-- Filter by shared_with_group_id
AND CASE
WHEN @shared_with_group_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN
workspaces.group_acl ? (@shared_with_group_id :: uuid) :: text
ELSE true
END
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaces
-- @authorize_filter
), filtered_workspaces_order AS (