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

fixed internal error with invalid hmac-auth authorization header #2996

Merged
merged 1 commit into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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