Han*_*dla 9 amazon-web-services hsts aws-api-gateway
我们的安全团队希望 AWS 上的所有 Rest API 都设置 HTTP 严格传输安全 (HSTS) 标头,即使我们的 api 不是从任何网页调用的。
我发现了一些在 Lambda 响应中设置响应标头的用例,但我们的大多数 api 都链接到 SQS 或 SNS。所以我不确定如何在 AWS API GW 中添加此响应标头。
谁能指导我这件事。
我找到了添加严格传输安全 (HSTS) 响应标头的解决方案。我已经通过 AWS 控制台完成了此操作。
步骤 1:在方法响应状态代码下添加Strict-Transport-Security标头。
步骤 2:在Integration Response下,为 HSTS 标头添加必要的映射值。附件是我尝试过的示例。这些值必须用单引号 ( ' ) 提供。

第 3 步:在securityheaders.com网站上验证相同内容。

使用 Cloudformation 设置此值时,请x-amazon-apigateway-integration注意将这些标头值放入双引号之间的单引号中.. ( "'my value here'")
例如
responses:
'200':
description: 200 response for stackoverflow
headers:
Content-Length:
type: string
Timestamp:
type: string
Content-Type:
type: string
Strict-Transport-Security:
type: string
Run Code Online (Sandbox Code Playgroud)
...
x-amazon-apigateway-integration:
responses:
'200':
statusCode: '200'
responseParameters:
method.response.header.Strict-Transport-Security: "'max-age=31536000'"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14468 次 |
| 最近记录: |