Skip to content
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

[ODC-4388] Allow cluster admins to create terminals #7145

Merged
merged 1 commit into from Dec 4, 2020
Merged

[ODC-4388] Allow cluster admins to create terminals #7145

merged 1 commit into from Dec 4, 2020

Conversation

JPinkney
Copy link
Contributor

@JPinkney JPinkney commented Nov 6, 2020

This PR is part of https://issues.redhat.com/browse/ODC-4388 which is for giving privileged users access to create terminal.

Currently, the flow is:
If the user is a cluster-admin then deny them from opening a terminal.

Now, the flow is:
If the user is a cluster-admin then automatically create their terminal in a secure openshift-terminal namespace. If the openshift-terminal namespace does not exist then create it.

The backend code then checks if the current user is a cluster-admin and if they are then check that the workspace they are trying to access is in the openshift-terminal namespace.

Before: https://www.youtube.com/watch?v=TUri-TE52UA
After: https://www.youtube.com/watch?v=v6Xy7LKbYrU

You can test with: quay.io/jpinkney/console:515

Signed-off-by: Josh Pinkney joshpinkney@gmail.com

@openshift-ci-robot openshift-ci-robot added the component/backend Related to backend label Nov 6, 2020
@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 6, 2020
@openshift-ci-robot
Copy link
Contributor

Hi @JPinkney. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@JPinkney JPinkney changed the title Allow cluster admins to create terminals [ODC-4388] Allow cluster admins to create terminals Nov 12, 2020
Copy link
Contributor

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

Everything apart from the shared corner-case works just fine

pkg/terminal/proxy.go Outdated Show resolved Hide resolved
@serenamarie125
Copy link
Contributor

This is aligned with one of our committed epics - confirmed that this is not dependent on updated to the WTO.

@christianvogt can you help get reviews on this?

Copy link
Contributor

@serenamarie125 serenamarie125 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! LGTM

@serenamarie125
Copy link
Contributor

FYI @parvathyvr @alimobrem

Copy link
Contributor

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

Tested on crc (1.18.0+bb304aa with OpenShift 4.6) with my built console and everything works as expected:

  1. Cluster admin is not able to exec into developer workspace.
  2. Cluster admin gets terminal in openshift-terminal namespace.
  3. Console ignores all terminals which are not in openshift-terminal namespace for cluster admin.
  4. Backend denies to /exec/init for cluster admin if terminal is not in openshift-terminal.

Good job!

@christianvogt
Copy link
Contributor

Tried this and works as expected on the surface.
However, when I first installed the operator and opened the terminal as an admin, I noticed that 3 DevWorkspace resources were created inside the openshift-terminal namespace.
I cannot reproduce this again on the same cluster anymore though....

@JPinkney
Copy link
Contributor Author

@christianvogt Regarding:

However, when I first installed the operator and opened the terminal as an admin, I noticed that 3 DevWorkspace resources were created inside the openshift-terminal namespace.
I cannot reproduce this again on the same cluster anymore though....

Can you try with the latest changes? I just got a fresh cluster from cluster bot and deployed the changes and looks like I can't reproduce anymore

@christianvogt
Copy link
Contributor

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 23, 2020
@JPinkney
Copy link
Contributor Author

/retest

@christianvogt
Copy link
Contributor

@sleshchenko @JPinkney is everything on the backend good now? Sorry I haven't been following what's needed on the backend changes.

@JPinkney
Copy link
Contributor Author

Yeah, everything should be good on the backend and frontend now

@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 24, 2020
@christianvogt
Copy link
Contributor

I tried again on cluster bot and everything worked for the admin and normal user.

@christianvogt
Copy link
Contributor

/retest

@christianvogt
Copy link
Contributor

@spadgett @rhamilto this PR needs your approval

@JPinkney please rebase

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 30, 2020
@christianvogt
Copy link
Contributor

front end changes lgtm. Waiting for cluster bot to test again.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/approve

Backend changes LGTM. I will let @christianvogt give final lgtm. Thanks!

pkg/terminal/auth.go Outdated Show resolved Hide resolved
@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 2, 2020
…mespace

Modify backend proxy check to allow cluster admins if and only if their
terminal is in the openshift-terminal namespace

Only search for terminals in openshift-terminal namespace when using cluster admin

Rework terminal proxy to use isClusterAdmin for checking if the user can access the terminal

Use error status to see if namespace exists in CloudShellAdminSetup

Return false if namespace is not found in CloudShellAdminSetup instead of displaying error.
The reason we need to do this is if you set the error the terminal will flash quickly with
the error before switching to the newly created terminal.

Make subject access review request against openshift-terminal namespace

Display loading screen until admin check has finished

Signed-off-by: Josh Pinkney <joshpinkney@gmail.com>
@christianvogt
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 3, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, JPinkney, serenamarie125, sleshchenko, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend component/core Related to console core functionality lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants