-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
JWT bearer passthrough #65
JWT bearer passthrough #65
Conversation
6e31fb3
to
fac781b
Compare
Looks like some tests are failing, could you try rebasing onto our master branch and see if that fixes the issue? |
9372ff3
to
9470608
Compare
@brianv0 By the way, you did a great work. I tried it, it is perfect and |
I tried this as well and it worked great. However, I'm using |
@meastman It seems the Try to add But maybe oidc should be automatically defined for google provider |
👍 That worked great.
Agreed. I just wanted to mention it so it could at least be considered. |
I've been meaning to get back to this soon, I don't understand what the travis error was - it looks like it was transient. I think it's the case that Google, Azure are both technically OIDC providers but under a different name. Since Google is sort of special it could be considered so you don't have to explicitly list it. |
@brianv0 Have you had a chance to look into this PR? I'd love to get this merged to master and start securing my API endpoint with oauth2_proxy. This is a feature that many people have been waiting for for a long time. Let me know if you need help with testing it. |
9470608
to
21e10a9
Compare
I've done a new round on this and also added some unit tests. @JoelSpeed if you wouldn't mind re-reviewing this? |
Will this patch make it possible to authenticate using only a "bearer token" (JWT) from an Authorization header, e.g no cookies? I built a custom image with this patch, but get |
Yes, do you have the proper flags set by chance? What Provider are you using? I started adding some more complete tests to make sure I’m sane, but it seems fine to me. |
Hi, I am using an OIDC provider (keycloak) and have set My setup is like this. I got an OAuth2 proxy setup protecting the frontend which basically follows the Nginx example in the README. But with an additional "location" for an "upstream" API (this is setup in k8s). This OAuth2 proxy is configured to "pass" the authorization header on a call to upstream (nginx). The idea was to have another OAuth2 proxy in front of the (nginx) upstream API and use a bearer token only validation. In order to ensure that the proxy in front of the API only authenticates using validation of the JWT I have explicitly removed the "oauth2" cookies issued by the frontend proxy before proxying traffic to the upstream API (I hope that explanation made sense). |
I added what should be a more realistic test case for that in b3135e8, and it seems to be working just fine. I will be testing this out today on my own environment (it's been a little slow on this I need some other unrelated patches). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @brianv0, there's a few comments outstanding on this one, please take a look
1574ed9
to
a526126
Compare
Okay I think addressed all the relevant issues and I did a rebase to pull in the new logging changes |
This patch works for me, but only in "proxy" mode. I could not figure out why neither refresh tokens or JWT validation did not work in "auth_request" mode despite following suggested work arounds for header size limits, but it's indicative that the issue I had was outside the scope of this patch. |
Ah okay, so this is something I didn’t touch. The
I would note that this is useful when other backends also expect some kind of header. I could add code to return the authorization header too, I will have to look and see if there was a reason why they didn’t do that originally though. |
Just to chip in here as I authored the |
@brianv0 Can you update for the conflict ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brianv0 I've left a comment below about a security concern when decoding the JWT, could you please verify and fix if my concerns are correct. Otherwise I'm happy with this PR and we should be good to merge soon
RefreshSessionIfNeeded checks the token expiry, we want to use the ID token's expiry
Unit tests for token discovery
311a220
to
5a50f62
Compare
@JoelSpeed - I added an extra check to always validate the groups, if possible, of the token, based on #141, in bd651df. It's not clear to me if this check will actually ever be executed - only the Google provider does a group check and I'm not sure if there's an easy way to get a bearer token from Google in any case, but I figured it might be surprising if that was the case. (PS - this shows a change is requested, but I believe the previous changes were already applied) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good now, thanks for all your work on this @brianv0!!!
* fix google service-account.json secret generation * bump chart version to 5.0.3 * base64 encode the secret value as expected by k8s * bump chart version to 5.0.4
Description
Adds support to skip JWT bearer tokens, when the issuer is either the configured issuer (if using an OIDC issuer) or a set of additional JWT issuers.
Motivation and Context
This is an implementation for #18.
How Has This Been Tested?
Tested in a kubernetes environment.
You need to get your token. An easy thing to do is to deploy an application behind oauth2_proxy that just prints it, then you can grab that token and re-request the same URL. Other than that, you can get it from the oauth2_proxy container, if it's running. For example, in kubernetes:
...then look for X-Auth-Request-Token, assuming you configured oauth2_proxy with
-pass-authorization-header
.From there, you can just do something like the following:
curl --header "Authorization: Bearer $TOKEN" https://example.com/my-protected-page
Checklist: