Skip to content

Commit

Permalink
fix basicauth not being executed by default
Browse files Browse the repository at this point in the history
- Fix wrong check in schema validation for sub-values with `default`
- Fix access.lua not throwing an error in case of missing configuration (
  which is mandatory for this plugin)
  • Loading branch information
thibaultcha committed Jun 25, 2015
1 parent c573db8 commit 6d732cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kong/dao/schemas_validation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function _M.validate_fields(t, schema, options)
-- Check for sub-schema defaults and required properties in advance
for sub_field_k, sub_field in pairs(sub_schema.fields) do
if t[column] == nil then
if sub_field.default then -- Sub-value has a default, be polite and pre-assign the sub-value
if sub_field.default ~= nil then -- Sub-value has a default, be polite and pre-assign the sub-value
t[column] = {}
elseif sub_field.required then -- Only check required if field doesn't have a default
errors = utils.add_error(errors, column, column.."."..sub_field_k.." is required")
Expand Down
7 changes: 5 additions & 2 deletions kong/plugins/basicauth/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ local function validate_credentials(credential, username, password)
end

function _M.execute(conf)
if not conf or skip_authentication(ngx.req.get_headers()) then return end
if not conf then return end
if skip_authentication(ngx.req.get_headers()) then return end
if not conf then
-- Print the error in logs and signal this is a server error to the client
return responses.send_HTTP_INTERNAL_SERVER_ERROR("[basicauth] missing configuration")
end

local username, password = retrieve_credentials(ngx.req, conf)
local credential
Expand Down

0 comments on commit 6d732cd

Please sign in to comment.