Skip to content

Commit

Permalink
Fix saltstack#61243 by checking for GET method before add GET params
Browse files Browse the repository at this point in the history
  • Loading branch information
jynolen committed Nov 18, 2021
1 parent 71ccdb9 commit 6fbc067
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/61243.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a conditon to be able to add version params only when using GET method
8 changes: 5 additions & 3 deletions salt/utils/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ def sig4(
if location is None:
location = DEFAULT_LOCATION

querystring = ""
params_with_headers = params.copy()
if product not in ("s3", "ssm"):
params_with_headers["Version"] = aws_api_version
if method == "GET":
params_with_headers["Version"] = aws_api_version
keys = sorted(params_with_headers.keys())
values = list(map(params_with_headers.get, keys))
querystring = urllib.parse.urlencode(list(zip(keys, values))).replace("+", "%20")
Expand Down Expand Up @@ -344,8 +346,8 @@ def sig4(
)

new_headers["Authorization"] = authorization_header

requesturl = "{}?{}".format(requesturl, querystring)
if querystring:
requesturl = "{}?{}".format(requesturl, querystring)
return new_headers, requesturl


Expand Down

0 comments on commit 6fbc067

Please sign in to comment.