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

Allow to call getCurrentUser and oAuth API with machine token #16383

Closed
wants to merge 8 commits into from

Conversation

vinokurig
Copy link
Contributor

What does this PR do?

Allow to get current user with machine token; Allow to call other oAuth service API with machine token. This is needed for github and openShift authentication to work in multi-user mode.

What issues does this PR fix or reference?

#15261

Release Notes

Docs PR

@vinokurig vinokurig requested a review from skabashnyuk March 17, 2020 15:44
@che-bot che-bot added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/enhancement A feature request - must adhere to the feature request template. labels Mar 17, 2020
@che-bot
Copy link
Contributor

che-bot commented Mar 17, 2020

✅ E2E Happy path tests succeed 🎉

See Details

Tested with Eclipse Che Multiuser User on K8S (minikube v1.1.1)

mshaposhnik
mshaposhnik previously approved these changes Mar 17, 2020
Copy link
Contributor

@metlos metlos left a comment

Choose a reason for hiding this comment

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

Code looks fine, I'm just concerned about the security implications of this... Could you please address my comments below?

.toInstance(new MachineAuthenticatedResource("oauth", "token"));
.toInstance(
new MachineAuthenticatedResource(
"oauth", "token", "authenticate", "callback", "getRegisteredAuthenticators"));
Copy link
Contributor

Choose a reason for hiding this comment

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

The token endpoint means that we're allowing any plugin or custom code in the workspace to impersonate the current user and talk to the Che API. This basically means that you can for example access other workspaces from the current workspace, create new workspaces, delete workspaces, etc...

I would call that a security issue, because it is conceivable to imagine that a user might import an "infected" devfile that would contain some code that could read the machine token from the env and wreck havoc in all the user workspaces - reading secret data, delete stuff, DDoS the cluster with hundreds of workspace start requests, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The token method is already opened. Actually I don't understand how oAuth API can influence the che API. It allows to get the GitHub or OpenShift token, but that was discussed earlier.
cc @skabashnyuk

Copy link
Contributor

Choose a reason for hiding this comment

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

To be fair, I misunderstood the purpose of the API 🙄 But I still think this is a dangerous thing. If for example the user authenticated with OpenShift authenticator as himself and the workspace is able to get hold of the openshift token (which I think it would with this change?), then the workspace can also go to keycloak and use the openshift token to get access token for the Che API. From there we're at a place I described in the above comment.

Maybe I'm wrong (I'm fairly new to this auth business to be fair) but giving the whole of workspace (which can come from various sources) is a dangerous thing. If nothing else it opens up the door to phishing attacks (please import this devfile with a component with only a slightly misspelled image name, nothing wrong can happen...).

Copy link
Contributor

@skabashnyuk skabashnyuk left a comment

Choose a reason for hiding this comment

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

Do not merge it, please. Give us some time to think about it.

@mshaposhnik mshaposhnik dismissed their stale review March 18, 2020 08:30

will wait for more responses

@skabashnyuk
Copy link
Contributor

I agree with @metlos POV. We are making machine token too powerful. My concerns are similar to the single token method of OAuth service of resed here #15705 (comment)

I want to let @benoitf @l0rd @davidfestal decide is that acceptable.
Previous pr #15705 was approved by @benoitf

@l0rd
Copy link
Contributor

l0rd commented Mar 19, 2020

@skabashnyuk @metlos do we have other options? The goal is to preconfigure oc, the OpenShift VS Code extension and any other k8s client with the current user OpenShift credentials (when Che is configured to use OpenShift OAuth). How can we achieve that without making machine tokens "more powerful"?

Anyway on VS Code, not Che, extensions have access to local filesystem and k8s tokens. I don't think it's considered as a VS Code vulnerability but it requires that users should install only extensions that they trust. For Che it should be the same.

@skabashnyuk
Copy link
Contributor

do we have other options? The goal is to preconfigure oc, the OpenShift VS Code extension and any other k8s client with the current user OpenShift credentials (when Che is configured to use OpenShift OAuth). How can we achieve that without making machine tokens "more powerful"?

We understand the goal, it's understandable and logical. We just have concerns in the way how it is going to be implemented.
An alternative is to have something similar to the mechanism of how we obtain cookie for jwt-proxy. The main idea is to have a web application on che-server side that is located on the space in which users have no control. And this application can provide all necessary functionality authorizing users with machine tokens from one site and executing operation with keycloak token from the other side.

@skabashnyuk skabashnyuk dismissed their stale review March 20, 2020 07:28

abandon review

@che-bot
Copy link
Contributor

che-bot commented Mar 26, 2020

❌ E2E Happy path tests failed ❗

See Details

Tested with Eclipse Che Multiuser User on K8S (minikube v1.1.1)

⚠️ https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

ℹ️ Use comment "crw-ci-test" to rerun happy path E2E test.

.toInstance(
new MachineAuthenticatedResource(
"oauth", "token", "authenticate", "callback", "getRegisteredAuthenticators"));
.toInstance(new MachineAuthenticatedResource("oauth", "token"));
Copy link
Contributor

Choose a reason for hiding this comment

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

.toInstance(new MachineAuthenticatedResource("oauth", "token")); this line can be removed too?

@che-bot
Copy link
Contributor

che-bot commented Mar 30, 2020

❌ E2E Happy path tests failed ❗

See Details

Tested with Eclipse Che Multiuser User on K8S (minikube v1.1.1)

⚠️ https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

ℹ️ Use comment "crw-ci-test" to rerun happy path E2E test.

@vinokurig vinokurig closed this Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants