http-headers - 标题 "Strict-Transport-Security"两次响应 Swisscom CloudFoundry 应用程序

标签 http-headers cloud-foundry hsts swisscomdev strict-transport-security

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

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

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

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

Strict-Transport-Security:max-age=31536000 ; includeSubDomains
Strict-Transport-Security:max-age=15768000; includeSubDomains

最佳答案

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

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

@EnableWebSecurity
public class WebSecurityConfig extends
        WebSecurityConfigurerAdapter {

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

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

更新 2 : 新行为已经到位。

关于http-headers - 标题 "Strict-Transport-Security"两次响应 Swisscom CloudFoundry 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46672206/

相关文章:

jwt - postman 收集授权不存在于文档标题中

java - 微服务——在不改变代码的情况下改变服务到底意味着什么?

ubuntu - 可以普遍执行严格的运输安全吗?

java - checkmarx 报告中缺少 HSTS header

axios - 如何在axios中的 header 中设置 `Content-Type`?

python - 如何检查传入的 HTTP header 请求的内容

html - 什么是 "X-Content-Type-Options=nosniff"?

cloud-foundry - 带有 Micro Cloud Foundry 的外部域

云代工厂租户 - 什么?

apache - 严格传输安全对重定向到 https 的 http 反向代理的影响