-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Feature Request - Add keycloak as a provider #127
Comments
Keycloak should be supported as an OIDC provider, however the docs are lacking, in that half the arguments you are supposed to pass appear to be unavailable, such as --oidc-issuer-url. |
@vikas027 Did you get this working? |
Hey @JoelSpeed , Nope, I want to try this out but was too busy in other stuff and AWS Summit :). It would be great if someone can add a little doco for keycloak. Thanks. |
I haven't had time to polish up anything, but got something working a month or two ago with something like this: cat > oauth-proxy-values.yaml <<"EOF"
# Oauth client configuration specifics
config:
clientID: "keycloak-dashboard"
clientSecret: "<REPLACE ME>"
# Create a new secret with the following command
# python -c 'import os,base64; print base64.b64encode(os.urandom(16))'
cookieSecret: "XXX"
configFile: |-
pass_authorization_header = true
set_authorization_header = true
ssl_insecure_skip_verify = true
oidc_issuer_url = "https://keycloak.192.168.39.199.xip.io/auth/realms/kubernetes"
extraArgs:
upstream: "file:///dev/null"
http-address: "0.0.0.0:4180"
ingress:
enabled: true
path: /oauth2
hosts:
- foo.bar.com
annotations:
kubernetes.io/ingress.class: nginx
# certmanager.k8s.io/issuer: letsencrypt
tls:
- hosts:
- foo.bar.com
secretName: foo-bar-com-tls
EOF
helm install stable/oauth2-proxy --namespace=kube-system -f oauth-proxy-values.yaml --name=k8s-dash-oauth2
```bash |
Thanks for posting this, it helped me get my own test k8s / oidc / keycloak lab working, and I had spent hours on it also. :( It would be really nice if oauth2-proxy did have a built-in provider mode for keycloak rather than having to tweak the oidc one, but at least it's doable. oauth2-proxy seems a lot easier to use and more flexible than keycloak-gatekeeper/proxy, great tool. For what it's worth, I isolated the settings that were definitely needed from your config and integrated them all into a single yaml file which deploys the proxy, the 2 ingresses, and the service. This is now repeatable and seems stable. I have done this on the Canonical deployment of kubernetes (CDK), and used the default dashboard service which runs on https/443. Not sure anyone still needs this info, but just in case, here are the complete set of oauth2-proxy args and ingress annotations I think are the critical ones for keycloak. The rest of the options mentioned in your post don't seem to be required (at least from my testing and trial/error). On the CDK kubernetes, the ingress proxy-buffer size of 8k is too small and needed to be raised via an annotation. INGRESS (external-auth-oauth2) deployment: INGRESS (oauth2-proxy) deployment: DEPLOYMENT (oauth2-proxy) args: The docker image used was: I can share the deployment yaml file if anyone wants it, but all the important settings are those listed above. |
Hi I found this pull request back in original repository: bitly/oauth2_proxy#366 I then tried to setup proxy with keycloak and it looked cool (I got authenticated but sadly the /oauth2/callback returns 500 - this is probably just my bad understanding of keycloak's oauth process and lack of knowledge when it comes to env variables which need to be satisfied and has nothing to do with quality of the PR) |
@Ofinka sounds cool, thanks for the info and motivation, as i am trying to get his to work without much success yet. I have the proxy configured as above but must be missing something trivial, as its not even redirecting to my keycloak instance. I am trying to link it behind my letsencrypt reverse proxy. I will see if I can do a similar thing as you have done. Or perhaps @FlorinPeter would consider recreating his PR against the lastest code, for those of us less familiar with the keycloak configs :) |
Hi finally I've made it working with bitly/oauth2_proxy#366 PR. Basically I just needed to specify correctly I put my configuration in case someone else wants to use keycloak provider.
Here are screenshots of everything I had to configure in keycloak UI. |
Getting some errors building the previous PR, maybe missed something. Hopeful someone with fresher skills can recreate the PR :) Edit: Specifically this error -> providers/keycloak.go:51:47: undefined: SessionState |
@Ofinka I followed your steps and built my own container with the added/modified files from your PR, and was able to get Keycloak working. In terms of use, since each proxy can only support one client in Keycloak, it would be better to have a proxy for each service you want to protect, correct? Then you could set proper redirect URIs and whatnot within Keycloak. |
Keycloack worked perfectly fine for me when using the oidc discovery url no need for manual configuration at all. |
This issue has been inactive for 60 days. If the issue is still relevant please comment to re-activate the issue. If no action is taken within 7 days, the issue will be marked closed. |
Hi, i'm still falling with keycloak as OIDC server. After successful authentication, the redirection to oauth2/callback failed as below:
Any idea about how to fix it ? Thanks. |
@yaakov-berkovitch Please open a new issue about this rather than using an old one. Please also check the logs at the time of the authentication, that is the internal server error page for OAuth2 Proxy so it should have logged that there was an error and that should help narrow down the problem |
you are correct - I opened a new issue related to error "http: named cookie not present". That's the real issue i'm facing now. |
Setting OAUTH2_PROXY_COOKIE_SECURE=false environment variable or --cookie-secure=false argument worked for me. See : |
It would be awesome to add support for Keycloak provider.
The text was updated successfully, but these errors were encountered: