-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Swagger-UI calls don't work with JWT auth #2836
Comments
OK, I just got it to work. Just added:
Really JWT is magic, so easy 😃 ! |
Also, may I suggest an improvement, currently we don't have the "api_key" field on our Swagger-Ui (see for example: http://petstore.swagger.io/). It would be nice at least for JWT to be able to set different tokens directly in Swagger-UI and then try the APIs with those tokens. This is interesting for the "granular security feature of JWT. |
All changes we make to swagger-ui/_index.html have to be manually merged when we update swagger-ui, this is why we don't have yet the api_key input field but I like your idea. This manual merge is a bit painful at the moment. I'm wondering whether this could be easier by externalizing our JS code from the index.html |
@PierreBesson the code for the swagger page comes from springfox (https://github.com/springfox/springfox/tree/master/springfox-swagger-ui/src/web). I have removed the api_key text box on purpose but it is easy to put it again. |
@gmarziou I see the problem that would arise when updating swagger-ui. But externalizing the js will not be enough to prevent all merge conflicts. I have an idea on how we could handle this but maybe it's a bit crazy. |
Oh and this means that we could be using the webjar. |
The index.html provided by springfox is not the original one from swagger-ui. |
springfox.js is just the js code that was extracted from the original index.html and on which they added some special "springfox" features (ui conf from java bean, docket group selection, ...) |
But shouldn't we move to springfox's swagger-ui ? |
@PierreBesson But the apiKey we want to pass (for instance JJWT or CSRF token) comes from javacript, not from java and is dynamic so it can't come from a bean |
Maybe we could PR to springfox to add the possibility to pass the api key and api key name by url |
@cbornet Oh I see...
Yes it would be nice to have, but would it be enough to handle all our authentication schemes. |
Whatever the auth type, we always call SwaggerClient.ApiKeyAuthorization() so that should be OK. |
This is why we enabled it only for dev. |
If we would like to customize swagger-ui a lot, it might be interesting to follow this idea. A second JHipster intern will arrive next week and he has some angular experience, he could help me to develop this. Then we could extends swagger-ui functionality for the gateway, for example to add a way to sort the available API, arrange them by folder or search the available resources)... |
Sounds good, the directive I tried 3 months ago was angular-swagger-ui. I just reviewed it and it is not very active, I checked also 2 others who are even less active. So I'm afraid that these projects may not offer very good support and not migrate to angular 2 soon. |
I dont think it will be hard to write a directive if our own. Its better
|
When using swagger UI on an application that uses JWT as authenticationType, the "Try it out" feature fails and return something like this:
It seems that some people have already managed to solve this problem (see this swagger-ui issue).
I plan to do a PR to fix that. What I will do is get the JWT token from localStorage and follow instructions from the previous link.
Please tell me if you have any thought on this.
The text was updated successfully, but these errors were encountered: