Skip to content

feat: add AK/SK(HMAC) auth plugin.#2192

Merged
moonming merged 29 commits into
apache:masterfrom
nic-chen:hmac-auth
Sep 16, 2020
Merged

feat: add AK/SK(HMAC) auth plugin.#2192
moonming merged 29 commits into
apache:masterfrom
nic-chen:hmac-auth

Conversation

@nic-chen

@nic-chen nic-chen commented Sep 9, 2020

Copy link
Copy Markdown
Member

What this PR does / why we need it:

add AK/SK auth plugin

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible?

@nic-chen
nic-chen marked this pull request as ready for review September 10, 2020 01:59
@nic-chen nic-chen changed the title [WIP] feat: add AK/SK auth plugin feat: add AK/SK auth plugin Sep 10, 2020
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread doc/zh-cn/plugins/hmac-auth.md Outdated
Comment thread t/APISIX.pm
Comment thread t/APISIX.pm Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread t/plugin/custom_hmac_auth.t
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua
Comment thread t/plugin/hmac-auth.t
Comment thread t/plugin/hmac-auth.t
Comment thread t/plugin/hmac-auth.t
Comment thread t/plugin/hmac-auth.t
Comment thread t/plugin/hmac-auth.t Outdated
Comment thread apisix/plugins/hmac-auth.lua
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread doc/zh-cn/plugins/hmac-auth.md Outdated

### 签名生成公式

签名的计算公式为 `signature = HMAC-SHAx-HEX(secret_key, signning_string)`,从公式可以看出,想要获得签名需要得到 `secret_key` 和 `signning_string` 两个参数。其中 `secret_key` 为对应 consumer 所配置的, `signning_string` 的计算公式为: `signning_string = HTTP Method + HTTP URI + canonical_query_string + HTTP BODY + access_key + timestamp + secret_key`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions:

  1. I think the HTTP body is optional.
  2. For the signning_string, we should add a space when we concat different values, eg: HTTP METHOD + " " + HTTP URI, it is more easier for understanding.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding HTTP body is safer, that a signature just can put or post a same body.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the HTTP body is optional.

this way is better, the request body maybe large.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another way to do both, that is, we can put the body hash in request header which could be put in the signning_string. what do you think ? @membphis

Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread apisix/plugins/hmac-auth.lua
Comment thread apisix/plugins/hmac-auth.lua Outdated
Comment thread apisix/plugins/hmac-auth.lua
Comment thread apisix/plugins/hmac-auth.lua
Comment thread apisix/plugins/hmac-auth.lua
Comment thread doc/plugins/hmac-auth.md Outdated
Comment thread doc/zh-cn/plugins/hmac-auth.md Outdated
Comment thread doc/zh-cn/plugins/hmac-auth.md Outdated
Comment thread t/plugin/hmac-auth.t Outdated
Comment thread t/plugin/hmac-auth.t Outdated
@moonming moonming changed the title feat: add AK/SK auth plugin feat: add AK/SK(HMAC) auth plugin. Sep 16, 2020
@moonming
moonming merged commit 84ce7ba into apache:master Sep 16, 2020
@moonming moonming added this to the 2.0 milestone Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants