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

Token call in Authorization Code flow lack origin header #6012

Closed
BeChaRem opened this issue May 15, 2020 · 3 comments
Closed

Token call in Authorization Code flow lack origin header #6012

BeChaRem opened this issue May 15, 2020 · 3 comments

Comments

@BeChaRem
Copy link

Q&A

  • OS: Windows
  • Browser: Chrome
  • Version: 81
  • Method of installation: nuget via Swashbuckle 5.4.1
  • Swagger-UI version: 3.25.0
  • Swagger/OpenAPI version: Swagger 4.0, OpenAPI 3.0

Content & configuration

Default configuration.

Describe the bug you're encountering

Missing origin header in the request prevent the server from returning the access-control-allow-origin header in the response and Chrome block the response due to CORS.

To reproduce...

Steps to reproduce the behavior:

  1. Have an identity provider supporting authorization code
  2. Host swagger on a different url
  3. Click authorize to start the login workflow
  4. Token call fails due to cors with Errors: Auth error TypeError: failed to fetch
    Access to fetch at 'https://[...]/token' from origin 'https://localhost:44343' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Expected behavior

Expected the origin header to be correctly set and chrome to authorize the call

Screenshots

Token request without the Origin header. https://i.imgur.com/SCBH13M.png

Additional context or thoughts

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
For a CORS request to be valid, the header Origin must be present on the request and the server response with the header Access-Control-Allow-Origin: https://theorigin.com

@BeChaRem
Copy link
Author

This might not be a problem with swagger-ui. When cloning the repo in local and running it I can complete the login and get call token without any cors issue. I will continue to investigate this. Sorry about opening this too soon.

@aldredb
Copy link

aldredb commented Jun 4, 2020

@BeChaRem i experienced this issue as well..did you find the solution?

@BeChaRem
Copy link
Author

BeChaRem commented Jun 4, 2020

No. Same reason as explained by laurynasr in your issue #6081 .

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

2 participants