-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
make sure set-cookie is retained from external auth endpoint #4872
make sure set-cookie is retained from external auth endpoint #4872
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ElvinEfendi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov Report
@@ Coverage Diff @@
## master #4872 +/- ##
==========================================
+ Coverage 58.37% 58.39% +0.01%
==========================================
Files 88 88
Lines 6720 6720
==========================================
+ Hits 3923 3924 +1
+ Misses 2369 2367 -2
- Partials 428 429 +1
Continue to review full report at Codecov.
|
/retest |
/test pull-ingress-nginx-e2e-1-15 |
The regression test is currently wrong. We should use authentication server that returns 401 and also sets cookie. Currently the authentication server only returns cookie and 302 status code. I'll do something like https://github.com/kubernetes/ingress-nginx/pull/4826/files#diff-d1dbbabd02e531d86463819dfef2f7b7R131 and use echoserver for this instead of HTTPBIN. |
@ElvinEfendi I think such a test is not going to test this is working. What about using something like https://github.com/RichardKnop/go-oauth2-server to deploy a real app and run a real e2e test? |
Hi - is this being worked on? If I understand the related PRs fully, external auth has been broken for over a month now. Even if the regression testing isn't perfect, it is better to have this merged than not. |
What do you mean? I have dozens of services exposed with oauth2 running without any issue using the latest version. |
I'm only familiar with the flow that pomerium uses, but it depends on setting a cookie during a 302 to the Specifically:
This cookie identifies futures requests via nginx when it makes the subrequest to Based on testing, I believe #4859 broke the setting of this cookie and this PR restores it. I assumed that other external auth implementations used this same strategy to set up sessions, but I might be wrong. Currently, Pomerium uses this for both nginx and traefik integration. Curiosity - Are you using oauth2_proxy or something else? |
the majority uses oauth2_proxy |
If you have problems with this I suggest you open a separate issue. It would be awesome if you could provide the steps to reproduce it, something like https://gist.github.com/aledbf/48237bd5d2dd23df4b9a2cf83d28d228 |
I will file a formal issue, but the lack of
I'll have full reproduction in the issue I open. Directly related to this PR - I have a simple nginx config that can simulate the responses at play. This may be useful for the regression test:
Corresponding annotations. Replace EXTAUTHENDPOINT: nginx.ingress.kubernetes.io/auth-signin: http://EXTAUTHENDPOINT/sign-in?uri=$scheme://$host$request_uri
nginx.ingress.kubernetes.io/auth-url: http://EXTAUTHENDPOINT/check?uri=$scheme://$host$request_uri |
/retest |
@ElvinEfendi: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
for _, err := range errs { | ||
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
Expect(resp.StatusCode).Should(Equal(http.StatusFound)) |
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.
Remove this line
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
Expect(resp.StatusCode).Should(Equal(http.StatusFound)) | ||
Expect(resp.Header.Get("Location")).Should(Equal(fmt.Sprintf("http://%s/auth/start?rd=http://%s%s", host, host, url.QueryEscape("/?a=b&c=d")))) |
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.
Remove this line
httpbinIP = e.Subsets[0].Addresses[0].IP | ||
|
||
annotations := map[string]string{ | ||
"nginx.ingress.kubernetes.io/auth-url": fmt.Sprintf("http://%s/cookies/set?alma=armud", httpbinIP), |
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.
change to /cookies/set/alma/armud
@ElvinEfendi: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@cmluciano yes. Closed |
@aledbf thanks for addressing this in another PR - I did not have time to complete this. This changes introduces another edge case where when there's an incorrect annotation that renders a Location as invalid then controller will generate invalid Nginx configuration and will not be able to reload it. Here's the bug report with more details: #5130 |
What this PR does / why we need it:
After the workaround in #4859, we no longer retain
Set-Cookie
header set by external authentication server. This PR fixes that.Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer: