Drop dependency on secure_headers, fix response headers (#15712)
* Drop dependency on secure_headers, use always_write_cookie instead * Fix cookies in Tor Hidden Services by moving configuration to application.rb * Instead of setting always_write_cookie at boot, monkey-patch ActionDispatch
This commit is contained in:
parent
eb23f98592
commit
21fb3f3684
8 changed files with 24 additions and 16 deletions
|
@ -25,6 +25,7 @@ require_relative '../lib/devise/two_factor_pam_authenticatable'
|
|||
require_relative '../lib/chewy/strategy/custom_sidekiq'
|
||||
require_relative '../lib/webpacker/manifest_extensions'
|
||||
require_relative '../lib/webpacker/helper_extensions'
|
||||
require_relative '../lib/action_dispatch/cookie_jar_extensions'
|
||||
require_relative '../lib/rails/engine_extensions'
|
||||
|
||||
Dotenv::Railtie.load
|
||||
|
|
|
@ -9,6 +9,7 @@ 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
|
||||
|
@ -19,6 +20,7 @@ Warden::Manager.after_fetch do |user, warden|
|
|||
value: warden.cookies.signed['_session_id'] || warden.raw_session['auth_id'],
|
||||
expires: 1.year.from_now,
|
||||
httponly: true,
|
||||
secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
|
||||
same_site: :lax,
|
||||
}
|
||||
else
|
||||
|
@ -227,6 +229,10 @@ Devise.setup do |config|
|
|||
# If true, extends the user's remember period when remembered via cookie.
|
||||
# config.extend_remember_period = false
|
||||
|
||||
# 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 }
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length.
|
||||
config.password_length = 8..72
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Makara::Cookie::DEFAULT_OPTIONS[:same_site] = :lax
|
||||
Makara::Cookie::DEFAULT_OPTIONS[:secure] = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
SecureHeaders::Configuration.default do |config|
|
||||
config.cookies = {
|
||||
secure: true,
|
||||
httponly: true,
|
||||
samesite: {
|
||||
lax: true
|
||||
}
|
||||
}
|
||||
config.csp = SecureHeaders::OPT_OUT
|
||||
end
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
Rails.application.config.session_store :cookie_store, {
|
||||
key: '_mastodon_session',
|
||||
secure: (Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'),
|
||||
same_site: :lax,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue