-
Notifications
You must be signed in to change notification settings - Fork 681
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
fix #6617 and #6659 #6661
base: main
Are you sure you want to change the base?
fix #6617 and #6659 #6661
Conversation
Changes: - use dagRoute's AuthContext and AuthDisabled in HTTPS-Upgrade to fix 6659 - Use globalExtAuth.AuthPolicy.Disabled to calculate dagRoute.AuthDisabled - Fix Tests Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6661 +/- ##
==========================================
- Coverage 81.76% 81.03% -0.74%
==========================================
Files 133 133
Lines 15944 20016 +4072
==========================================
+ Hits 13037 16220 +3183
- Misses 2614 3503 +889
Partials 293 293
|
@sunjayBhatia can you please add required labels to this one? |
Thank you @tsaarni for the label. |
@SamMHD I will try to arrange time for myself to review ASAP today or tomorrow! |
Thank you so much @tsaarni |
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.
Looks good!
Regarding testing the fix: Would it be possible to add a new test case in the e2e test suite that would have caught this bug. There are global ext auth tests here but they currently only cover disabled: false
.
Also tagging @clayton-gonsalves for your input, as your review would be valuable since you originally implemented this functionality.
Thank you for your feedback; I'll add the tests as suggested. I previously attempted to write tests for this scenario but found the existing test functions a bit incompatible to implement |
Exactly, the existing test functions make no sense for |
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
I think I have implemented a workaround to this by making the test function more flexible. Btw, Do you think we still need to add this to e2e tests? |
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
@tsaarni Do have time to review the changes again? |
@tsaarni @sunjayBhatia @skriss is there any update on this? |
Why nobody answer us? :((( |
Sorry @SamMHD I haven’t had a chance to review yet, I've been swamped 😅 |
thank you @tsaarni , when do you think you can give it a look? |
Hello again, Is there any update on this PR? @tsaarni |
Hi @SamMHD and apologies once more for the delays! I've now created an environment to test this PR. It works well, however it seems override can only be done at the route level and not at the virtual host level. This example does not work: apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: echoserver
spec:
virtualhost:
fqdn: protected.127-0-0-101.nip.io
tls:
secretName: ingress
authorization:
authPolicy:
disabled: false
routes:
- services:
- name: echoserver
port: 80 It seems that with this scenario we end up in this code branch where it will try use the uninitialized extension name from |
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
Very good point dear @tsaarni , I have visited that code branch and fixed it, other than this one more thing came to my attention, and it was that "If we disable global auth in vhost configuration then we can not enable it back again in a route" so I have fixed it in "else clause" of same code branch. Can you give it a try or help me setup your test environment for myself? I think it should be fixed now. |
The Contour project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to the #contour channel in the Kubernetes Slack |
dear @tsaarni , do you have any update on this PR? |
/lgtm |
Thank you so much @izturn 🙌 |
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.
@SamMHD Looks very good! I re-tested the PR and it worked perfectly now. I still added suggestions for the change log to hopefully highlight the change bit more clearly to the users, please check and see what you think.
@@ -0,0 +1,7 @@ | |||
## Disable ExtAuth by default if GlobalExtAuth.AuthPolicy.Disabled is set | |||
|
|||
Global external authorization or vhost-level authorization is enabled by default unless an AuthPolicy explicitly disables it. By default, `disabled` is set to `GlobalExtAuth.AuthPolicy.Disabled`. This global setting can be overridden by vhost-level AuthPolicy, which can further be overridden by route-specific AuthPolicy. Therefore, the final authorization state is determined by the most specific policy applied at the route level. |
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.
Global external authorization or vhost-level authorization is enabled by default unless an AuthPolicy explicitly disables it. By default, `disabled` is set to `GlobalExtAuth.AuthPolicy.Disabled`. This global setting can be overridden by vhost-level AuthPolicy, which can further be overridden by route-specific AuthPolicy. Therefore, the final authorization state is determined by the most specific policy applied at the route level. | |
Global external authorization can now be disabled by default and enabled by overriding the vhost and route level auth policies. | |
This is achieved by setting the `globalExtAuth.authPolicy.disabled` in the configuration file or `ContourConfiguration` CRD to `true`, and setting the `authPolicy.disabled` to `false` in the vhost and route level auth policies. | |
The final authorization state is determined by the most specific policy applied at the route level. |
## Disable External Authorization in UpgradeHTTPS | ||
|
||
From now on, Contour will configure Envoy to handle HTTPS Redirection without authorization on routes. (previously if GlobalExtAuth was set, Envoy would check request with ext_auth before redirection which could result in 401 instead of redirection) |
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.
## Disable External Authorization in UpgradeHTTPS | |
From now on, Contour will configure Envoy to handle HTTPS Redirection without authorization on routes. (previously if GlobalExtAuth was set, Envoy would check request with ext_auth before redirection which could result in 401 instead of redirection) | |
## Disable External Authorization in HTTPS Upgrade | |
When external authorization is enabled, no authorization check will be performed for HTTP to HTTPS redirection. | |
Previously, external authorization was checked before redirection, which could result in a 401 Unauthorized error instead of a 301 Moved Permanently status code. |
closes #6617 and #6659
In order to fix #6617 I have changed how
dagRoute.DisableAuth
is caclulated.Also, to fix #6659 I thought it is needed to change behavior when we are upgrading a request to HTTPS (when
permitInsecure
is not set and we are redirecting HTTP to HTTPS). Thereby, whendagRoute.AuthContext
/dagRoute.AuthDisabled
is configured it will affect redirection as well -- before these changes, redirection won't care about them.Changes: