From d2a2c6cc95b431ae810e68ee75fe5a93fad5c69a Mon Sep 17 00:00:00 2001 From: Gabriel Odero Date: Wed, 26 Jul 2023 14:21:30 +0300 Subject: [PATCH] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 73cb8f0..8d5e758 100644 --- a/README.md +++ b/README.md @@ -582,12 +582,36 @@ public async Task GetMessage() } ``` +## Verify Webhook X-Hub-Signature-256 (.NET 7 Minimal API) (Credits @sapharos) +```c# +app.Use((context, next) => +{ + context.Request.EnableBuffering(); + return next(); +}); + +// Validation implementation + +string stringifiedBody; +string xHubSignature256 = context.Request.Headers["X-Hub-Signature-256"].ToString(); +context.Request.Body.Seek(0, SeekOrigin.Begin); +using (var sr = new StreamReader(context.Request.Body)) +{ + stringifiedBody = await sr.ReadToEndAsync().ConfigureAwait(false); +} +string xHubSignature256Result = FacebookWebhookHelper.CalculateSignature(_config.GetValue