Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Add Authorization: Bearer <jwt> as an optional header from OIDC style providers #530

@JoelSpeed

Description

@JoelSpeed

I've come across several applications/apis Authorization: Bearer <jwt> as a header for authentication, a major one of these being Kubernetes and the Kubernetes Dashboard.

I have my own copy of this repo where the OIDC provider returns the raw IdToken instead of the Access token to put in front of Kubernetes, but I did this quickly and in a hacky way. I'd like to make it proper and provide the functionality upstream.

I would like to propose the addition of pass-authorization-header and set-authorization-header flags to the OAuth Proxy. The effect of which would be similar to the pass-access-token and set-x-auth-request flags respectively.

The effect of this would be, that for certain providers, where the login process generates an IdToken (can see this in the OIDC provider and Google providers for instance), then the proxy would add a header to the proxied requests/auth requests of Authorization: Bearer <IdToken>.

To do this, you could add an IdToken field to the SessionState object.

type SessionState struct {
AccessToken string

Then providers such as the OIDC provider and the Google provider could set this field during the Redeem method and then the proxy could set the headers in a very similar way to the below snippet

oauth2_proxy/oauthproxy.go

Lines 698 to 700 in ae49c7d

if p.PassAccessToken && session.AccessToken != "" {
req.Header["X-Forwarded-Access-Token"] = []string{session.AccessToken}
}

I don't know too much about how the other providers work, but they may well also be able to set Authorization headers in a similar way.

If you think this is a worthwhile and a reasonable approach, I will start working on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions