-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add API route config #1760
Add API route config #1760
Conversation
In addition to requests with Accept header `application/json` return 401 instead of 302 to login page on requests matching API paths regex.
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.
This looks great, couple of nits but otherwise LGTM, thanks for putting this together
oauthproxy_test.go
Outdated
|
||
if tc.shouldRedirect { | ||
assert.Equal(t, 302, rw.Code) | ||
// assert.Equal(t, "Allowed Request", rw.Body.String()) |
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.
Do we need this line?
pkg/validation/options.go
Outdated
@@ -96,6 +96,8 @@ func Validate(o *options.Options) error { | |||
}) | |||
} | |||
|
|||
msgs = append(msgs, validateApiRoutes(o)...) |
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.
Can you move this up to the top of the function, I don't think we need to have it down here right?
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.
LGTM thanks
Please resolve the linter issues |
* Add API route config In addition to requests with Accept header `application/json` return 401 instead of 302 to login page on requests matching API paths regex. * Update changelog * Refactor * Remove unnecessary comment * Reorder checks * Lint Api -> API Co-authored-by: Sebastian Halder <[email protected]>
Hey, is there a plan on when to release this in some patch version? Im using the docker image and not sure how to use the master branch directly. Any help is highly appreciated |
Release should come soon, need to find the time to get the release together |
Hi @segfault16, please could you confirm what the format of the --api-route configuration option is? I have a number of paths that I want to return a 401 Unauthorized if a bearer token is not present instead of issuing a 302 redirect to the OIDC provider. I'm applying the following in my yaml:
And the parameters are confirmed in the logs:
But when I try with a curl I'm still getting the 302 redirect instead of a 401:
I've tried various variations on the structure of the path_regex but it doesn't seem to want to match. |
@johnswarbrick-napier Your regex doesn't match. You probably mean this: |
Sorry, that was a typo in my comment.
I tried simplifying it with a single path and these variants but still get the 302 redirection:
|
Hi @segfault16. Any thoughts on why even a simple path in I assume the path regex isn't matching but I cannot figure out why. |
Description
In addition to requests with Accept header
application/json
return 401 instead of 302 to login page on requests matching API paths regex.Motivation and Context
Several APIs like grpcweb or graphql don't use
application/json
. See #551How Has This Been Tested?
Extended unit tests
Checklist: