CSP ssue 与部署在 Elastic Beanstalk 中的 Jhipster 应用程序

CSP ssue with Jhipster App deployed in Elastic Beanstalk

我的应用程序是非常简单的 Jhispter(带有 Angular)应用程序,它使用 mapbox 和 google fonts 作为外部库。 我只是将它部署到 Elastic Beanstalk。 我用谷歌搜索并找到了一些答案,我应该只将 index.html 文件中的元数据标记更改为:

<meta http-equiv="Content-Security-Policy" content="default-src *;
    img-src * 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
    style-src  'self' 'unsafe-inline' *">

但是没有用。

我也在属性文件中启用了它,但似乎没有影响。

  cors:
    allowed-origins: "*"
    allowed-methods: "*"
    allowed-headers: "*"
    exposed-headers: "Link,X-Total-Count"
    allow-credentials: true
    max-age: 1800

CSP is also a challenging web security like CORS.

Jhipster 中,它是在 Spring 启动时配置的,所以我不得不允许一些受信任的 url 并将我的 CSR 配置更改为:

.contentSecurityPolicy("default-src 'self'; frame-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.mapbox.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: *.amazonaws.com; font-src 'self' data:")

此答案基于以上非常有用的评论