Skip to content

Commit

Permalink
fix: handle redirect_uri with question mark correctly
Browse files Browse the repository at this point in the history
previously a question mark in redirect URI
resulted in an invalid URI with two question marks
  • Loading branch information
melanger authored Sep 26, 2023
1 parent 1fd663f commit 6b48d0b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions satosa_oidcop/idpy_oidcop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import base64
import logging
import os
from urllib.parse import urlencode
from urllib.parse import urlencode, urlparse, parse_qs
from datetime import datetime

from cryptojwt.key_jar import KeyJar
Expand Down Expand Up @@ -784,7 +784,11 @@ def _handle_backend_response(self, context: ExtendedContext, internal_resp):
)
if _response_placement == "url":
data = _args["response_args"].to_dict()
redirect_url = info_response + f"?{urlencode(data)}"
url_components = urlparse(info_response)
original_params = parse_qs(url_components.query)
merged_params = {**original_params, **data}
updated_query = urlencode(merged_params, doseq=True)
redirect_url = url_components._replace(query=updated_query).geturl()
logger.debug(f"Redirect to: {redirect_url}")
resp = SeeOther(redirect_url)
else: # pragma: no cover
Expand Down

0 comments on commit 6b48d0b

Please sign in to comment.