Skip to content

Commit

Permalink
Added secure flag to cookies and enabled HSTS
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Jan 31, 2024
1 parent ffd5af2 commit a499209
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Enable HSTS in production mode
config.ssl_options = { hsts: { preload: true, expires: 1.year, subdomains: true } }
end
12 changes: 9 additions & 3 deletions config/initializers/session_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
# frozen_string_literal: true

if ENV['LOADBALANCER_ENDPOINT'].present?
Rails.application.config.session_store :cookie_store, key: '_greenlight-3_0_session', domain: ENV.fetch('SESSION_DOMAIN_NAME', nil),
path: ENV.fetch('RELATIVE_URL_ROOT', '/')
Rails.application.config.session_store :cookie_store,
key: '_greenlight-3_0_session',
domain: ENV.fetch('SESSION_DOMAIN_NAME', nil),
secure: Rails.env.production?,
path: ENV.fetch('RELATIVE_URL_ROOT', '/')
else
Rails.application.config.session_store :cookie_store, key: '_greenlight-3_0_session', path: ENV.fetch('RELATIVE_URL_ROOT', '/')
Rails.application.config.session_store :cookie_store,
key: '_greenlight-3_0_session',
secure: Rails.env.production?,
path: ENV.fetch('RELATIVE_URL_ROOT', '/')
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class AddDefaultRecordingVisibilityToSettings < ActiveRecord::Migration[7.1]
def up
setting = Setting.create!(name: 'DefaultRecordingVisibility')
SiteSetting.create!(setting:, value: 'Published', provider: 'greenlight')
Tenant.each do |tenant|
SiteSetting.create!(setting:, value: 'Published', provider: tenant.name)
end
end

def down
Expand Down

0 comments on commit a499209

Please sign in to comment.