Use Cookie Prefix in Production and Staging

This commit is contained in:
Sebastian Serth
2022-09-03 10:50:29 +02:00
parent 9e08f3a6a8
commit 7f0d8b63f9

View File

@ -2,8 +2,19 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
def self.cookie_prefix
if (Rails.env.production? || Rails.env.staging?) \
&& Rails.application.config.relative_url_root == '/'
'__Host-'
elsif Rails.env.production? || Rails.env.staging?
'__Secure-'
else
''
end
end
Rails.application.config.session_store :cookie_store, Rails.application.config.session_store :cookie_store,
key: '_code_ocean_session', key: "#{cookie_prefix}CodeOcean-Session",
expire_after: 1.month, expire_after: 1.month,
secure: Rails.env.production? || Rails.env.staging?, secure: Rails.env.production? || Rails.env.staging?,
path: Rails.application.config.relative_url_root, path: Rails.application.config.relative_url_root,