add CookieJar patch to flag cookies as secure based on the connection protocol
rails only allows to globally flag session cookies as either secure or not this patch sets the secure flag for cookies based on the protocol (http/https) this is used to send cookies via http but flag them secure for https which allows use with HTTP over Tor for an onion domain this is acceptable because nginx redirects clearnet http to https
This commit is contained in:
17
config/initializers/auto_secure_cookies.rb
Normal file
17
config/initializers/auto_secure_cookies.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# rails only allows to globally flag session cookies as either secure or not
|
||||
# this patch sets the secure flag for cookies based on the protocol (@secure)
|
||||
# this is used to send cookies via http but flag them secure for https
|
||||
# which allows use with HTTP over Tor for an onion domain
|
||||
# this is acceptable because nginx redirects clearnet http to https
|
||||
|
||||
module ActionDispatch
|
||||
class Cookies
|
||||
class CookieJar
|
||||
private
|
||||
def write_cookie?(cookie)
|
||||
cookie[:secure] = @secure
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,4 +6,4 @@
|
||||
Redstoner::Application.config.session_store :active_record_store,
|
||||
key: 'redstoner_session',
|
||||
expire_after: 5.days,
|
||||
secure: Rails.env.production?
|
||||
secure: nil # see config/initializers/auto_secure_cookies.rb
|
||||
Reference in New Issue
Block a user