question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

redirect endpoint returning a 302 redirect to AWS S3 - generating an auth problem

See original GitHub issue

I have a download endpoint in my API which is redirecting the user to a AWS S3 presigned URL

Here is the swagger file describing my endpoint:

openapi: 3.0.0
info:
  title: My API
  description: API
  version: 2.0

servers:
  - url: myapi.com
    description: API v2.0.
components:
  securitySchemes:
    Auth:
      type: apiKey
      in: header
      name: Authorization
security:
  - Auth: []
paths:
  /download/:
    get:
      summary: Download
      description: Download
      responses:
        '302':
          description: Redirects to a location for downloading
          content:
            application/gzip:
              schema:
                type: string
                format: binary

My problem is when the SwaggerUI (version 3.14.2) it trying the endpoint it does get the redirect order, but when it tries to go the redirect location it for some reason sends the “Authorization” header to that URL although it’s not on the same domain.

This problem is causing AWS S3 to omit the following error because it’s receiving both “Authorization” header and the “AWSAccessKeyId” get parameters.

<?xml version="1.0"?>
<Error>
  <Code>InvalidArgument</Code>
  <Message>Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified</Message>
  <ArgumentName>Authorization</ArgumentName>
  <ArgumentValue>Token TTTTTTTTTTTTT</ArgumentValue>
  <RequestId>RRRRRRRRRRRRRR</RequestId>
  <HostId>HHHHHHHHHHHHHHHH</HostId>
</Error>

Any idea how to solve this issue?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
shockeycommented, Aug 28, 2018

@kobymeir @MaxHo1234, upon further inspection, this is a limitation within the browser. The request is being transparently followed, with no way to control the behavior from within a web application like Swagger UI. Postman gets around this with their Interceptor extension, which is not subject to the same constraints.

I’m going to keep this open: if there’s sufficient interest, we could consider building a similar extension that allows users to circumvent browser limitations.

1reaction
kobymeircommented, Aug 6, 2018

Hi @shockey

There is no reason to pass on the authorization headers as you have no idea where the redirect it going, thus potentially exposing the authorization token to a 3rd party that we might not want them to receive the token.

Hope that my answered helped 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request routing - Amazon Simple Storage Service
The default endpoint redirects the request to the correct endpoint with an HTTP 302 response. Temporary redirects contain a URI to the correct...
Read more >
How to solve CORS problems when redirecting to S3 signed ...
Temporary redirect to signed URLs simplifies the frontend ... First, there is a request to the backend, asking to sign an S3 URL....
Read more >
AWS s3 forces 302 redirects when url has no trailing slash
You can fix this problem now using CloudFront and Lambda@Edge. You can intercept the request coming back from S3 using the 'origin response' ......
Read more >
Extractions/RawExtractionResults AWS download - Forum
I expect result to have a 302 status code with the redirect to the S3 ... The endpoint gives a 200 response and...
Read more >
How To Fix the HTTP 302 Error (5 Methods) - Kinsta
However, if your website is delivering 302 redirects in error, it's a sign that something's wrong. Don't worry — you can fix this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found