Skip to content

Commit 817dac1

Browse files
committed
Enable HTTP Strict-Transport-Security
1 parent 17cddbc commit 817dac1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class App < Sinatra::Application
1212
Rack::Mime::MIME_TYPES['.webapp'] = 'application/x-web-app-manifest+json'
1313

1414
configure do
15-
use Rack::SslEnforcer, only_environments: ['production', 'test'], hsts: false, force_secure_cookies: false
15+
use Rack::SslEnforcer, only_environments: ['production', 'test'], hsts: true, force_secure_cookies: false
1616

1717
set :sentry_dsn, ENV['SENTRY_DSN']
1818
set :protection, except: [:frame_options, :xss_header]

test/app_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def app
2121
assert_equal 'https://example.com/test?q=1', last_response['Location']
2222
end
2323

24+
it 'returns HSTS header' do
25+
get 'https://example.com/test'
26+
assert_equal 'max-age=31536000; includeSubDomains', last_response['Strict-Transport-Security']
27+
end
28+
2429
describe "/" do
2530
it "works" do
2631
get '/'

0 commit comments

Comments
 (0)