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

Add AccessToken as fallback to Authorization header #875

Closed
wants to merge 1 commit into from

Conversation

kvaps
Copy link

@kvaps kvaps commented Oct 27, 2020

Description

This change allows to map Bearer token to Authorization header required by many applications including but not limited to Kubernetes.

Motivation and Context

As part of deprecating louketo-proxy (louketo/louketo-proxy#683), formely known as keycloak-gatekeeper, it is suggested to migrate to oauth-proxy.

Keycloak is issuing the tokens with "typ": "Bearer", and louketo-proxy successfully passing them into application, however oauth2-proxy is not doing that.

See #843 (comment) for more details.

fixes #843
fixes vmware-tanzu/kubeapps#2111

How Has This Been Tested?

  • A docker image with this change has been built
    docker.io/kvaps/oauth2-proxy@sha256:8b022e564717aadfaa31dc53ed4337d4e441fa5e7e73a91954c7bea69e4cb195
    
  • Successfully deployed and authenticated with Keycloak and kubeapps as a backend

Checklist:

  • My change requires a change to the documentation or CHANGELOG.
  • I have updated the documentation/CHANGELOG accordingly.
  • I have created a feature (non-master) branch for my PR.

@kvaps kvaps requested a review from a team as a code owner October 27, 2020 16:34
@@ -1051,6 +1051,8 @@ func (p *OAuthProxy) addHeadersForProxying(rw http.ResponseWriter, req *http.Req
if p.PassAuthorization {
if session.IDToken != "" {
req.Header["Authorization"] = []string{fmt.Sprintf("Bearer %s", session.IDToken)}
} else if session.AccessToken != "" {
req.Header["Authorization"] = []string{fmt.Sprintf("Bearer %s", session.AccessToken)}
Copy link
Member

Choose a reason for hiding this comment

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

@JoelSpeed I'll defer to you on whether to merge this or not since your refactor in #826 completely deletes this codepath.

Otherwise, seems sensible to me -- if we decide to move forward with this I'd like to see some unit tests added.

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 given this would have to be considered a breaking change (people could start getting headers where they didn't before) and that we have the header work being done in #826 which would remove this anyway, we should not be accepting this change for now.

@kvaps For our next release we should have some alpha configuration that allows you to configure headers in a flexible way so that you can do this without the need for this addition.

The only case we haven't covered is fallback, ie, if the session field is empty, fallback to something else. I don't think this is desirable in most cases, unless you have something in particular in mind that justifies a fallback if a part of the session is empty?

@JoelSpeed
Copy link
Member

This codepath has now gone with the merge of #826, before the next release we are going to introduce an advanced/alpha configuration for headers which in turn will allow this feature. I'm going to close this PR for now, if you feel this is inappropriate feel free to reopen/open an issue to discuss the desired feature.

@JoelSpeed JoelSpeed closed this Nov 8, 2020
Jing-ze pushed a commit to Jing-ze/oauth2-proxy that referenced this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forward access token from OIDC login as Authorization Bearer token. Can't login to kubeapps using Keycloak
3 participants