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

Allow signature validation without timestamp tolerance enforcement #93

Closed
svix-frank opened this issue Jul 10, 2021 · 5 comments
Closed

Comments

@svix-frank
Copy link
Contributor

svix-frank commented Jul 10, 2021

Should keep it enabled by default, but we might want to allow custom tolerances or allow to disable the tolerance enforcement altogether.

Can be useful if you want to verify old payloads or if you have a bad clock.

@masahiro-yamamoto-rc
Copy link

@svix-frank
Would you let me know why this issue was closed, please?

We are in a situation where we need to use a custom tolerance.
We are going to create a subclass of __verify_timestamp, but wondering why such a simple method is prefixed with double underscore.

def __verify_timestamp(self, timestamp_header: str) -> datetime:
webhook_tolerance = timedelta(minutes=5)
now = datetime.now(tz=timezone.utc)
try:
timestamp = datetime.fromtimestamp(float(timestamp_header), tz=timezone.utc)
except Exception:
raise WebhookVerificationError("Invalid Signature Headers")
if timestamp < (now - webhook_tolerance):
raise WebhookVerificationError("Message timestamp too old")
if timestamp > (now + webhook_tolerance):
raise WebhookVerificationError("Message timestamp too new")
return timestamp

@dimaqq
Copy link

dimaqq commented Apr 25, 2024

Asking for the same tweak but for a different reason than OP: sometimes, things go bad in production and webhooks need to be retried for business reasons.

Ref: https://news.ycombinator.com/item?id=27823109

@tasn tasn reopened this Apr 25, 2024
@tasn
Copy link
Member

tasn commented Apr 25, 2024

I reopened it. No idea why it was closed, but at the very least it's useful for tests (if not a variety of other use-cases too).

Asking for the same tweak but for a different reason than OP: sometimes, things go bad in production and webhooks need to be retried for business reasons.

You should generate a new signature when you retry (Svix already does it).

@dimaqq
Copy link

dimaqq commented Apr 25, 2024

Sorry I mean to say “processing of web hooks received from a 3rd party”

@svix-jplatte
Copy link
Member

There's a function VerifyIgnoringTimestamp for this nowadays. Please let us know if we closed this in error.

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

5 participants