-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Feature/check mandatory headers in hmac param #2418
Feature/check mandatory headers in hmac param #2418
Conversation
…antee that the date or x-date header used in clock skew validation is not tampered. Also, according to ietf draft (https://tools.ietf.org/html/draft-cavage-http-signatures-06#section-2.3) it is madatory to include date headers in Hmac-header parameter. If validate-request-body config is enabled for an API then Hmac-header should also must contain digest header. Note: This config parameter is not present in this commit. I'll add it in a different PR as it a totally different feature. Changes committed: modified: kong/plugins/hmac-auth/access.lua added a function which will check mandatory hmac params modified: spec/03-plugins/20-hmac-auth/03-access_spec.lua 1. added date header in Hmac-header parameter 2. If date header passes skew test but this header was not used in Hmac-params then it is of no use. The header used in hmac-header should be used for skew test. Same for x-date header. 3. added a test to fail request if date header not used in hmac-header
Changes to the codebase should try to be as atomic as possible. Is it possible to re-work this PR such that it does not rely on a feature present in another branch? |
@p0pr0ck5 I can remove |
@vaibhavatul47 ok, sounds good. will you make these changes? |
@p0pr0ck5 sure, I'll update once its ready. |
@vaibhavatul47 here client has option to include |
@@ -13,21 +13,24 @@ local ngx_sha1 = ngx.hmac_sha1 | |||
local ngx_set_header = ngx.req.set_header | |||
local ngx_get_headers = ngx.req.get_headers | |||
local ngx_log = ngx.log | |||
local req_read_body = ngx.req.read_body | |||
local req_get_body_data = ngx.req.get_body_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@p0pr0ck5 @shashiranjan84 Will you make sure that this is using the recent public API draft to read the request body as well? Thanks!
@shashiranjan84 Yes client would still have the option to chose from |
@vaibhavatul47 no as per draft, it is must for client to send the "In order to generate the string that is signed with a key, the client |
@shashiranjan84 I never meant that server should send |
@vaibhavatul47 Sorry I meant, It's on client to make sure to add |
I would prefer updating doc, to inform user to make sure to include |
@shashiranjan84 I think you are right, we should not mandate
I will update my code to following:
Also, we will need to update in docs to encourage users to include |
@vaibhavatul47 I am thinking to close this PR and update your another PR #2419 to make it work independent of this PR. I will take care of the addition changes. |
As per discussion before, I am closing this. |
Summary
Making date or x-date header mandatory in Hmac-headers.
Full changelog
Mandatory header values in Hmac-headers parameter
Currently, although the plugin validates clock-skew but it is no guarantee that the date or x-date header used in clock skew validation is not tampered.
Also, according to ietf draft it is madatory to include date headers in Hmac-header parameter.
If
validate-request-body
config is enabled for an API then Hmac-header should also must contain digest header.Note:
validate-request-body
config is not present in this code. I'll add it in another PR as it is associated with another feature.Test edited