Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect request signature #21

Closed
zen4ever opened this issue Sep 3, 2016 · 1 comment
Closed

Incorrect request signature #21

zen4ever opened this issue Sep 3, 2016 · 1 comment

Comments

@zen4ever
Copy link
Contributor

zen4ever commented Sep 3, 2016

There is a bug in sorting query string parameters in case when parameter keys include dashes

https://github.com/sam-washington/requests-aws4auth/blob/master/requests_aws4auth/aws4auth.py#L661

Here parameters are sorted after they urlencoded, which puts them in a wrong order.

For example:

sorted("id=1000000161418039&id-type=receipt".split("&"))
>>> ['id-type=receipt', 'id=1000000161418039']

If you sort them by name, as AWS describes here http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html, the order would be the following

sorted([tuple(pair.split("=")) for pair in "id=1000000161418039&id-type=receipt".split("&")], key=lambda x: x[0])
>>> [('id', '1000000161418039'), ('id-type', 'receipt')]
@tedder
Copy link
Owner

tedder commented Mar 3, 2021

merged.

@tedder tedder closed this as completed Mar 3, 2021
tedder added a commit that referenced this issue Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants