redirect endpoint returning a 302 redirect to AWS S3 - generating an auth problem
See original GitHub issueI 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:
- Created 5 years ago
- Comments:16 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
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 😃