mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Strip subdomains from session cookie host
This commit is contained in:
@@ -39,7 +39,7 @@ module Openfoodnetwork
|
||||
SessionCookieUpgrader, {
|
||||
old_key: "_session_id",
|
||||
new_key: "_ofn_session_id",
|
||||
domain: "." + ENV["SITE_URL"].delete_prefix("www.")
|
||||
domain: ".#{ENV['SITE_URL'].gsub(/^(www\.)|^(app\.)|^(staging\.)|^(stg\.)/, '')}"
|
||||
}
|
||||
) if Rails.env.staging? || Rails.env.production?
|
||||
|
||||
|
||||
@@ -3,9 +3,15 @@
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
# (create the session table with "rails generate session_migration")
|
||||
|
||||
domain = if Rails.env.staging? || Rails.env.production?
|
||||
".#{ENV['SITE_URL'].gsub(/^(www\.)|^(app\.)|^(staging\.)|^(stg\.)/, '')}"
|
||||
else
|
||||
:all
|
||||
end
|
||||
|
||||
Openfoodnetwork::Application.config.session_store(
|
||||
:active_record_store,
|
||||
key: "_ofn_session_id",
|
||||
domain: :all,
|
||||
tld_length: 2
|
||||
domain: domain
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user