Fintoc-Signature header.
Fintoc signs every event sent to your webhook endpoints. The Fintoc-Signature header lets you verify that Fintoc, not a third party, sent each event.
Fintoc generates a secret when you register a webhook endpoint. You need this secret to validate the Fintoc signature of every event.
Verify that Fintoc sent the event
Each event sent by Fintoc includes theFintoc-Signature header. The header contains a Unix timestamp in t and a signature in v1. For example:
Validate the signature with the Fintoc SDKs
If you use Node or Python, verify webhook signatures with the Fintoc Node SDK or Fintoc Python SDK.Validate the signature with your own code
If you want to write your own implementation or use a different programming language, follow these steps:Extract the timestamp and the signature
Split theFintoc-Signature header at each , character. Then, split each array element at the = character to obtain a key-value pair. Get the corresponding value for each key.
Rebuild the signed message
The signed message consists of the timestamp, a. character, and the raw request body. Rebuild the message with the timestamp from the Fintoc-Signature header.
message should look like this:
Generate the signature
Generate the signature with SHA-256 and the secret returned when you created the webhook endpoint.Compare the signatures
Compare the signature from theFintoc-Signature header with the signature you generated. If both signatures match, the event came from Fintoc.
Prevent a replay attack
To prevent a replay attack, define an acceptable age for events. When you receive an event, compare the timestamp from theFintoc-Signature header with the current time. Use five minutes as the default tolerance. Accept events within this range, and discard events outside it.
Test the integration
Confirm that signature validation works before you rely on it in production. Trigger a test event for your webhook endpoint from the Fintoc Dashboard, then check how your handler responds:- With a valid signature, your handler validates the header and processes the event.
- With an invalid signature, such as a modified
v1value or the wrong secret, your handler rejects the event and returns400 Bad Request.