Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 29 commits into from
Sep 16, 2020
Merged

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

merged 29 commits into from
Sep 16, 2020

Conversation

nic-chen
Copy link
Member

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

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
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved
doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved
doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved
doc/zh-cn/plugins/hmac-auth.md Outdated Show resolved Hide resolved
t/APISIX.pm Show resolved Hide resolved
t/APISIX.pm Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved
t/plugin/custom_hmac_auth.t Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Show resolved Hide resolved
t/plugin/hmac-auth.t Show resolved Hide resolved
t/plugin/hmac-auth.t Show resolved Hide resolved
t/plugin/hmac-auth.t Show resolved Hide resolved
t/plugin/hmac-auth.t Show resolved Hide resolved
t/plugin/hmac-auth.t Outdated Show resolved Hide resolved
doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved
doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved

### 签名生成公式

签名的计算公式为 `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
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
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
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
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

doc/plugins/hmac-auth.md Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
apisix/plugins/hmac-auth.lua Outdated Show resolved Hide resolved
t/plugin/hmac-auth.t Outdated Show resolved Hide resolved
t/plugin/hmac-auth.t Outdated Show resolved Hide resolved
@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