-
Notifications
You must be signed in to change notification settings - Fork 360
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: add support for compressed hydrator. Closes #988 #1018
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1018 +/- ##
==========================================
- Coverage 78.06% 77.98% -0.09%
==========================================
Files 83 83
Lines 3999 4010 +11
==========================================
+ Hits 3122 3127 +5
- Misses 598 604 +6
Partials 279 279
|
@@ -215,8 +221,21 @@ func (a *MutatorHydrator) Mutate(r *http.Request, session *authn.AuthenticationS | |||
return errors.New(ErrNon200ResponseFromAPI) | |||
} | |||
|
|||
// Handle compressed data |
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.
The go stdlib HTTP client should do that automatically, does it not?
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.
From the stdlib HTTP docs:
// If the Transport requests gzip on
// its own and gets a gzipped response, it's transparently
// decoded in the Response.Body. However, if the user
// explicitly requested gzip it is not automatically
// uncompressed.
So because we set the Accept-Encoding header, we must decompress ourselves.
Based on what I and Juan131 observed, the transport was not decoding the response prior to that either.
It's been over 2 years since I touched Go and we've been running this code in production all this time.
However, I have not yet tested again with the latest version of Go.
Oathkeeper doesn't restrict the encoding it accepts when making the hydrator HTTP call. If the hydrator is configured with compression it will try to parse the compressed string directly as JSON and fail.
This PR restricts the accepted encoding types to gzip and deflate, and add the ability to handle those encodings.
I experimented with brotli as well, but that would require CGO, which seemed too big of a change.
Related issue(s)
#988
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security. vulnerability, I
confirm that I got green light (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments
I've already deployed this fix in our production environment and it work.
Don't think we need to update any docs as this fixes a low level bug.