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

Missing 'Authorization' header when download file #42

Open
zhongqishi12 opened this issue Jun 21, 2023 · 2 comments
Open

Missing 'Authorization' header when download file #42

zhongqishi12 opened this issue Jun 21, 2023 · 2 comments
Assignees

Comments

@zhongqishi12
Copy link

<LinkButton
      style={{ textDecoration: 'none' }}
      variant="outlined"
      title={`Download ${objectInfo.downloadName}`}
      to={objectInfo.downloadUrl}
      download={objectInfo.downloadName}
>

When click this linkbutton, the Authorization didn't set into the header. It will return 401 on production env

{
  "error": {
  "name": "AuthenticationError",
  "message": "Missing 'Authorization' header in request"
  },
  "request": {
  "method": "GET",
  "url": "[/stream/test/report%2Fscan_20_report.html?endpoint=test-report](https://portal.8293f99d.nip.io/stream/test/report%2Fscan_20_report.html?endpoint=test-report)"
  },
  "response": {
  "statusCode": 401
  }
}

@heyLu
Copy link
Member

heyLu commented Jun 22, 2023

@ivangonzalezacuna, could you have a look at this? As far as I can tell the button definitely works for us internally.

@ivangonzalezacuna
Copy link
Collaborator

This is definitely working for us. All the requests from the backend can easily add the Authorization header, however, to make it work for the frontend there's something required. The steps are explained here: https://github.com/spreadshirt/backstage-plugin-s3/tree/main/plugins/s3-viewer-backend#permissions-setup. Have you added that @zhongqishi12?

If you follow those steps a new cookie called s3_viewer_token is added to all the requests, and the middleware will inject that header to the s3-viewer requests if the Authorization is not found, which is what happens when you click that Button in the UI.

Please, let me know if adding that fixes the issue, otherwise I'll investigate what is missing.

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

No branches or pull requests

3 participants