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

Access token forwarding through nginx auth request #68

Merged
merged 5 commits into from Feb 22, 2019

Conversation

davidholsgrove
Copy link
Contributor

@davidholsgrove davidholsgrove commented Feb 19, 2019

Description

This enables expected behavior when using:

set_xauthrequest = true
pass_access_token = true

If both of these are set, the access token will be included in an X-Auth-Request-Access-Token header, following the X-Auth-Request-* pattern used for User and Email.

The access token allows for further validation by upstream services.

Motivation and Context

Re-targeting of @patrickfuller's PR from original bitly/oauth2_proxy which wasn't merged before fork to pusher/oauth2_proxy.
Original review and discussion available on the PR and issue:
bitly/oauth2_proxy#424
bitly/oauth2_proxy#420

How Has This Been Tested?

Kubernetes helm charts for oauth2_proxy and keycloak

nginx-ingress annotations;

annotations:
            kubernetes.io/ingress.class: nginx
            nginx.ingress.kubernetes.io/auth-response-headers: X-Auth-Request-Access-Token, Authorization
            nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
            nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$request_uri"
            nginx.ingress.kubernetes.io/configuration-snippet: |
                auth_request_set $name_upstream_1 $upstream_cookie_name_1;
                access_by_lua_block {
                    if ngx.var.name_upstream_1 ~= "" then
                    ngx.header["Set-Cookie"] = "name_1=" .. ngx.var.name_upstream_1 .. ngx.var.auth_cookie:match("(; .*)")
                    end
                }

Confirmed X-Auth-Request-Access-Token received by backend, and successfully decoded the JWT access token.

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.

Related to oauth2-proxy#420.

(cherry picked from commit b138872)
Signed-off-by: David Holsgrove <david.holsgrove@biarri.com>
(cherry picked from commit 6fab314)
Signed-off-by: David Holsgrove <david.holsgrove@biarri.com>
@davidholsgrove davidholsgrove requested a review from a team February 19, 2019 00:47
@davidholsgrove davidholsgrove changed the title Pass access token Access token forwarding through nginx auth request Feb 19, 2019
Copy link
Member

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

I've seen the original PR before, it inspired the -set-authorization stuff I worked on! One minor nit and then LGTM

README.md Outdated Show resolved Hide resolved
Example should set header as `X-Access-Token`

Co-Authored-By: davidholsgrove <davidholsgrove@users.noreply.github.com>
@davidholsgrove
Copy link
Contributor Author

@JoelSpeed yeah no worries - I kept @patrickfuller's commits unmodified, but happy for the readme example to be updated 👍

@JoelSpeed
Copy link
Member

Looking good, please add a note to the Changelog and then we can get this merged

@davidholsgrove
Copy link
Contributor Author

Done - thanks :)

@davidholsgrove
Copy link
Contributor Author

Anything else you need from me @JoelSpeed?
Out of interest, do you have a ballpark when you might be cutting a new release? Would be great to switch to vanilla helm chart use of your image instead of my forked image.

Copy link
Member

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Apologies for not getting back to you on this! One minor thing to do with the change note not being in the right section then we can go

As for the release, probably 2-3 weeks time, there's a few things nearly ready to merge and something I've got planned to get done by around mid march that would be good to get released asap

CHANGELOG.md Outdated Show resolved Hide resolved
@JoelSpeed JoelSpeed merged commit 2280b42 into oauth2-proxy:master Feb 22, 2019
aigarius pushed a commit to aigarius/oauth2_proxy that referenced this pull request Mar 8, 2019
* Access token forwarding through nginx auth request

Related to oauth2-proxy#420.

(cherry picked from commit b138872)
Signed-off-by: David Holsgrove <david.holsgrove@biarri.com>

* Improved documentation for auth request token

(cherry picked from commit 6fab314)
Signed-off-by: David Holsgrove <david.holsgrove@biarri.com>

* Update README.md

Example should set header as `X-Access-Token`

Co-Authored-By: davidholsgrove <davidholsgrove@users.noreply.github.com>

* Update Changelog to reference oauth2-proxy#68

* Fix Changelog message location
philpep added a commit to philpep/oauth2-proxy that referenced this pull request Oct 8, 2020
Document feature implemented in oauth2-proxy#68

The feature is already decribed in in the nginx example but not clearly
on each respective parameters documentation.
NickMeves pushed a commit that referenced this pull request Oct 14, 2020
* Document set_xauthrequest with pass_access_token

Document feature implemented in #68

The feature is already decribed in in the nginx example but not clearly
on each respective parameters documentation.

* Update docs/configuration/configuration.md

Co-authored-by: Nick Meves <nick.meves@greenhouse.io>

Co-authored-by: Nick Meves <nick.meves@greenhouse.io>
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.

None yet

3 participants