about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@protonmail.com>2018-09-08 23:54:28 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-09-08 23:54:28 +0200
commit6f3d934bc1c11e7c316e5956c59d4e37541c8737 (patch)
tree6f7b58d4a9cd02726d6854503bcca79c6c588692 /config/initializers
parent7607f4778b0e9021d4ed6ebcafbff60e67e38e59 (diff)
feat(cookies): Use the same-site attribute to lax (#8626)
CSFR-prevention is already implemented but adding this doesn't hurt.

A brief introduction to Same-Site cookies (and the difference between strict and
lax) can be found at
https://blog.mozilla.org/security/2018/04/24/same-site-cookies-in-firefox-60/

TLDR: We use lax since we want the cookies to be sent when the user navigates
safely from an external site.
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/devise.rb2
-rw-r--r--config/initializers/session_store.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index cd9bacf68..3e4c9a79d 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -10,6 +10,7 @@ Warden::Manager.after_set_user except: :fetch do |user, warden|
     expires: 1.year.from_now,
     httponly: true,
     secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
+    same_site: :lax,
   }
 end
 
@@ -20,6 +21,7 @@ Warden::Manager.after_fetch do |user, warden|
       expires: 1.year.from_now,
       httponly: true,
       secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
+      same_site: :lax,
     }
   else
     warden.logout
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 3dc0edd6f..c0757b6b5 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -1,3 +1,3 @@
 # Be sure to restart your server when you modify this file.
 
-Rails.application.config.session_store :cookie_store, key: '_mastodon_session', secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true')
+Rails.application.config.session_store :cookie_store, key: '_mastodon_session', secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'), same_site: :lax