Apply suggestions from code review

Co-authored-by: Mira <weller@rami.io>
This commit is contained in:
Martin Gross
2025-01-30 12:35:58 +01:00
committed by GitHub
co-authored by Mira
parent e8a716273e
commit b21041a833
+4 -12
View File
@@ -140,16 +140,9 @@ def oidc_validate_and_complete_config(config):
)
if "query_parameters" in config and config["query_parameters"]:
for qp in config["query_parameters"].split("&"):
# Very rudimentary check to avoid the most common footguns:
# - No ? in the query parameters
# - Max of one = (to split key and value)
# - One key, one value. Not just keys with no value.
if not (qp.count('=') == 1 and qp.count('?') == 0 and len(list(filter(None, qp.split('=')))) == 2):
raise ValidationError(
_(f'Query parameter {qp} is invalid.')
)
config["query_parameters"] = urllib.parse.urlencode(
urllib.parse.parse_qsl(config["query_parameters"])
)
config['provider_config'] = provider_config
return config
@@ -167,8 +160,7 @@ def oidc_authorize_url(provider, state, redirect_uri):
}
if "query_parameters" in provider.configuration and provider.configuration["query_parameters"]:
for qp in provider.configuration["query_parameters"].split("&"):
params[qp.split("=")[0]] = qp.split("=")[1]
params.update(urllib.parse.parse_qsl(provider.configuration["query_parameters"]))
return endpoint + '?' + urlencode(params)