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

Cloud CDN Singed Urls and Signed Cookies examples use time-zone unaware datetime objects #12692

Open
pawelkedzior-gl opened this issue Oct 11, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@pawelkedzior-gl
Copy link

The code snippets of Cloud CDN use naive datetime objects as expiration times and depend on deprecated datetime.utcfromtimestamp() function. It is not apparent for the users that they are supposed to pass UTC expiration datetime.

If unnoticed by a user of the snippet, this may lead to generating signatures that are valid for shorter or longer then expected.

In which file did you encounter the issue?

cdn/snippets.py

Describe the issue

If a user create an expiration datetime that depends on local timezone, e.g. by adding expiration period to datetime.now(), the signature may be longer or shorter than expected, depending on the local-time zone, where the code was executed.

Instead, the code snippets should use time-zone aware datetime objects, to ensure that time-zone offsets are taken into account, when the signatures are calculated.

@pawelkedzior-gl pawelkedzior-gl added priority: p2 Moderately-important priority. Fix may not be included in next release. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Oct 11, 2024
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Oct 11, 2024
@glasnt glasnt removed their assignment Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
2 participants