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

Make Theia sidecar/stack secure, add an ability to use new JWT auth on a per-workspace basis #11410

Merged
merged 6 commits into from
Oct 3, 2018

Conversation

garagatyi
Copy link

@garagatyi garagatyi commented Sep 30, 2018

What does this PR do?

This PR is designed to be reviewed in a commit-by-commit manner. The scope of each commit is very limited to the purpose described in its message.

Description of why:
In sidecar-based workspaces with Theia sidecar, we can not use current security mechanism. To overcome it Che platform team implemented JWTProxy based implementation. We can switch these implementations for the whole Che, but this is not enough in a case when old workspaces are mostly used but sidecar-based workspaces evaluation is needed. Since JWTProxy based auth wasn't tested well enough as it is a non-default option I decided to switch only sidecar-based workspaces to it.

Description of what:
Adds an ability to enable workspace security implementation on a per-workspace basis.
Enables JWTProxy based security to sidecar-based workspaces if authentication is enabled in Che.
Adds secure and cookiesAuthEnabled attributes to Theia stacks, so they are secure on a multiuser Che in contrast to the current state in master.
Adds other small fixes, such as fixing warning codes for workspace starting components.

Description of how:
In ServersConverter I used SecureServerExposerFactoryProvider to create SecureServerExposerFactory directly and removed its binding from the DI container.
Then I added an argument to the get() method of the provider. It accepts KubernetesEnvironment as an argument. The provider now does the deccision on what security implementation should be used not just by checking global Che property but also by looking at KuberneterEnvironment attributes KuberneterEnvironment.getAttributes(). When attribute che.server.secure_exposer is present in the environment and contains bound implementation the provider uses this implementation instead of the globally configured with the property with the same name. If there is no attribute or implementation not found the provider falls back to the globally configured implementation.
Then in che.server.secure_exposer I added code that adds attribute che.server.secure_exposer with value jwtproxy if authentication is enabled in Che.

How to test it:
Prerequsites:
Theia will work in secure sidecar-based workspaces only after applying this PR and populating it to your che-plugin-registry instance and applying PR to the plugin broker.

  1. Start Che in multiuser mode.
  2. Create and start sidecar-based workspace.
  3. Create and start regular Che 6 workspace, but add attribute che.server.secure_exposer with value jwtproxy to workspace config attributes.
  4. Create workspace from Theia stack.
  5. All 3 workspaces from the previous steps are secured with JWTProxy instead of being completely unsecure as it is in master branch.

What issues does this PR fix or reference?

To vitness working sidecar-based Theia secured in multi-user Che PRs need to be merged:
eclipse-che/che-plugin-broker#11
https://github.com/ws-skeleton/che-editor-theia/pull/7
Fixes redhat-developer/rh-che#853

Release Notes

Docs PR

…binding time

Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
@garagatyi
Copy link
Author

ci-test

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Sep 30, 2018
@riuvshin
Copy link
Contributor

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:11410
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@benoitf benoitf added the kind/enhancement A feature request - must adhere to the feature request template. label Sep 30, 2018
@garagatyi
Copy link
Author

ci-test

@riuvshin
Copy link
Contributor

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:11410
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@garagatyi
Copy link
Author

@eclipse/eclipse-che-qa Please, take a look at the report

@@ -27,6 +27,8 @@
* @author Alexander Garagatyi
*/
public class RestartPolicyRewriter implements ConfigurationProvisioner {
public static final int RESTART_POLICY_SET_TO_NEVER = 4104;
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to place warning codes in one place, like Constants class.

Copy link
Author

Choose a reason for hiding this comment

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

Make sense, but it is not related to this particular PR I suppose. Can you create an issue for that?

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 but I afraid it won't get needed priority to be fixed.
I think it makes sense to do it only in part of a code that is changed in this PR. But I'm OK to leave it as it is.

import org.eclipse.che.inject.ConfigurationException;
import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment;

/**
* Provides implementation of {@link SecureServerExposerFactory} according to configuration property
* with name `che.server.secure_exposer`.
* or workspace config attribute with name `che.server.secure_exposer`.
Copy link
Member

Choose a reason for hiding this comment

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

It makes sense to rewrite this java doc to make clear priority of different configuration sources.

Copy link
Author

Choose a reason for hiding this comment

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

fixed


if (isAuthEnabled) {
// enable per-workspace security with JWT proxy for sidecar based WS
// because it is the only WS security implementation supported for now
Copy link
Member

Choose a reason for hiding this comment

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

please, don't use WS abbreviation where it is possible since there is a collision with Workspace and WebSocket meaning.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@vkuznyetsov vkuznyetsov mentioned this pull request Oct 2, 2018
47 tasks
@SkorikSergey
Copy link
Contributor

Selenium tests execution on Eclipse Che Multiuser on OCP (https://ci.codenvycorp.com/job/che-pullrequests-test-ocp/892/) doesn't show any regression against this Pull Request.

Copy link
Member

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

LGTM

Oleksandr Garagatyi added 5 commits October 3, 2018 09:07
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
@garagatyi garagatyi merged commit eb6b28d into eclipse-che:master Oct 3, 2018
@garagatyi garagatyi deleted the secureWSNEXT branch October 3, 2018 06:08
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 3, 2018
@benoitf benoitf added this to the 6.12.0 milestone Oct 3, 2018
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to use JWT-proxy based Che workspace security for a particular user/workspace
8 participants