feat: add sharing info to /workspaces endpoint (#21049)

closes: https://github.com/coder/internal/issues/858

Similar to https://github.com/coder/coder/pull/19375, this one uses
system permissions for fetching actual user and group data.

Modifies the `workspaces_expanded` view to fetch the required data; this way it's made available to all code paths that make use of it.  

Also fixes a bug in a test helper function that can result in `null` being saved to the DB for `user_acl` or `group_acl` and break tests; a defensive check constraint that prevents this is worth a PR, e.g:

`ALTER TABLE workspaces
   ADD CONSTRAINT group_acl_is_object CHECK (jsonb_typeof(group_acl) = 'object');`

Also adds missing  `OwnerName` in `ConvertWorkspaceRows`.
This commit is contained in:
George K
2025-12-15 08:42:08 -08:00
committed by GitHub
parent 7ecfd1aa07
commit 103967ed02
22 changed files with 838 additions and 92 deletions
+66
View File
@@ -295,6 +295,17 @@ of the template will be used.
"owner_avatar_url": "string",
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
"owner_name": "string",
"shared_with": [
{
"actor_type": "group",
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"roles": [
"admin"
]
}
],
"task_id": {
"uuid": "string",
"valid": true
@@ -589,6 +600,17 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
"owner_avatar_url": "string",
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
"owner_name": "string",
"shared_with": [
{
"actor_type": "group",
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"roles": [
"admin"
]
}
],
"task_id": {
"uuid": "string",
"valid": true
@@ -908,6 +930,17 @@ of the template will be used.
"owner_avatar_url": "string",
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
"owner_name": "string",
"shared_with": [
{
"actor_type": "group",
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"roles": [
"admin"
]
}
],
"task_id": {
"uuid": "string",
"valid": true
@@ -1188,6 +1221,17 @@ curl -X GET http://coder-server:8080/api/v2/workspaces \
"owner_avatar_url": "string",
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
"owner_name": "string",
"shared_with": [
{
"actor_type": "group",
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"roles": [
"admin"
]
}
],
"task_id": {
"uuid": "string",
"valid": true
@@ -1483,6 +1527,17 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace} \
"owner_avatar_url": "string",
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
"owner_name": "string",
"shared_with": [
{
"actor_type": "group",
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"roles": [
"admin"
]
}
],
"task_id": {
"uuid": "string",
"valid": true
@@ -2037,6 +2092,17 @@ curl -X PUT http://coder-server:8080/api/v2/workspaces/{workspace}/dormant \
"owner_avatar_url": "string",
"owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
"owner_name": "string",
"shared_with": [
{
"actor_type": "group",
"avatar_url": "http://example.com",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"roles": [
"admin"
]
}
],
"task_id": {
"uuid": "string",
"valid": true