From d84767c0b7402d14f235a52877a2597ef9f4998a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 6 Aug 2025 08:56:39 +0100 Subject: [PATCH] Monkey patch OmniAuth to redirect POST callbacks to GET --- config/initializers/omniauth_oauth2.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 config/initializers/omniauth_oauth2.rb diff --git a/config/initializers/omniauth_oauth2.rb b/config/initializers/omniauth_oauth2.rb new file mode 100644 index 000000000..238fcbbe5 --- /dev/null +++ b/config/initializers/omniauth_oauth2.rb @@ -0,0 +1,22 @@ +module OpenStreetMap + module OmniAuth + module Strategies + module OAuth2 + def callback_phase + if request.request_method == "POST" + query = URI.encode_www_form(request.params) + uri = URI::Generic.build(:path => callback_path, :query => query) + + session.options[:skip] = true + + [303, { "Location" => uri.to_s }, []] + else + super + end + end + end + end + end +end + +OmniAuth::Strategies::OAuth2.prepend(OpenStreetMap::OmniAuth::Strategies::OAuth2) -- 2.39.5