-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Support for Content-Security-Policy Trusted-Types to fix error Failed to set the 'innerHTML' property on 'Element'
#1566
Comments
Hi, thanks for pointing me into the right direction! I got it working by extending I would like to share my Solution: Extend
Define Bean of the above class in a
Reference the
|
Thank you for your sharing! |
Problem:
I have setup a Content-Security-Policy that requires trusted types, also for my swagger-ui.html.
My CSP header looks like
Content-Security-Policy: ...; require-trusted-types-for 'script'; trusted-types default;
It broke my Swagger, when expanding an endpoint on the UI. The UI shows the message
😱 Could not render n, see the console.
. My console says tons of messages likeTypeError: Failed to set the 'innerHTML' property on 'Element': This document requires 'TrustedHTML' assignment. at ve (swagger-ui-bundle.js:2:739971) at ou (swagger-ui-bundle.js:2:806017) at Cs (swagger-ui-bundle.js:2:826320) at Os (swagger-ui-bundle.js:2:826203) at ks (swagger-ui-bundle.js:2:826070) at Ss (swagger-ui-bundle.js:2:825933) at vs (swagger-ui-bundle.js:2:822920) at swagger-ui-bundle.js:2:772592 at t.unstable_runWithPriority (swagger-ui-bundle.js:2:849631) at Wo (swagger-ui-bundle.js:2:772369)
.Possible Solutions:
InnerHTML is not safe to use because of XSS, that is why my CSP breaks things. This is fixable by adding a javascript function that defines the missing default policy. I just don't know how to add it to the swagger-ui bundle.
trusted-types
?The text was updated successfully, but these errors were encountered: