-
Notifications
You must be signed in to change notification settings - Fork 14
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
4.1.3 does not allow configuration via query parameters #156
Comments
Oh interesting. I wonder if we should add a |
So |
|
Simply adding the Besides the technical detail - the upstream project decided to disable parameter overrides via url query params as a response to a security advisory - I personally think we should not overrule this decision in a downstream distribution. A solution could be to modify the As a workaround, I copied the index.html to my server root, editing the parameters as required and sourcing the assets (js, css, etc) via the webjar.
|
Thanks @cachescrubber for the details on that. I would really rather not modify the upstream code. That becomes a maintenance burden. I wonder what other options we have? |
Not many I think. The springdoc project is transforming the index.html on the fly, if I understand the code correctly. |
I'll chime in to say I did what @cachescrubber did (below):
EDIT: I also agree that the webjar should not override the setting from a security perspective. |
FYI User Interface (UI) Misrepresentation of Critical Information |
After two days of trying to figure this out I finally found this thread. I was eventually able to get the workaround described by @cachescrubber to work locally after some trial and error For future people who aren't running static assets through Play yet, the trick was to put the swagger.html file in a new directory tree: Then add the route entry:
Unfortunately, after deployment I'm seeing some issues, probably because static assets aren't exposed publicly by default at my company, so now I have to figure that out :headache:. Edit: the fix for ^ was to add this to the Dockerfile:
Definitely hoping for a solution to this soon! |
Thanks for the details! One thing to note is that some of these workarounds might depend on classpath ordering which is tricky and can seem like indeterminate behavior when it doesn't work as expected (ie something produced a different classpath order). |
Any plans to simply revert cfe7a37 @jamesward ? |
@datagitlies It sounds like that commit didn't fix anything so yeah, I should revert it. But I also don't think it breaks anything, right? |
As a side note, if re-enabling the query functionality through the URI reintroduces the security vulnerability, I personally would no longer be able to use this library 😢 |
It doesn't break anything because it doesn't work (currently) but I don't want it to accidentally start working somehow in a future release which could open my application to the security vulnerability described. Hence, I asked about reverting the change so the EDIT: I'm happy to open a pull request - just let me know. |
Sounds good. I'm releasing |
I am still unable to get this working btw. |
workaround for playframework with
(i've just changed this line:
(i use iheartradio for swagger generation, |
I'll second what @papirosko said. I just created my own |
I solved this by adding swagger-config.yaml in the resource folder (some-project/src/main/resources/swagger-config.yaml) and set
|
All this pseudo security movement makes me cry. |
My fix for the (nonexisting) problem. Copy and modify processResources {
with copySpec {
def artifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find({ it.moduleVersion.id.name == 'swagger-ui' })
from zipTree(artifact.file).matching { include '**/index.html' }.singleFile
into 'static'
filter { line -> line
.replace('https://petstore.swagger.io/v2/swagger.json', '/openapi.yaml')
.replace('StandaloneLayout', 'BaseLayout')
.replace('="./', """="/webjars/swagger-ui/$artifact.moduleVersion.id.version/""")
}
}
} for newer use V2 (upd with lazy artefact resolving): processResources {
with copySpec {
from {
def artifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find({ it.moduleVersion.id.name == 'swagger-ui' })
zipTree(artifact.file).matching({ include '**/index.html' }).singleFile
} into 'static'
filter {
def artifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find({ it.moduleVersion.id.name == 'swagger-ui' })
it.replace('="./', """="/webjars/swagger-ui/$artifact.moduleVersion.id.version/""").replace('</body>', """
<script> window.onload = function() {
const ui = SwaggerUIBundle({url: "/openapi.yaml", dom_id: '#swagger-ui', deepLinking: true,presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], plugins: [ SwaggerUIBundle.plugins.DownloadUrl ], layout: "BaseLayout" });
window.ui = ui;
};</script></body>
""")
}
}
} @jamesward How about adding solutions that are shared in the issue to the readme? |
Thanks for the workarounds. I'd rather not patch the upstream in the WebJar because that becomes a maintenance burden. Has anyone worked with the Swagger team to see if there is a possible upstream fix to this? |
@jamesward absolutely agree with you! The problem should be solved on swagger UI side or end user side. While I'm not sure about the first, my code snippet solves the problem on end user side, so no changes to original code swagger UI code. |
What I wrote is not true. Managed to test with some other modifications 🤦.
Will try use one of the other workarounds. |
The latest Swagger UI documentation notes that only |
This upstream change means that it is no longer possible to pass configuration as query parameters https://github.com/swagger-api/swagger-ui/releases/tag/v4.1.3.
So URLs like http://localhost:8080/my-api/docs/index.html?url=/my-api/openapi3.json now display the default Petstore API.
Is there a way of setting
queryConfigEnabled
to true when using the webjar (https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#core)?The text was updated successfully, but these errors were encountered: