Skip to content

feat: add endpoint for retrieving workspace acl #19375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

aslilac
Copy link
Member

@aslilac aslilac commented Aug 15, 2025

Implements /acl [get] for workspaces, with tests.

One big concern this PR is starting to bring up: users that have workspace.share will also need org_member.read and group.read within their organization, or they won't actually be able to share with anyone. However, giving everyone org_member.read and group.read would probably agitate some of our more security conscious customers and not giving it to anyone would either just be lying about our security model or would make the feature useless.

This is probably going to have to be solved by reimplementing the default "organization member" role as a custom role, which we were already planning on doing anyway. Just something important to keep in mind when we get to that point.

It's worth noting that all of this applies to template ACL as well, but in that case we kind of got away with it because usually only admins can see/edit template ACLs. For workspaces, that is very much not the case. Still, we might actually want to go back and fix this same issue for templates.

@aslilac aslilac requested a review from Emyrk August 15, 2025 20:00
@aslilac aslilac marked this pull request as ready for review August 15, 2025 21:01
Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

I see we do not return the workspace ACL as apart of the workspace get, and instead require a new query for it.

I am guessing this is because of permissions. I do not think it's crazy to say if you can read a workspace, you can also read the list of people it is shared with.

Comment on lines +2224 to +2245
groups := make([]codersdk.WorkspaceGroup, 0, len(dbGroups))
for _, it := range dbGroups {
var members []database.GroupMember
// For context see https://github.com/coder/coder/pull/19375
// nolint:gocritic
members, err = api.Database.GetGroupMembersByGroupID(dbauthz.AsSystemRestricted(ctx), database.GetGroupMembersByGroupIDParams{
GroupID: it.Group.ID,
IncludeSystem: false,
})
if err != nil {
httpapi.InternalServerError(rw, err)
return
}
groups = append(groups, codersdk.WorkspaceGroup{
Group: db2sdk.Group(database.GetGroupsRow{
Group: it.Group,
OrganizationName: it.OrganizationName,
OrganizationDisplayName: it.OrganizationDisplayName,
}, members, len(members)),
Role: convertToWorkspaceRole(workspaceACL.Groups[it.Group.ID.String()].Permissions),
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. Can we just make some MinimialGroup type that does not require fetching all members in the group?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking this could be nice for showing the users that are in a group on the sharing page, but maybe we could require a click for that and have it be a separate query.

@aslilac
Copy link
Member Author

aslilac commented Aug 22, 2025

I do not think it's crazy to say if you can read a workspace, you can also read the list of people it is shared with.

I agree, but I think we need to actually accommodate that in the permissions users are given, rather than hack around it. While we are hacking around it, I think it needs to be kept to an endpoint that's only available with the experiment.

Since it's not stable, we can decide to remove this endpoint later if it seems redundant when the usual workspace endpoints get sharing info.

@Emyrk
Copy link
Member

Emyrk commented Aug 22, 2025

I think it needs to be kept to an endpoint that's only available with the experiment.

Ah this is a great point 👍

@aslilac
Copy link
Member Author

aslilac commented Aug 22, 2025

I kinda wanna punt on the groups issue. I think the extra info could be useful for the frontend (tho it does seem that the templates permissions page underutilizes the extra data). I can even make an issue to re-evaluate when we pick back up on shared workspaces.

@aslilac aslilac requested a review from Emyrk August 22, 2025 20:48
@aslilac
Copy link
Member Author

aslilac commented Aug 22, 2025

@Emyrk I would appreciate if this one got merged too 😄 there will be tacos in it for you

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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy