diff options
Diffstat (limited to 'lib/action_dispatch')
-rw-r--r-- | lib/action_dispatch/cookie_jar_extensions.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/action_dispatch/cookie_jar_extensions.rb b/lib/action_dispatch/cookie_jar_extensions.rb new file mode 100644 index 000000000..44c39c1f8 --- /dev/null +++ b/lib/action_dispatch/cookie_jar_extensions.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module ActionDispatch + module CookieJarExtensions + private + + # Monkey-patch ActionDispatch to serve secure cookies to Tor Hidden Service + # users. Otherwise, ActionDispatch would drop the cookie over HTTP. + def write_cookie?(*) + request.headers['Host'].ends_with?('.onion') || super + end + end +end + +ActionDispatch::Cookies::CookieJar.prepend(ActionDispatch::CookieJarExtensions) |