Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable HSTS when using strict #16

Merged
1 commit merged into from
Feb 15, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rack/ssl-enforcer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call(env)
elsif ssl_request?(env)
status, headers, body = @app.call(env)
flag_cookies_as_secure!(headers)
set_hsts_headers!(headers)
set_hsts_headers!(headers) if !@options[:strict]
[status, headers, body]
else
@app.call(env)
Expand Down
5 changes: 5 additions & 0 deletions test/rack-ssl-enforcer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ class TestRackSslEnforcer < Test::Unit::TestCase
get 'http://www.example.org/'
assert_equal ["id=1; path=/", "token=abc; path=/; secure; HttpOnly"], last_response.headers['Set-Cookie'].split("\n")
end

should 'not set hsts' do
get 'http://www.example.org/'
assert !last_response.headers["Strict-Transport-Security"]
end
end

context 'that has hsts options set' do
Expand Down