Browse Source

Fix cookies not having a SameSite attribute (#15098)

master
Eugen Rochko 4 years ago
committed by GitHub
parent
commit
acc1c03861
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions
  1. +2
    -0
      config/initializers/devise.rb
  2. +2
    -0
      config/initializers/makara.rb
  3. +5
    -1
      config/initializers/session_store.rb

+ 2
- 0
config/initializers/devise.rb View File

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

+ 2
- 0
config/initializers/makara.rb View File

@ -0,0 +1,2 @@
Makara::Cookie::DEFAULT_OPTIONS[:same_site] = :lax
Makara::Cookie::DEFAULT_OPTIONS[:secure] = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'

+ 5
- 1
config/initializers/session_store.rb View File

@ -1,3 +1,7 @@
# 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,
}

Loading…
Cancel
Save