Skip to content

Commit 62ac974

Browse files
committed
Introduce explicit context property to hold the query params
A POST request can have a query string. In that case context.request will hold the data from the POST request body, and thus there is no place to hold the query params. With this changeset, a new property is introduced to hold the query string, parsed as query params. The query params is a list of tuples. Each tuple holds two elements, the query param name and the query param value. Params with no value are dropped. ?param_w_value=123&param_w_no_value Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 7c82d89 commit 62ac974

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/satosa/micro_services/idp_hinting.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ def process(self, context, data):
4141
:param data: the internal request
4242
"""
4343
target_entity_id = context.get_decoration(context.KEY_TARGET_ENTITYID)
44-
query_string = context.request
44+
qs_params = context.qs_params
4545

46-
an_issuer_is_already_selected = bool(target_entity_id)
47-
query_string_is_missing = not query_string
48-
if an_issuer_is_already_selected or query_string_is_missing:
46+
issuer_is_already_selected = bool(target_entity_id)
47+
query_string_is_missing = not qs_params
48+
if issuer_is_already_selected or query_string_is_missing:
4949
return super().process(context, data)
5050

5151
hints = (
5252
entity_id
53-
for param in self.idp_hint_param_names
54-
for entity_id in query_string.get(param, [])
55-
if entity_id
53+
for param_name in self.idp_hint_param_names
54+
for qs_param_name, entity_id in qs_params
55+
if param_name == qs_param_name
5656
)
5757
hint = next(hints, None)
5858

src/satosa/proxy_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def __call__(self, environ, start_response, debug=False):
128128
context.request_uri = environ.get("REQUEST_URI")
129129
context.request_method = environ.get("REQUEST_METHOD")
130130
context.http_headers = collect_http_headers(environ)
131+
context.qs_params = parse_query_string(environ.get("QUERY_STRING"))
131132
environ['wsgi.input'].seek(0)
132133

133134
context.cookie = environ.get("HTTP_COOKIE", "")

0 commit comments

Comments
 (0)