Skip to content

Commit

Permalink
fixed internal error with invalid hmac-auth authorization header
Browse files Browse the repository at this point in the history
fixes Kong#2951
  • Loading branch information
mvanholsteijn committed Oct 30, 2017
1 parent 166f880 commit 57d5184
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kong/plugins/hmac-auth/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ local function validate_params(params, conf)
-- check enforced headers are present
if conf.enforce_headers and #conf.enforce_headers >= 1 then
local enforced_header_set = list_as_set(conf.enforce_headers)
for _, header in ipairs(params.hmac_headers) do
enforced_header_set[header] = nil
if params.hmac_headers then
for _, header in ipairs(params.hmac_headers) do
enforced_header_set[header] = nil
end
end
for _, header in ipairs(conf.enforce_headers) do
if enforced_header_set[header] then
Expand Down
15 changes: 15 additions & 0 deletions spec/03-plugins/20-hmac-auth/03-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,21 @@ describe("Plugin: hmac-auth (access)", function()
assert.res_status(403, res)
end)

it("should return a 403 with an invalid authorization header", function()
local date = os.date("!%a, %d %b %Y %H:%M:%S GMT")
local res = assert(client:send {
method = "GET",
path = "/request",
body = {},
headers = {
["HOST"] = "hmacauth6.com",
date = date,
["proxy-authorization"] = "this is no hmac token at all is it?",
},
})
assert.res_status(403, res)
end)

it("should pass with hmac-sha1", function()
local date = os.date("!%a, %d %b %Y %H:%M:%S GMT")
local encodedSignature = ngx.encode_base64(
Expand Down

0 comments on commit 57d5184

Please sign in to comment.