diff --git a/src/ring/middleware/oauth2.clj b/src/ring/middleware/oauth2.clj index 1cfe870..4b0f863 100644 --- a/src/ring/middleware/oauth2.clj +++ b/src/ring/middleware/oauth2.clj @@ -19,6 +19,7 @@ (defn- authorize-uri [profile request state] (str (:authorize-uri profile) (if (.contains ^String (:authorize-uri profile) "?") "&" "?") + (if (:query-string request) (str (:query-string request) "&")) (codec/form-encode {:response_type "code" :client_id (:client-id profile) :redirect_uri (redirect-uri profile request) diff --git a/test/ring/middleware/oauth2_test.clj b/test/ring/middleware/oauth2_test.clj index 033cb87..3fb4332 100644 --- a/test/ring/middleware/oauth2_test.clj +++ b/test/ring/middleware/oauth2_test.clj @@ -56,6 +56,13 @@ location (get-in response [:headers "Location"])] (is (.startsWith ^String location "https://example.com/oauth2/authorize?business_partner_id=XXXX&")))) +(deftest test-location-uri-with-dynamic-query + (let [profile test-profile + handler (wrap-oauth2 token-handler {:test profile}) + response (handler (mock/request :post "/oauth2/test?hd=tenant.com")) + location (get-in response [:headers "Location"])] + (is (.contains ^String location "?hd=tenant.com&")))) + (def token-response {:status 200 :headers {"Content-Type" "application/json"}