about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-04-08 12:47:18 +0200
committerGitHub <noreply@github.com>2022-04-08 12:47:18 +0200
commit6e418bf3465d2df6b47e9b43d3b960504b81e8fb (patch)
tree8c57fbb98431dcfa477872cae3581f08102212b6 /config/initializers
parent46633f1de1dafb860ee444d041f8454c4a0bd62f (diff)
Fix cookies secure flag being set when served over Tor (#17992)
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/devise.rb4
-rw-r--r--config/initializers/session_store.rb2
2 files changed, 2 insertions, 4 deletions
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index b434c68fa..c55bea7a7 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -8,7 +8,6 @@ Warden::Manager.after_set_user except: :fetch do |user, warden|
     value: session_id,
     expires: 1.year.from_now,
     httponly: true,
-    secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
     same_site: :lax,
   }
 end
@@ -23,7 +22,6 @@ Warden::Manager.after_fetch do |user, warden|
       value: session_id,
       expires: 1.year.from_now,
       httponly: true,
-      secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
       same_site: :lax,
     }
   else
@@ -265,7 +263,7 @@ Devise.setup do |config|
 
   # Options to be passed to the created cookie. For instance, you can set
   # secure: true in order to force SSL only cookies.
-  config.rememberable_options = { secure: true }
+  config.rememberable_options = {}
 
   # ==> Configuration for :validatable
   # Range for password length.
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 3d9bf96fd..210964b1f 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -2,5 +2,5 @@
 
 Rails.application.config.session_store :cookie_store,
   key: '_mastodon_session',
-  secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
+  secure: false, # All cookies have their secure flag set by the force_ssl option in production
   same_site: :lax