about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-02-12 14:02:24 +0100
committerGitHub <noreply@github.com>2021-02-12 14:02:24 +0100
commit8792128f38e19b0d7882468a4f1f9362b98793a0 (patch)
tree2689e394f9f88d05533e70ad0f6bcf622ee2fd5c /lib
parenta30a40c4379b26890b6453083ef213e672658902 (diff)
parent49eef466b8274ca5768deca3309af31bfbf81184 (diff)
Merge pull request #1500 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'lib')
-rw-r--r--lib/action_dispatch/cookie_jar_extensions.rb15
-rw-r--r--lib/rails/engine_extensions.rb11
2 files changed, 26 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)
diff --git a/lib/rails/engine_extensions.rb b/lib/rails/engine_extensions.rb
new file mode 100644
index 000000000..4848b15f2
--- /dev/null
+++ b/lib/rails/engine_extensions.rb
@@ -0,0 +1,11 @@
+module Rails
+  module EngineExtensions
+    # Rewrite task loading code to filter digitalocean.rake task
+    def run_tasks_blocks(app)
+      Railtie.instance_method(:run_tasks_blocks).bind(self).call(app)
+      paths["lib/tasks"].existent.reject { |ext| ext.end_with?('digitalocean.rake') }.sort.each { |ext| load(ext) }
+    end
+  end
+end
+
+Rails::Engine.prepend(Rails::EngineExtensions)