Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

AbhineetJain
Copy link
Contributor

@AbhineetJainAbhineetJain commentedJun 7, 2022
edited
Loading

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

  • allow admins (or members with workspace update access) to open and use terminal/app links from all organization workspaces.
  • do not show the terminal/app links to users without access.
  • add a story
  • update backend unit tests that check for access.

Fixes#1988

Screenshots

Other user

Screen Shot 2022-06-07 at 1 39 15 AM

Same user

Screen Shot 2022-06-07 at 1 39 24 AM

@AbhineetJainAbhineetJain requested a review froma team as acode ownerJune 7, 2022 05:34
Copy link
Member

@kylecarbskylecarbs left a 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
Copy link
Member

bpmct commentedJun 7, 2022
edited
Loading

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.

@kylecarbs
Copy link
Member

@AbhineetJain we may want to adjust the reconnecting PTY route to allow access in that case, then it all shouldjust work.

@AbhineetJain
Copy link
ContributorAuthor

@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.

kylecarbs reacted with hooray emoji

@Emyrk
Copy link
Member

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.

@AbhineetJainAbhineetJainforce-pushed theabhineetjain/1988-restrict-app-terminal-access branch from08c4fd4 to4ecfd7fCompareJune 7, 2022 21:30
@AbhineetJain
Copy link
ContributorAuthor

@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
Copy link
Member

ammario commentedJun 7, 2022
edited
Loading

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 inmain. The superadmin/root has full access to everyone's workspace, and we create a lesser admin role that is RBAC-restricted from workspace exec.

@ammario
Copy link
Member

Another reason to have a user that can literally do anything is limitless automation.

@AbhineetJainAbhineetJain changed the titlefeat: Restrict access links to workspace ownerfeat: Allow admins to access member workspace terminalsJun 8, 2022
@AbhineetJain
Copy link
ContributorAuthor

@ammario The PR evolved and the original description was outdated. I've now updated the description.

Inmain, we are showingOpen terminal links to admin users for member workspaces, but clicking on the link opens the terminal in a failed/disconnected state due to their access being forbidden.

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.

@ammario
Copy link
Member

@ammario The PR evolved and the original description was outdated. I've now updated the description.

Inmain, we are showingOpen terminal links to admin users for member workspaces, but clicking on the link opens the terminal in a failed/disconnected state due to their access being forbidden.

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.

@Emyrk
Copy link
Member

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.

kylecarbs reacted with thumbs up emoji

@AbhineetJainAbhineetJainforce-pushed theabhineetjain/1988-restrict-app-terminal-access branch 2 times, most recently fromc05da12 to158dd56CompareJune 9, 2022 18:20
@AbhineetJain
Copy link
ContributorAuthor

This should bealmost ready. I am seeing this error in the console on the Workspace page though:

Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.Please make sure that you pass the same Machine as argument each time.

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
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixing previous debt!

Emyrk reacted with thumbs up emoji

ctx := context.WithValue(r.Context(), workspaceAgentParamContextKey{}, agent)
chi.RouteContext(ctx).URLParams.Add("workspace", build.WorkspaceID.String())
Copy link
ContributorAuthor

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.

@AbhineetJainAbhineetJain requested a review froma teamJune 9, 2022 18:34
appIcon={app.icon}
appName={app.name}
userName={workspace.owner_name}
{canUpdateWorkspace && (
Copy link
Member

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.

@Kira-Pilot
Copy link
Member

This should bealmost ready. I am seeing this error in the console on the Workspace page though:

Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.Please make sure that you pass the same Machine as argument each time.

I am not sure what caused it, so can use some help there. @coder/frontend Any ideas?

@AbhineetJain I think maybe it is complaining because we are modifying workspace as we pass it in to theuseMachine hook.
When we use that hook, could we try:

  const [workspaceState, workspaceSend] = useMachine(workspaceMachine, {    context: {      userId: me?.id,    },  })

That seems to clear out the warning on my end while still passing in theuserId.

@AbhineetJain
Copy link
ContributorAuthor

This should bealmost ready. I am seeing this error in the console on the Workspace page though:

Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.Please make sure that you pass the same Machine as argument each time.

I am not sure what caused it, so can use some help there. @coder/frontend Any ideas?

@AbhineetJain I think maybe it is complaining because we are modifying workspace as we pass it in to theuseMachine hook. When we use that hook, could we try:

  const [workspaceState, workspaceSend] = useMachine(workspaceMachine, {    context: {      userId: me?.id,    },  })

That seems to clear out the warning on my end while still passing in theuserId.

@Kira-Pilot It does indeed! Thank you so much. How'd you figure this out? 😄

@AbhineetJainAbhineetJainforce-pushed theabhineetjain/1988-restrict-app-terminal-access branch from08d1c34 to252a6dfCompareJune 9, 2022 22:28
@Kira-Pilot
Copy link
Member

@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!

AbhineetJain reacted with thumbs up emojiAbhineetJain reacted with hooray emoji

@AbhineetJainAbhineetJainforce-pushed theabhineetjain/1988-restrict-app-terminal-access branch from252a6df to4e69393CompareJune 10, 2022 13:59
Copy link
Member

@EmyrkEmyrk left a 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

AbhineetJain reacted with hooray emoji
@AbhineetJainAbhineetJain merged commit953e8c8 intomainJun 10, 2022
@AbhineetJainAbhineetJain deleted the abhineetjain/1988-restrict-app-terminal-access branchJune 10, 2022 14:46
kylecarbs pushed a commit that referenced this pull requestJun 10, 2022
* 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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@presleyppresleyppresleyp left review comments

@kylecarbskylecarbskylecarbs left review comments

@EmyrkEmyrkEmyrk approved these changes

@Kira-PilotKira-PilotKira-Pilot approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Unclear admin persmissions: Admin can use Open terminal link on other users workspaces, but terminal is opened with Web Socket error
7 participants
@AbhineetJain@bpmct@kylecarbs@Emyrk@ammario@Kira-Pilot@presleyp

[8]ページ先頭

©2009-2025 Movatter.jp