-
Notifications
You must be signed in to change notification settings - Fork 184
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
[full-ci] Refactor proxy to get rid of the hardcoded unprotected lists #4461
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
Gave it a spin, with following results:
|
I refactored the proxy so that we execute the routing before the authentication middleware. This is necessary so that we can determine which routes are considered unprotected i.e. which routes don't need authentication.
I added an unprotected flag to the proxy routes which is evaluated by the authentication middleware. This way we won't have to maintain a hardcoded list of unprotected paths and path prefixes and we will hopefully reduce the times we encounter the basic auth prompt by web browsers.
💥 Acceptance test Core-API-Tests-ocis-storage-1 failed. Further test are cancelled... |
1b2cdc3
to
46f48de
Compare
Kudos, SonarCloud Quality Gate passed! |
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.
Retested a lot of different scenarios, all worked well. Only thing I found was on the archiver route for public links (see comment), but also broken on master, so IMO not a blocker for this PR.
Backend: "http://localhost:9130", | ||
Endpoint: "/signin/", | ||
Backend: "http://localhost:9130", | ||
Unprotected: true, | ||
}, | ||
{ | ||
Endpoint: "/archiver", |
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.
tough one: when the archiver is opened from a public link it needs to be unprotected as well. Archiver from public link has ?public-token=xyz
in the url query.
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'd be fine solving that in a followup ticket, as it's also currently broken in master.
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.
Hm, I guess this should be fixable with an addtional QueryRoute
. I see if I can address this in another PR.
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 to me apart from a little nit picking about the comment.
@@ -91,7 +49,8 @@ func Authentication(auths []Authenticator, opts ...Option) func(next http.Handle | |||
|
|||
return func(next http.Handler) http.Handler { | |||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |||
if isOIDCTokenAuth(r) || isUnprotectedPath(r) { | |||
ri := router.ContextRoutingInfo(r.Context()) | |||
if isOIDCTokenAuth(r) || ri.IsRouteUnprotected() { | |||
// The authentication for this request is handled by the IdP. |
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.
Nit: This comment seems to be not quite correct anymore.
Backend: "http://localhost:9130", | ||
Endpoint: "/signin/", | ||
Backend: "http://localhost:9130", | ||
Unprotected: true, | ||
}, | ||
{ | ||
Endpoint: "/archiver", |
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.
Hm, I guess this should be fixable with an addtional QueryRoute
. I see if I can address this in another PR.
Turns out that this causes some unstable behavior for routes that match multiple rules 😱. E.g. we have:
And now requests on |
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: