如何在 Kong API 网关中为您的 API 添加 HMAC 签名认证?

How to add HMAC Signature Authentication to your APIs in Kong API Gateway?

我正在尝试使用 日期 header 中的 HMAC 身份验证,如 https://getkong.org/plugins/hmac-authentication/

但我仍然收到错误

{
  "message": "HMAC signature cannot be verified, a valid date or x-date header is required for HMAC Authentication"
}

请提出一个让它工作的方法。

我认为日期 header 不应该使用。无论如何,我只是用 x-date header 替换它,问题就解决了。

只需授权请求即可 header。

Authorization : hmac username="<username>",algorithm="hmac-sha1",headers="X-Date",signature="Ee4Gv1at78U3f+bawoV0PucdF/Q="

X-Date: Fri, 17 Feb 2017 10:28:40 GMT

为了生成用密钥签名的字符串,客户端必须按照 headers 指定的每个 HTTP header 的值出现的顺序。这就是这里指定 X-Date header 的原因。

签名是 Base64(HMAC-SHA1(signing string))

客户端将在此处编写签名字符串为:

X-Date: Fri, 17 Feb 2017 10:28:40 GMT

您还可以使用一个或多个 header 来创建签名。不过这是最简单的了。

访问:https://getkong.org/plugins/hmac-authentication/