Onion service related changes to HTTPS handling (#15560)
* Enable secure cookie flag for https only * Disable force_ssl for .onion hosts only Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
parent
d499bb031f
commit
e79f8dd85c
8 changed files with 27 additions and 11 deletions
|
@ -9,7 +9,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
|
||||
|
@ -20,7 +19,6 @@ 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
|
||||
|
@ -229,10 +227,6 @@ 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,2 +1 @@
|
|||
Makara::Cookie::DEFAULT_OPTIONS[:same_site] = :lax
|
||||
Makara::Cookie::DEFAULT_OPTIONS[:secure] = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
|
||||
|
|
10
config/initializers/secureheaders.rb
Normal file
10
config/initializers/secureheaders.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
SecureHeaders::Configuration.default do |config|
|
||||
config.cookies = {
|
||||
secure: true,
|
||||
httponly: true,
|
||||
samesite: {
|
||||
lax: true
|
||||
}
|
||||
}
|
||||
config.csp = SecureHeaders::OPT_OUT
|
||||
end
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
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