-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Cookie authentication doesn't work in swagger-editor #1951
Comments
Thank you in advance for your help |
Cookie authentication currently does not work in Swagger UI and Swagger Editor because of browser security restrictions that prevent web pages from modifying certain headers (such as |
@hkosova Thank you for your answer... If browser security restrictions prevents web pages from modifying headers like "Cookie", then Why there is a Cookie Authentication section in the Swagger documentation that seems to tell us that it is possible to do "Cookie Authentication" ? |
That doc is an OpenAPI syntax guide. OpenAPI Specification allows describing cookie authentications in API definitions. Swagger tools (Editor, UI, etc.) are specific implementations of the OpenAPI Specification. Since Swagger Editor/UI are web pages run entirely client-side in a browser, they are subject to browser security mechanisms like forbidden headers, CORS, etc. Other tools may or may not have the same limitations depending on their implementation and runtime environment. For example, one of the workarounds discussed in swagger-api/swagger-js#1163 is to proxy the requests through a server-side application to work around browser restrictions. SwaggerHub does this, so cookie authentication works in API docs hosted on SwaggerHub. |
Thanks for your answer..It is more clear now.. |
Closing due to inactivity. This is simply to keep our issue tracker clean - feel free to comment if there are any further thoughts or concerns, and we'll be happy to reopen this issue. To future readers: you should check swagger-api/swagger-js#1163 for more information about this limitation in general. |
Q&A (please complete the following information)
Content & configuration
OpenAPI definition:
Describe the bug you're encountering
Event if a cookie authentification is defined (under the components->securitySchemes section) in the OpenAPI configuration file (yaml), it seems that Swagger Editor does not send cookie authentication data to the Web Server. But when executing the Swagger Editor generated CURL command in a command line window, the Web Server receive properly the cookie data for authentication.
To reproduce...
Steps to reproduce the behavior:
Expected behavior
Normally, After clicking on the "Execute" button of the API, the Web Server should have a "Cookie" header with the data described in the cookieAuth security scheme. But the request on the Web Server has no "Cookie" in his headers
Screenshots
The Available authorizations window:
The API we want to test:
The response we have after executing the API:
The content of request headers on the Web Server:
As you can see, no "cookie" header is available in the request headers. However, there is the "authorization" header
The Curl command generated by Swagger Editor:
The content of request headers on the Web Server when Swagger Editor generated Curl command is manually executed:
As you can see, there is a "cookie" header in the request headers. There is also an "authorization" header.
The result I receive in the command line console when Swagger Editor generated Curl command is manually executed:
Additional context or thoughts
The text was updated successfully, but these errors were encountered: