Skip to content

Commit

Permalink
Merge pull request #1633 from Mashape/fix/oauth2-error-message
Browse files Browse the repository at this point in the history
fix(oauth2) removing Kong from error message
  • Loading branch information
thibaultcha authored Sep 14, 2016
2 parents e4f0fae + 3ed9468 commit 33c2483
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions kong/plugins/oauth2/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ local function authorize(conf)
response_params = {[ERROR] = "access_denied", error_description = err or "You must use HTTPS"}
else
if conf.provision_key ~= parameters.provision_key then
response_params = {[ERROR] = "invalid_provision_key", error_description = "Invalid Kong provision_key"}
response_params = {[ERROR] = "invalid_provision_key", error_description = "Invalid provision_key"}
elseif not parameters.authenticated_userid or utils.strip(parameters.authenticated_userid) == "" then
response_params = {[ERROR] = "invalid_authenticated_userid", error_description = "Missing authenticated_userid parameter"}
else
Expand Down Expand Up @@ -306,7 +306,7 @@ local function issue_token(conf)
elseif grant_type == GRANT_CLIENT_CREDENTIALS then
-- Only check the provision_key if the authenticated_userid is being set
if parameters.authenticated_userid and conf.provision_key ~= parameters.provision_key then
response_params = {[ERROR] = "invalid_provision_key", error_description = "Invalid Kong provision_key"}
response_params = {[ERROR] = "invalid_provision_key", error_description = "Invalid provision_key"}
else
-- Check scopes
local ok, scopes = retrieve_scopes(parameters, conf)
Expand All @@ -319,7 +319,7 @@ local function issue_token(conf)
elseif grant_type == GRANT_PASSWORD then
-- Check that it comes from the right client
if conf.provision_key ~= parameters.provision_key then
response_params = {[ERROR] = "invalid_provision_key", error_description = "Invalid Kong provision_key"}
response_params = {[ERROR] = "invalid_provision_key", error_description = "Invalid provision_key"}
elseif not parameters.authenticated_userid or utils.strip(parameters.authenticated_userid) == "" then
response_params = {[ERROR] = "invalid_authenticated_userid", error_description = "Missing authenticated_userid parameter"}
else
Expand Down
12 changes: 6 additions & 6 deletions spec/03-plugins/99-oauth2/03-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe("#ci Plugin: oauth2 (access)", function()
}
})
local body = assert.res_status(400, res)
assert.equal([[{"error_description":"Invalid Kong provision_key","error":"invalid_provision_key"}]], body)
assert.equal([[{"error_description":"Invalid provision_key","error":"invalid_provision_key"}]], body)
assert.are.equal("no-store", res.headers["cache-control"])
assert.are.equal("no-cache", res.headers["pragma"])
end)
Expand Down Expand Up @@ -474,7 +474,7 @@ describe("#ci Plugin: oauth2 (access)", function()
}
})
local body = assert.res_status(400, res)
assert.equal([[{"error_description":"Invalid Kong provision_key","error":"invalid_provision_key"}]], body)
assert.equal([[{"error_description":"Invalid provision_key","error":"invalid_provision_key"}]], body)
end)
it("returns success with a path", function()
local res = assert(proxy_ssl_client:send {
Expand Down Expand Up @@ -816,7 +816,7 @@ describe("#ci Plugin: oauth2 (access)", function()
}
})
local body = assert.res_status(400, res)
assert.equal([[{"error_description":"Invalid Kong provision_key","error":"invalid_provision_key"}]], body)
assert.equal([[{"error_description":"Invalid provision_key","error":"invalid_provision_key"}]], body)
end)
it("fails when setting authenticated_userid and invalid provision_key", function()
local res = assert(proxy_ssl_client:send {
Expand All @@ -836,7 +836,7 @@ describe("#ci Plugin: oauth2 (access)", function()
}
})
local body = assert.res_status(400, res)
assert.equal([[{"error_description":"Invalid Kong provision_key","error":"invalid_provision_key"}]], body)
assert.equal([[{"error_description":"Invalid provision_key","error":"invalid_provision_key"}]], body)
end)
it("returns success", function()
local res = assert(proxy_ssl_client:send {
Expand Down Expand Up @@ -1097,7 +1097,7 @@ describe("#ci Plugin: oauth2 (access)", function()
}
})
local body = assert.res_status(400, res)
assert.equal([[{"error_description":"Invalid Kong provision_key","error":"invalid_provision_key"}]], body)
assert.equal([[{"error_description":"Invalid provision_key","error":"invalid_provision_key"}]], body)
end)
it("fails when no provision key is being sent", function()
local res = assert(proxy_ssl_client:send {
Expand All @@ -1115,7 +1115,7 @@ describe("#ci Plugin: oauth2 (access)", function()
}
})
local body = assert.res_status(400, res)
assert.equal([[{"error_description":"Invalid Kong provision_key","error":"invalid_provision_key"}]], body)
assert.equal([[{"error_description":"Invalid provision_key","error":"invalid_provision_key"}]], body)
end)
it("fails when no authenticated user id is being sent", function()
local res = assert(proxy_ssl_client:send {
Expand Down

0 comments on commit 33c2483

Please sign in to comment.