-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat: secure workspace services #1045
feat: secure workspace services #1045
Conversation
Skipping CI for Draft Pull Request. |
a41d73c
to
9b56256
Compare
9b56256
to
02d7589
Compare
02d7589
to
b86d5bf
Compare
0a38a1f
to
f0a939c
Compare
acf4983
to
b1e4f86
Compare
24495e1
to
8427238
Compare
Signed-off-by: Michal Vala <mvala@redhat.com>
8427238
to
78b6367
Compare
Signed-off-by: Michal Vala <mvala@redhat.com>
Signed-off-by: Michal Vala <mvala@redhat.com>
/retest |
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've not tested it in a running cluster yet, but here's a couple of small comments...
@@ -360,7 +360,7 @@ func DefaultPullPolicyFromDockerImage(dockerImage string) string { | |||
} | |||
|
|||
func GetSingleHostExposureType(cr *orgv1.CheCluster) string { | |||
if util.IsOpenShift { | |||
if util.IsOpenShift || cr.Spec.DevWorkspace.Enable { |
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.
Why do we need this changes?
So, it means that gateway
will be default for k8s when devworkspace is enabled.
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.
Exactly. There was the agreement on the last cabal that we're doing that, if I remember correctly.
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.
Then DefaultOpenShiftSingleHostExposureType
const has no sense anymore.
Let's remove it and just return gateway
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.
there will be only gateway
with devworkspaces. native
does not really work with native auth. Everything we want to protect with oauth-proxy and kube-rbac-proxy has to go through the gateway.
@sparkoo can you describe in the description how in general protection has been made. |
added "How it works" paragraph |
/retest |
Btw I've read the description again and am I correct in saying that the request is checked using kube-rbac-proxy also in the workspace pod (essentially again?). This is important so that we guard against in-cluster access by other users. I thought I saw it in the code but I understood your description otherwise. Could you please clarify? |
Yes, it's now checked twice. First in main che-gateway https://github.com/eclipse-che/che-operator/pull/1045/files#diff-ebca2eefe12f7ba4a722c53d574ba1b2adee412909da8cdbc974c8f7fcbfb02fR468 then second time in workspace gateway https://github.com/eclipse-che/che-operator/pull/1045/files#diff-ebca2eefe12f7ba4a722c53d574ba1b2adee412909da8cdbc974c8f7fcbfb02fR554 |
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.
@@ -533,7 +702,7 @@ func determineEndpointScheme(gatewayEnabled bool, e dw.Endpoint) string { | |||
upgradeToSecure := e.Secure | |||
|
|||
// gateway is always on HTTPS, so if the endpoint is served through the gateway, we need to use the TLS'd variant. | |||
if gatewayEnabled && e.Attributes.GetString(urlRewriteSupportedEndpointAttributeName, nil) == "true" { | |||
if e.Attributes.GetString(urlRewriteSupportedEndpointAttributeName, nil) == "true" { |
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.
that's such a huge file... Not really related to the PR but it deserves refactoring.
} | ||
|
||
func (c *CheRoutingSolver) cheSpecObjects(cheManager *v2alpha1.CheCluster, routing *dwo.DevWorkspaceRouting, workspaceMeta solvers.DevWorkspaceMetadata) (solvers.RoutingObjects, error) { | ||
func (c *CheRoutingSolver) cheSpecObjects(cheCluster *v2alpha1.CheCluster, routing *dwo.DevWorkspaceRouting, workspaceMeta solvers.DevWorkspaceMetadata) (solvers.RoutingObjects, error) { |
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.
maybe it makes sense to move this method and its dependency to a separate file. But makes sense to move it out of the PR, since it would not make this PR reviewing easier
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: metlos, sleshchenko, sparkoo, tolusha The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What does this PR do?
Secures workspace services with devworkspace engine on OpenShift.
There is a slight change in exposing logic. The ingresses/routes are not merged into one when exposing same port.
Beside that, it also always deploys with gateway on kubernetes when devworkspaces are enabled.
How it works?
Nowdays, workspace service is open to the cluster. It exposes all workspace ports and communication goes directly to target container, so anyone in the cluster can access it.
This patch adds traefik container into workspace pod and narrows the service to only single port (targeting to the traefik) for all endpoints that exposes on subpath. That means that all communication that is coming to the workspace service, must go through the traefik. The traefik is configured so it checks the requests with kube-rbac-proxy (in main che-gateway) using forwardAuth middleware (https://doc.traefik.io/traefik/middlewares/http/forwardauth/). Kube-rbac-proxy is checking whether token in authorization header can access the service in workspace's namespace. If this check is OK, traefik route the request to correct port inside the workspace pod.
Screenshot/screencast of this PR
What issues does this PR fix or reference?
eclipse-che/che#20190
How to test this PR?
quay.io/mvala/che-operator:gh20190-secureWsServicesTraefik
PR Checklist
As the author of this Pull Request I made sure that:
What issues does this PR fix or reference
andHow to test this PR
completedReviewers
Reviewers, please comment how you tested the PR when approving it.