Skip to content
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

Hydrator mutator isn't compatible with gzipped responses. #988

Open
4 of 6 tasks
juan131 opened this issue Aug 2, 2022 · 1 comment
Open
4 of 6 tasks

Hydrator mutator isn't compatible with gzipped responses. #988

juan131 opened this issue Aug 2, 2022 · 1 comment
Labels
bug Something is not working.

Comments

@juan131
Copy link

juan131 commented Aug 2, 2022

Preflight checklist

Describe the bug

As it's described in the documentation, the hydrator mutator works by sending a POST request containing a JSON representation of AuthenticationSession to the URL you configure (it's also possible to customize the authentication headers if needed). However, the rest of headers to use on that POST request can't be customized.

It seems that Oathkeeper is accepting gzip-encoding but then it's unable to handle it.

Reproducing the bug

  1. I have an Golang API that uses chi's as router and uses the "Compress" middleware (see https://github.com/go-chi/chi#core-middlewares), this middleware compress the HTTP responses using gzip when the requester adds the header Accept-Encoding: gzip. This API exposes an endpoint that accepts POST requests including a AuthenticationSession (as described in the docs).
  2. Run Oathkeeper configuring a Hydrator mutator that uses the API mentioned above.
  3. Test the Hydrator mutator by accessing a resources protected by Oathkeeper.
  4. Oathkeeper is sending the POST accepting gzipped encoding, but then it's unable to decode the response (see relevant logs).

Relevant log output

{
    "error": {
      "message": "invalid character '\\x1f' looking for beginning of value"
    },
    (...)
    "level": "warning",
    "msg": "The mutation handler encountered an error",
    "mutation_handler": "hydrator",
    "reason_id": "mutation_handler_error",
    (...)
}

Relevant configuration

serve:
  mutators:
    hydrator:
      enabled: true
      config:
        api:
          url: https://MY-CUSTOM-API-WITH-GZIP-ENCODING-SUPPORT/

Version

v0.38.25-beta.1

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Kubernetes

Additional Context

If I disable the Compress middleware in my API, it works as expected.

@juan131 juan131 added the bug Something is not working. label Aug 2, 2022
@mvanderlee
Copy link

mvanderlee commented Sep 21, 2022

Same goes for brotli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

2 participants