为API设置Strict-Transport-Security标头

时间:2014-03-03 02:59:02

标签: api http http-headers

为API响应设置Strict-Transport-Security标头是否有意义(例如,不维护状态的请求)并且很可能不是来自浏览器。

1 个答案:

答案 0 :(得分:2)

不幸的是,HSTS RFC没有提到API。

在2.1使用案例中,它声明:

o  Web browser user wishes to interact with various web sites (some
  arbitrary, some known) in a secure fashion.

o  Web site deployer wishes to offer their site in an explicitly
  secure fashion for their own, as well as their users', benefit.

http://tools.ietf.org/html/rfc6797#section-2.1

它明确指出"网络浏览器"我认为可以安全地假设HSTS是为通过Web浏览器访问的资源而设计的。

如果您认为以后网络浏览器可能会使用您的API,那么我建议您添加HSTS标头。如果您的API永远不会通过网络浏览器访问,那么您就不需要HSTS标头,但是,将其添加到未来的证据中可能是值得的。你的API决定你将来应该通过网络浏览器访问它(和/或将来允许HTTP连接)。

相关问题