Skip to content

Always set the Date header to the current date - #399

Merged
jamesls merged 3 commits into
boto:developfrom
jamesls:fix-auth-date
Dec 5, 2014
Merged

jamesls merged 3 commits into
boto:developfrom
jamesls:fix-auth-date

Conversation

@jamesls

@jamesls jamesls commented Dec 5, 2014

Copy link
Copy Markdown
Member

This fixes a bug where if you resend a request and resign
it without changing the date, you can get an auth error
that your signature is too old if the retry loops fall outside
the auth window (~15 minutes).

What was happening is that we were retrying a failed S3 request,
but because we weren't re-setting the Date header, eventually
the retried request would have a signature that was too old.

I also had to update this for sigv4, but it's a little more complicated.

Part of the reason this change looks more complicated than
you would expect is because we use the sigv4 test suite
(http://docs.aws.amazon.com/general/latest/gr/signature-v4-test-suite.html)
to test our implementation. However, these tests use a Date header
whereas previous versions used an X-Amz-Date.

We can possibly investigate always using Date instead of X-Amz-Date,
but we'd need to make sure we aren't introducing any regressions.

cc @danielgtaylor @kyleknap

This fixes a bug where if you resend a request and resign
it without changing the date, you can get an auth error
that your signature is too old if the retry loops fall outside
the auth window (~15 minutes).

What was happening is that we were trying a failed S3 request,
but because we weren't re-setting the Date header, eventually
the retried request would have a signature that was too old.
Part of the reason this change looks more complicated than
you would expect is because we use the sigv4 test suite
(http://docs.aws.amazon.com/general/latest/gr/signature-v4-test-suite.html)
to test our implementation.  However, these tests use a Date header
whereas previous versions used an X-Amz-Date.

We can possibly investigate always using Date instead of X-Amz-Date,
but we'd need to make sure we aren't introducing any regressions.
@kyleknap

kyleknap commented Dec 5, 2014

Copy link
Copy Markdown
Contributor

Looks good. Looks like you appropriately deleted and then re-added all of the appropriate date headers. 🚢

Comment thread botocore/auth.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this line could ever be True because the same check is performed on line 346.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I'll fix this.

@danielgtaylor

Copy link
Copy Markdown
Contributor

LGTM :shipit:

@jamesls
jamesls merged commit 319e7b4 into boto:develop Dec 5, 2014
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

Successfully merging this pull request may close these issues.

3 participants