strapi-plugin-website-builder icon indicating copy to clipboard operation
strapi-plugin-website-builder copied to clipboard

Support Signature in header

Open YassineElbouchaibi opened this issue 2 years ago • 1 comments

Either we add something like this in config:

config: {
  ...
  secret: {
    headerKey: "X-Hub-Signature",
    hash: "sha1",
    secret: "SomeSecret", 
  },
  ...
}

and add something like this

function createHmacSignature(req, hash, secretKey) {
  return require("crypto")
    .createHmac(hash, secretKey)
    .update(JSON.stringify(req.body))
    .digest("hex");
}

or have headers object accept functions

config: {
  ...
  headers: {
    "X-Hub-Signature": (req) => "someValue",
  },
  ...
}

I will try something

YassineElbouchaibi avatar Feb 27 '22 19:02 YassineElbouchaibi

Hello @YassineElbouchaibi,

I am okay with the first method. Thank you very much for the PR!

I have left some comments regarding some required changes, let me know if any further clarification is needed.

ComfortablyCoding avatar Feb 27 '22 22:02 ComfortablyCoding