Merge pull request #8127 from Matt-Yorkley/session-uri-parsing

Strip subdomains from session cookie host
This commit is contained in:
Matt-Yorkley
2021-09-03 09:38:11 +02:00
committed by GitHub
3 changed files with 10 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ env:
TIMEZONE: UTC
COVERAGE: true
RSPEC_RETRY_RETRY_COUNT: 3
RAILS_ENV: test
jobs:
test-controllers-and-serializers:

View File

@@ -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?

View File

@@ -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
)