-
Notifications
You must be signed in to change notification settings - Fork 9k
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
The global security requirement seems to be ignored or securityDefinitions is not read #1889
Comments
swagger-ui doesn't automatically parse the |
I see. I haven't realized that. Would you be open to a pull request which adds parsing of |
I think a PR would be great, but it may get complicated. I'm sure you've seen the |
I've found #1454, #1108 and #764 which are all on the subject as far as I can tell. You are right that the UI is the biggest hurdle. Unfortunately, I am ill equipped for that. What if we take a middle road? Make sure all "simple" authentication methods work out of the box. That is, all which can fit in the current interface: token in query or header, basic authentication. This would be relatively easy to do. It is an incremental improvement and will probably save you the time for answering tickets such as this one. |
@ironsmile looks like we may have some updates on this soon, so please stay tuned. |
I agree it is somewhat misleading that swagger-ui does not respect the security definitions (which are part of the documentation). Ideally there should also be a way to indicate the |
Yes, as @webron mentioned, we are actively working on making the auth rendering dynamic based on the spec, which is how it should work. |
Fixed by #2014 |
It seems that no matter what you have in
securityDefinitions
andsecurity
Swagger UI ignores them and simply appends "api_key" into the query.I am using master (3aaf121310) with an API which has global security requirements and few possible ways for authentication (described in
securityDefinitions
). Example:What happens
When I use the Swagger UI it makes requests which do not use any of the security definitions. It does:
This is the output in the "Curl" section. Using the dev tools and logs from the API I was able to verify that this is equivalent to what it actually does.
As can be seen, neither securityDefinition is used. Nowhere in the definitions there is a mention of "api_key" query parameter. Regardless, it is added in the query with the token I've pasted.
What should happen
The UI should make a request which is equivalent to
or
The first one has a query parameter "token" (from the "api_key_token" security definition) and the second one has the header "X-Auth-Token" (from the "api_header_token" definition).
How to easily reproduce
I value your time so I've cooked up a full example specification which can be used for verifying the problem. It can be seen at pastebin. It is pity that CORS rules makes it so that it cannot be "explored" in the Swagger UI with this direct url.
The text was updated successfully, but these errors were encountered: