springwolf-core icon indicating copy to clipboard operation
springwolf-core copied to clipboard

Content Security Policy

Open atul-gawali opened this issue 1 year ago • 7 comments

I am looking for a sample code of springwolf-ui (without plugin) using asynapi file. I tried steps provided at https://www.springwolf.dev/docs/faq but couldn't get the springwolf UI generated from my asyncapi file placed in resources folder of my spring boot app

atul-gawali avatar Sep 26 '24 18:09 atul-gawali

Welcome to Springwolf. Thanks a lot for reporting your first issue. Please check out our contributors guide and feel free to join us on discord.

github-actions[bot] avatar Sep 26 '24 18:09 github-actions[bot]

Hi @atul-gawali, unfortunately there is no example project for using springwolf-ui as a standalone component. Can you provide more information on what is not working after following the documentation? For example:

  • Does your spring boot backend serve the async api file for the correct path?
  • Does your spring boot backend serve the springwolf ui?
  • Is there an error in the browser?

sam0r040 avatar Sep 27 '24 16:09 sam0r040

Hi @sam0r040 I am also try to do similar thing in my spring boot project to render asyncapi json in springwolf-ui. We have a asyncapi.json file and now based on this json file we want to generate the async-ui in our spring-boot application.

Q1. Does your spring boot backend serve the async api file for the correct path?

We put the asyncapi.json file in /resources/springwolf/docs as per the documentation. Btw we tried to put the file in /resources/static, /resources and /META-INF/resources/

Q2. Does your spring boot backend serve the springwolf ui?

We added below springwolf-ui dependency. <groupId>io.github.springwolf</groupId> <artifactId>springwolf-ui</artifactId> 1.6.0

Q3. Is there an error in the browser?

No error is showing.

Do we need any properties in application.properties for the filepath of ayncapi.json file?

abhishekanand1902 avatar Sep 30 '24 05:09 abhishekanand1902

Hi @sam0r040

We wrote spring boot application by following the documentation https://www.springwolf.dev/docs/faq to display the UI for asyncapi file(asyncapi.json). But the application doesn't display the details as in asyncapi file. Here is a screenshot of the browser. image

Here is the sample code springwolf-ui.zip. Can you please check the sample code?

ajit2k21 avatar Sep 30 '24 10:09 ajit2k21

@ajit2k21 Have you checked the browsers network tab to see whether the GET request is successful?

Just to double check: The asyncapi file is located at springwolf/docs without any extension (docs is the file name)?

timonback avatar Oct 04 '24 11:10 timonback

@timonback Thanks for reply. Now I am able to display the asyncapi-ui.html in the sample application. We integrated the springwolf-ui dependency to our product but found some issues with ui like as below because our product follow the "Content Secure Policy"(Reference: https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html) so its block the inline the css and js. Here is the screenshot of asyncapi-ui.html and its contents. It has inline css codes. image

As per the Content Secure Policy, all inline CSS and JS contents must be in external files and links in HTML files.

Can you please suggest to me how can we resolve the Content Secure Policy issue? Are you planning to work on this issue?

ajit2k21 avatar Oct 17 '24 14:10 ajit2k21

Hi @ajit2k21 , great to hear.

You are welcome to contribute a Content Security Policy to make Springwolf better.

We use a default Angular application setup on the frontend, see springwolf-ui folder. CSP sound like a common problem, there are probably helpful guides out there.

timonback avatar Oct 18 '24 13:10 timonback

Hi @ajit2k21 , great to hear.

You are welcome to contribute a Content Security Policy to make Springwolf better.

We use a default Angular application setup on the frontend, see springwolf-ui folder. CSP sound like a common problem, there are probably helpful guides out there.

Is there any update on the "Content Security Policy" enhancement?

ajit2k21 avatar Nov 14 '24 01:11 ajit2k21

We had a look noticed that CSPs are configured on the webserver and not by Springwolf. We had a look at the necessary configuration changes (switching optimizations off in angular.json) in the build process and decided against it due to the complexity. Even with this change a slightly different CSP-header is required.

sam0r040 avatar May 23 '25 14:05 sam0r040