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

Replace Dex with external OIDC provider (Keycloak) in v1.9 and above #2831

Closed
4 of 7 tasks
jmmoreu opened this issue Aug 2, 2024 · 9 comments
Closed
4 of 7 tasks

Comments

@jmmoreu
Copy link

jmmoreu commented Aug 2, 2024

Validation Checklist

Version

1.9

Describe your issue

Version 1.9 introduces a major change replacing traditional oidc-authservice with oauth2-proxy. In fact, master's branch has already removed the oidc-authservice folder. Previous option allowed switching from Dex to Keycloak (or other oidc providers) by simply creating an overlay to modify params.env and secret_params.env (as shown in #2379 and #2513).

The corresponding kustomization.yaml removes oidc-authservice and installs oauth2-proxy with m2m-self-signed overlay. This uses oauth2-proxy-config.yaml which contains the cfg for traditional Dex service.

I assume that if we were to replace Dex with Keycloak we would need an overlay modifying this ConfigMap with the required fields. However, many of these fields in this cfg do not match exactly with previous fields to be changed in the previous approach (i.e params.env). Which fields should be changed and how?

Additionally, I assume that the secret_params CLIENT_ID and CLIENT_SECRET should be modified in this secretGenerator.

Steps to reproduce the issue

See above.

Put here any screenshots or videos (optional)

No response

@thesuperzapper
Copy link
Member

@jmmoreu I want to note that Keycloak is a lot more complicated than Dex, and while it has more features, its purpose is really to run as your core authentication infrastructure, not to be the authentication infrastructure for a specific app.

Right now it's already possible to integrate default Kubeflow with a Keycloak deployment, by having Dex trust it.

What exactly are you wanting to achieve by this change?

@jmmoreu
Copy link
Author

jmmoreu commented Aug 3, 2024

@thesuperzapper pretty much what was discussed in #2513 and #2379. I've been using Keycloak to manage users and groups access to third party apps including Kubeflow. I just want users to access kubeflow with their keycloak credentials.

Perhaps I am mistaken, but I believe that in my setting I am not using Dex at all. Also, in #2379 they really mean replacing Dex with Keycloak, right?

If what you mentioned about having dex trust my keycloak deployment works, that is ok to me. I would really appreciate some hints on how to achieve so, though. Thanks!

@thesuperzapper
Copy link
Member

@jmmoreu Dex can connect to Keycloak through OpenID Connect, this is documented on the deployKF docs, which should give you context, even if you are not using deployKF:

@kromanow94
Copy link
Contributor

@jmmoreu so you're setup includes a k8s cluster running with self-signed certificates for the kube-apiserver and keycloak instead of dex? Or is keycloak also used for the kube-apiserver as well?

@jmmoreu
Copy link
Author

jmmoreu commented Aug 5, 2024

@kromanow94 Yes, I have also configured the apiserver to perform OIDC authentication, following this tutorial. This is particularly useful to grant users access to the cluster, and attach VS code directly to the jupyter server pod, for instance.

I am fine with the approach @thesuperzapper suggested (I need to try it first, though). I just thought it would be possible to keep using my previous approach. If you think there's another way which might be interesting I'll be glad to hear it. Thanks!

@kromanow94
Copy link
Contributor

I see. It's definitely possible to not use dex, although that would be an easier and more flexible option, for example if you also want to setup SSO for ArgoCD or another tool. You could configure all the services you deploy on your cluster (or wherever) to use dex directly and configure dex with a connector to any OIDC Provider.

But, if you're more interested with going directly with ouath2-proxy, this can be achieved by configuring the following field in the common/oauth2-proxy/base/oauth2-proxy-config.yaml:

oidc_issuer_url = "https://keycloak.example.com/auth/realms/master"

and removing those few as those are configured for in-cluster dex:

skip_auth_regex
skip_oidc_discovery
login_url
redeem_url
oidc_jwks_url

If you use the same OIDC Issuer for kube-apiserver and the oauth2-proxy, you can skip the EXTRA_JWT_ISSUERS.
You also don't have to use the m2m-self-signed overlay as the OIDC Issuer is served with publicly trusted certificates and go directly with m2m.

Also, you'd have to configure:

It makes sense to provide a documentation on how to do that. Also, I think the oauth2-proxy kustomization can be modified to provide more args directly through the env variables so there is no need to modify the oauth2-proxy Config Map, but there might be other challenges...

@jxdn
Copy link

jxdn commented Aug 7, 2024

I see. It's definitely possible to not use dex, although that would be an easier and more flexible option, for example if you also want to setup SSO for ArgoCD or another tool. You could configure all the services you deploy on your cluster (or wherever) to use dex directly and configure dex with a connector to any OIDC Provider.

But, if you're more interested with going directly with ouath2-proxy, this can be achieved by configuring the following field in the common/oauth2-proxy/base/oauth2-proxy-config.yaml:

oidc_issuer_url = "https://keycloak.example.com/auth/realms/master"

and removing those few as those are configured for in-cluster dex:

skip_auth_regex
skip_oidc_discovery
login_url
redeem_url
oidc_jwks_url

If you use the same OIDC Issuer for kube-apiserver and the oauth2-proxy, you can skip the EXTRA_JWT_ISSUERS. You also don't have to use the m2m-self-signed overlay as the OIDC Issuer is served with publicly trusted certificates and go directly with m2m.

Also, you'd have to configure:

It makes sense to provide a documentation on how to do that. Also, I think the oauth2-proxy kustomization can be modified to provide more args directly through the env variables so there is no need to modify the oauth2-proxy Config Map, but there might be other challenges...

HTTP/1.1 "" 302 12523 0.001 got this error , too many redirect.... need some guide on it

@jxdn
Copy link

jxdn commented Aug 7, 2024

I see. It's definitely possible to not use dex, although that would be an easier and more flexible option, for example if you also want to setup SSO for ArgoCD or another tool. You could configure all the services you deploy on your cluster (or wherever) to use dex directly and configure dex with a connector to any OIDC Provider.
But, if you're more interested with going directly with ouath2-proxy, this can be achieved by configuring the following field in the common/oauth2-proxy/base/oauth2-proxy-config.yaml:

oidc_issuer_url = "https://keycloak.example.com/auth/realms/master"

and removing those few as those are configured for in-cluster dex:

skip_auth_regex
skip_oidc_discovery
login_url
redeem_url
oidc_jwks_url

If you use the same OIDC Issuer for kube-apiserver and the oauth2-proxy, you can skip the EXTRA_JWT_ISSUERS. You also don't have to use the m2m-self-signed overlay as the OIDC Issuer is served with publicly trusted certificates and go directly with m2m.
Also, you'd have to configure:

It makes sense to provide a documentation on how to do that. Also, I think the oauth2-proxy kustomization can be modified to provide more args directly through the env variables so there is no need to modify the oauth2-proxy Config Map, but there might be other challenges...

HTTP/1.1 "" 302 12523 0.001 got this error , too many redirect.... need some guide on it

No valid authentication in request. Initiating login.

@juliusvonkohout
Copy link
Member

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

No branches or pull requests

5 participants