oauth2-proxy: I can't get Authorization: Bearer to work with version 6.1.1 . It works with 5.1.1
I’ve tried for several hours to make it work without success.
I’ve used it with keycloak provider and oidc provider.
I’ve tested with echoserver to see the Authorization: Bearer <>
header and no luck.
I think it’s broken.
I am working to configure authentication for kubernetes dashboard.
extraArgs:
provider: 'oidc'
upstream: http://echoserver.default
pass-authorization-header: true
pass-basic-auth: false
skip-jwt-bearer-tokens: true
ssl-upstream-insecure-skip-verify: true
email-domain: '*'
skip-provider-button: true
oidc-issuer-url: "https://REDACTED/auth/realms/gpi-infra"
login-url: "https://REDACTED/auth/realms/gpi-infra/protocol/openid-connect/auth"
redeem-url: "https://REDACTED/realms/gpi-infra/protocol/openid-connect/token"
validate-url: "https://REDACTED/auth/realms/gpi-infra/protocol/openid-connect/userinfo"
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (7 by maintainers)
Hmmm - there might be odd interactions with non-oidc
providers
(you have google set). It was the only Provider where the contributer implemented theCreateSessionStateFromBearerToken
.I’ll need to dig, I believe that is ahead in the middleware chain before the generic extra JWT handlers (that assume OIDC and look for
.well-known/openid-configuration
). I don’t fully know what the Google provider did with tokens in a bearer session pre-v6 (I’m not a google provider user)Thanks for the details!
@harshitmahapatra could you provide us which urls you used?
I struggle a lot because I don’t know what I should put in
--extra-jwt-issuers
. As everyone else I use keycloak and the newest version of oauth2-proxy.When I don’t use the
--extra-jwt-issuers
option I’ll get this error:[2021/02/14 10:23:13] [jwt_session.go:51] Error retrieving session from token in Authorization header: [unable to verify bearer token, oidc: expected audience "CLIENT_ID" got ["account"]]
below is my config what I’m currently running.
config:
When I switch to version 6.1.1 I’ll get without
--extra-jwt-issuers
the following error:EDIT: // I’ve got it working with latest proxy
Running into this with keycloak, everything latest and greatest:
snippit from kubernetes deployment:
Is the solution still to use extra-jwt-issuers?
@pavan-pn as it’s a very long time ago, I can’t remember what I’ve done.
But I switched to https://github.com/travisghansen/external-auth-server because with oauth2-proxy it’s not possible to check on every request if an accessToken is valid or not.
I can confirm I got
keycloak + v6.1.1 + skip-jwt-bearer-tokens
working by removing--oidc-issuer-url
from my config and adding--extra-jwt-issuers
along with--oidc-jwks-url
.I have a theory what’s happening:
Because
keycloak
also uses some of the OIDC parameters, it goes down this codepath: https://github.com/oauth2-proxy/oauth2-proxy/blob/4a54c9421c505446168b2463aa9a5a0b24b752ad/pkg/validation/options.go#L78This results in
SetOIDCVerifier
being called (which makes the first extra-jwt issuer the provider instead of the generic extras): https://github.com/oauth2-proxy/oauth2-proxy/blob/4a54c9421c505446168b2463aa9a5a0b24b752ad/pkg/validation/options.go#L145If that’s the case, the first provider in the chain is Keycloak’s
CreateSessionStateFromBearerToken
: https://github.com/oauth2-proxy/oauth2-proxy/blob/d9c141ae7c88af6e095c513dfcebeede52e95c27/oauthproxy.go#L237Which isn’t implemented.
As a workaround you can set the OIDC details you want to use to validate your sessions
--extra-jwt-issuers
(if anything in the chain passes, auth is valid, so it will just move past theNot Implemented
).Long term, a Keycloak user will need to implement
CreateSessionStateFromBearerToken
and submit a PR. If Keycloak is close to OIDC - the implementation will likely mirror that Providerhttps://github.com/oauth2-proxy/oauth2-proxy/blob/d9c141ae7c88af6e095c513dfcebeede52e95c27/providers/provider_default.go#L120
CC: @JoelSpeed - In case you have any other thoughts since you spearheaded the middlware auth chain refactor.
Can also confirm I’m seeing the same issue where
provider=keycloak
. Version 5.1.0 - 6.0.0 works ok, but version 6.1.1 gives error:Error retrieving session from token in Authorization header: not implemented