mirror of
https://github.com/pretix/pretix.git
synced 2026-08-17 11:56:27 +00:00
Apply suggestions from code review
Co-authored-by: Mira <weller@rami.io>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user