Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ring/middleware/oauth2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions test/ring/middleware/oauth2_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down