-
Notifications
You must be signed in to change notification settings - Fork 16
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
When no Accept Header is set in the original request, 2 Accept headers will be added by the plugin #48
Comments
Thanks, @pokerjocke70 , for the report. This is certainly a bug due to the refactor in 6f379c3. Can you build and test the changes on the |
ok, thanks. We will try to build it today and test it, however for us to move forward we need to get rid of application/jwt value as well. The preferred way (for us at least ) would be that you leave the original request untouched. Why do you even add an Accept header at all? |
If your calling a standard-compliant HTTP service, I don't think it'll be an issue. The spec says:
So, if the request includes:
Then, the HTTP service should service whatever it has unless it really can return the requested resource as a JWT (which I highly doubt in all cases).
This reason is, as tried to explain: The subrequest adds |
Yes, it will probably work with both the 2 new headers. We are moving from an old api gateway that does not tamper with the request so preferably we would like the new gateway to do the same. And the application/jwt is only leaked into the request when trying to add the '/' and that seems to be done after the response from the Curity call. What if this code:
was changed to:
|
I don't disagree that what's being done here is sloppy, but the HTTP spec tells me it's gonna be OK.
I don't think this matters if the downstream services comply with HTTP and don't product JWTs.
Then, the request would look like this:
The way NGINX works is that the subrequest's headers are the same as the main one's (the new subrequest's headers point to the same headers as the main request). So, once the subrequest is created and the I think this would have gone unnoticed if it weren't for the bug in setting the length of the string in the With the change I've made now, the HTTP server will be told that the client accepts anything, but prefers JWTs (due to the sloppiness). The server doesn't have a JWT representation of any resource, so it will see that the client accepts anything and will return a non-error result. I'll look a bit more into how to make this subrequest's header changes to not affect the main request, but please test it. I'm 99% it will solve your problem. |
We have tested the fix now and can verify that is solves the problem with the invalid characters. Thanks. |
Great, @pokerjocke70. Shall we make a release, so you can use that? We can continue to cleanup this sloppiness in the meantime, but it would feel good to get a release that unblocks you. Should we do that? |
Please go ahead with the release. |
Solved by #49 |
If you make a request without the Accept header set the plugin will try to add a '*/*' Accept header to the original request but that seem not to work as expected because we end up with application/jwt being added as well and also there are some garbage at the end of the '*/*' value.
// Accept header set, orignal accept header left untouched after introspection
// No accept header, Curity adds 2 Accept headers after introspection
The problem seems to originate from the code https://github.com/curityio/nginx_phantom_token_module/blob/master/phantom_token.c#L271
Looking at the code it seems a bit strange that the plugin should alter the original request.
Versions:
Curity: 1.1.0
Nginx: 1.19.6
K8s ingress-nginx-controller: 0.44.0
The text was updated successfully, but these errors were encountered: