提交 add4375a 编写于 作者: A Andrew White

Allow use of durations for ActionDispatch::SSL configuration

上级 e752cb49
......@@ -45,7 +45,7 @@ def redirect_to_https(request)
# http://tools.ietf.org/html/draft-hodges-strict-transport-sec-02
def hsts_headers
if @hsts
value = "max-age=#{@hsts[:expires]}"
value = "max-age=#{@hsts[:expires].to_i}"
value += "; includeSubDomains" if @hsts[:subdomains]
{ 'Strict-Transport-Security' => value }
else
......
......@@ -57,6 +57,13 @@ def test_hsts_expires
response.headers['Strict-Transport-Security']
end
def test_hsts_expires_with_duration
self.app = ActionDispatch::SSL.new(default_app, :hsts => { :expires => 1.year })
get "https://example.org/"
assert_equal "max-age=31557600",
response.headers['Strict-Transport-Security']
end
def test_hsts_include_subdomains
self.app = ActionDispatch::SSL.new(default_app, :hsts => { :subdomains => true })
get "https://example.org/"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册