- Notifications
You must be signed in to change notification settings - Fork928
feat: Allow admins to access member workspace terminals#2114
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
feat: Allow admins to access member workspace terminals#2114
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It might be wiser for us to actually allow administrators to access a developer terminal instead of this approach. Right now, the backend allows admins to delete workspaces for other users, so it seems silly they couldn't access them too.
Any thoughts here@bpmct? Curious for yours too@AbhineetJain!
bpmct commentedJun 7, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There are cases for both. For now, I think it is best to keep this option enabled for admins. In Coder classic, many admins have built internal tooling to exec into workspaces and reproduce bugs. Having this as a first-class feature (when the agent works, of course) is a helpful utility. Down the road, fine-grained permissions can be used to restrict this to 1 or 2 users or disable it entirely. |
@AbhineetJain we may want to adjust the reconnecting PTY route to allow access in that case, then it all shouldjust work. |
@kylecarbs sounds good, I'll update the PR to do that. |
Do we want to implement this as admins connecting to a user's workspace, or have admins "impersonate" the user, then access? We talked about masquerading/impersonation as a feature before. That avenue seems to accomplish the same thing in a more general way? Keeping the codepath as "the owner" accessing. Once we get audit logs, it will show who actually is connecting. |
08c4fd4
to4ecfd7f
Compare@kylecarbs:@Emyrk and I worked together to set up the RBAC check for allowing terminal (or workspace agent) access to users with workspace update permissions. I am planning to block the access links in the UI for users without the workspace update permission, if this looks like a good approach. Alternatively, we might need to create a new resource for workspace agents and its own set of permissions. |
ammario commentedJun 7, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This seems highly related to#2135 issue. I don't understand why we would restrict it to the owner instead of relying on RBAC. RBAC is a lot more configurable. Also, we want to minimize assumptions about access in the frontend to avoid future bugs due to misalignment between backend and frontend. (Edit: I see we're aligned here) I'm in favor of keeping the behavior as it is in |
Another reason to have a user that can literally do anything is limitless automation. |
@ammario The PR evolved and the original description was outdated. I've now updated the description. In We're now allowing users with the workspace update access as per RBAC to see the link and use the terminal, and hide the link for users without access. |
Ah ok. Makes a lot of sense. |
I want to mention the RBAC perm of "update workspace" is being used for now. If we have reason too, we can break this out into a new resource. Keeping the number of RBAC unique resources as few as possible at the moment. |
c05da12
to158dd56
CompareThis should bealmost ready. I am seeing this error in the console on the Workspace page though:
I am not sure what caused it, so can use some help there. @coder/frontend Any ideas? |
if !ok { | ||
panic("developer error: user roles middleware not provided") | ||
} | ||
returnapiKey | ||
returnuserRoles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixing previous debt!
ctx := context.WithValue(r.Context(), workspaceAgentParamContextKey{}, agent) | ||
chi.RouteContext(ctx).URLParams.Add("workspace", build.WorkspaceID.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Adding the workspace param here to check RBAC in the actual call.
Uh oh!
There was an error while loading.Please reload this page.
appIcon={app.icon} | ||
appName={app.name} | ||
userName={workspace.owner_name} | ||
{canUpdateWorkspace && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I could see this living in its own component given the length of the file.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@AbhineetJain I think maybe it is complaining because we are modifying workspace as we pass it in to the
That seems to clear out the warning on my end while still passing in the |
@Kira-Pilot It does indeed! Thank you so much. How'd you figure this out? 😄 |
08d1c34
to252a6df
Compare@AbhineetJain I foundthis example in the XState docs. They should really update the context section you and I looked at earlier. Glad it worked out! |
252a6df
to4e69393
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
RBAC looks good. Perms should be good for admins and users
* allow workspace update permissions to access agents* do not show app links to users without workspace update access* address CR comments* initialize machine context in the hook* revert scoped connected status check
Uh oh!
There was an error while loading.Please reload this page.
This PR allows the terminal/app access links shown on the workspace page to be used by the admin. Currently, the admins can open the link but the terminal opens with a web socket failure due to forbidden access.
Subtasks
Fixes#1988
Screenshots
Other user
Same user