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

Always set the Date header to the current date #399

Merged
merged 3 commits into from
Dec 5, 2014

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Dec 5, 2014

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
Copy link
Contributor

kyleknap commented Dec 5, 2014

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

if 'X-Amz-Date' in request.headers:
del request.headers['X-Amz-Date']
request.headers['X-Amz-Date'] = self.timestamp
if 'Date' in request.headers:
Copy link
Member

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
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
Member

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