You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+29-10Lines changed: 29 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,16 @@ An [Otoroshi](https://github.com/MAIF/otoroshi) plugin that validates [YouSign](
4
4
5
5
## How it works
6
6
7
-
Every webhook sent by YouSign includes an `X-Yousign-Signature-256` header whose value is an HMAC-SHA256 hash of the raw request body, prefixed with `sha256=`.
7
+
The plugin is provider-agnostic: the signature header, HMAC algorithm and prefix are all configurable. Out of the box it is pre-configured for YouSign, whose webhooks include an `X-Yousign-Signature-256` header containing an HMAC-SHA256 hash of the raw request body prefixed with `sha256=`.
8
8
9
9
The plugin:
10
10
11
11
1. Reads the raw request body.
12
-
2. Computes `HMAC-SHA256(secret, rawBody)` using the secret configured in the plugin.
13
-
3. Compares the result (constant-time, to prevent timing attacks) against the `X-Yousign-Signature-256` header.
14
-
4. Forwards the request to your backend unchanged when the signature is valid.
15
-
5. Returns **401 Unauthorized** when the signature is missing or invalid.
12
+
2. Computes `HMAC-<algorithm>(secret, rawBody)` using the configured secret and algorithm.
13
+
3. Prepends the configured prefix to the hex-encoded hash to form the expected signature.
14
+
4. Compares the result (constant-time, to prevent timing attacks) against the configured signature header.
15
+
5. Forwards the request to your backend unchanged when the signature is valid.
16
+
6. Returns **401 Unauthorized** when the signature is missing or invalid.
16
17
17
18
## Create a route to receive YouSign webhooks
18
19
@@ -37,7 +38,10 @@ $ curl -X POST 'http://otoroshi-api.oto.tools:8080/api/routes' \
|`prefix`|`string`| no | derived from `algorithm`| String prepended to the hex hash before comparison (e.g. `sha256=`). Defaults are derived automatically from the chosen algorithm. |
overridedefdescription:Option[String] =Some("This plugin validates YouSign webhook payloads by verifying the HMAC SHA-256 signature present in the X-Yousign-Signature-256 header.")
91
+
overridedefdescription:Option[String] =Some("This plugin validates webhook payloads by verifying an HMAC signature. The header name, algorithm and prefix are all configurable (defaults to YouSign's X-Yousign-Signature-256 / HmacSHA256 / sha256=).")
0 commit comments