Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Monkey patch Rack::Session to send secure cookies to onions (mastodon…
Browse files Browse the repository at this point in the history
  • Loading branch information
cohosh authored Feb 13, 2021
1 parent 5aa66fc commit 3447bd2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/action_dispatch/cookie_jar_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ def write_cookie?(*)
end

ActionDispatch::Cookies::CookieJar.prepend(ActionDispatch::CookieJarExtensions)

module Rack
module SessionPersistedExtensions
def security_matches?(request, options)
request.headers['Host'].ends_with?('.onion') || super
end
end
end

Rack::Session::Abstract::Persisted.prepend(Rack::SessionPersistedExtensions)

0 comments on commit 3447bd2

Please sign in to comment.