标题为"Strict-Transport-Security"两次,以响应Swisscom CloudFoundry应用程序

ssc*_*ep3 5 http-headers cloud-foundry hsts swisscomdev strict-transport-security

将Swisscom CloudFoundry解决方案与Spring Boot应用程序一起使用时,Strict-Transport-Security会在HTTPS响应中添加两个标头.我已经研究过这个问题,并发现CloudFoundry解决方案添加了几个标题.默认情况下,Spring Boot也已添加Strict-Transport-Security标头(在安全站点上),这会导致两个不同的HSTS标头.

我想在我的应用程序中配置我的应用程序的标头.有没有办法禁用Swisscom CloudFoundry解决方案的自动标题添加?

如果没有,有没有办法告诉Swisscom Cloud覆盖现有的Strict-Transport-Security标题而不是将其附加到标题列表?

部署Swisscom Cloud的Spring Boot应用程序的HTTP响应包含以下两个标头:

Strict-Transport-Security:max-age=31536000 ; includeSubDomains
Strict-Transport-Security:max-age=15768000; includeSubDomains
Run Code Online (Sandbox Code Playgroud)

Mat*_*ler 4

感谢您的报告。我们目前仅插入(而不是替换)HSTS 标头,因为我们不知道某些框架默认添加它。我们将考虑始终覆盖标头,因为重复的标头可能没有意义,并且我们设置的默认值适合大多数用例。

目前:您可以在 Spring Boot 中禁用设置 HSTS 吗?根据Spring boot 文档,您应该能够使用以下代码片段禁用它:

@EnableWebSecurity
public class WebSecurityConfig extends
        WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            // ...
            .headers()
                .frameOptions().sameOrigin()
                .httpStrictTransportSecurity().disable();
    }
}
Run Code Online (Sandbox Code Playgroud)

更新:我们将很快更改此行为:Appcloud 仅在应用程序尚未设置标头时才设置标头。因此,我们将选择权留给开发人员是否以及如何实现 HSTS,但它将提供默认值。

更新 2:新行为已到位。