Skip to content

Commit

Permalink
feat(webhooks): add override for verify that takes string
Browse files Browse the repository at this point in the history
  • Loading branch information
feinoujc committed Feb 29, 2024
1 parent 25c6010 commit 6ab1553
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Mandrill.net/Model/WebHook/WebHookSignatureHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ namespace Mandrill.Model
{
public static class WebHookSignatureHelper
{
public static bool VerifyWebHookSignature(string signature, string key, Uri absoluteUri, NameValueCollection formPost)
public static bool VerifyWebHookSignature(string signature, string key, string absoluteUri, NameValueCollection formPost)
{
if (signature == null) throw new ArgumentNullException(nameof(signature));
if (key == null) throw new ArgumentNullException(nameof(key));
if (absoluteUri == null) throw new ArgumentNullException(nameof(absoluteUri));
if (formPost == null) throw new ArgumentNullException(nameof(formPost));
if (!absoluteUri.IsAbsoluteUri) throw new ArgumentException("uri must be an absolute uri", nameof(absoluteUri));

var toSign = new StringBuilder();
toSign.Append(absoluteUri);
Expand All @@ -32,5 +31,12 @@ public static bool VerifyWebHookSignature(string signature, string key, Uri abso
return signature == hash;
}
}
public static bool VerifyWebHookSignature(string signature, string key, Uri absoluteUri, NameValueCollection formPost)
{
if (absoluteUri == null) throw new ArgumentNullException(nameof(absoluteUri));
if (!absoluteUri.IsAbsoluteUri) throw new ArgumentException("uri must be an absolute uri", nameof(absoluteUri));

return VerifyWebHookSignature(signature, key, absoluteUri.ToString(), formPost);
}
}
}

0 comments on commit 6ab1553

Please sign in to comment.