Skip to content

Commit a499209

Browse files
committed
Added secure flag to cookies and enabled HSTS
1 parent ffd5af2 commit a499209

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

config/environments/production.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,7 @@
159159

160160
# Do not dump schema after migrations.
161161
config.active_record.dump_schema_after_migration = false
162+
163+
# Enable HSTS in production mode
164+
config.ssl_options = { hsts: { preload: true, expires: 1.year, subdomains: true } }
162165
end

config/initializers/session_store.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
# frozen_string_literal: true
1818

1919
if ENV['LOADBALANCER_ENDPOINT'].present?
20-
Rails.application.config.session_store :cookie_store, key: '_greenlight-3_0_session', domain: ENV.fetch('SESSION_DOMAIN_NAME', nil),
21-
path: ENV.fetch('RELATIVE_URL_ROOT', '/')
20+
Rails.application.config.session_store :cookie_store,
21+
key: '_greenlight-3_0_session',
22+
domain: ENV.fetch('SESSION_DOMAIN_NAME', nil),
23+
secure: Rails.env.production?,
24+
path: ENV.fetch('RELATIVE_URL_ROOT', '/')
2225
else
23-
Rails.application.config.session_store :cookie_store, key: '_greenlight-3_0_session', path: ENV.fetch('RELATIVE_URL_ROOT', '/')
26+
Rails.application.config.session_store :cookie_store,
27+
key: '_greenlight-3_0_session',
28+
secure: Rails.env.production?,
29+
path: ENV.fetch('RELATIVE_URL_ROOT', '/')
2430
end

db/data/20231213203353_add_default_recording_visibility_to_settings.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ class AddDefaultRecordingVisibilityToSettings < ActiveRecord::Migration[7.1]
44
def up
55
setting = Setting.create!(name: 'DefaultRecordingVisibility')
66
SiteSetting.create!(setting:, value: 'Published', provider: 'greenlight')
7+
Tenant.each do |tenant|
8+
SiteSetting.create!(setting:, value: 'Published', provider: tenant.name)
9+
end
710
end
811

912
def down

0 commit comments

Comments
 (0)