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

fix(*): fix AWS_CONTAINER_CREDENTIALS_FULL_URI parsing #65

Merged
merged 2 commits into from
Jul 31, 2023
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ Release process:
1. upload using: `VERSION=x.y.z APIKEY=abc... make upload`
1. test installing the rock from LuaRocks

### Unreleased

- fix: fix AWS_CONTAINER_CREDENTIALS_FULL_URI parsing.
[#65](https://github.com/Kong/lua-resty-aws/pull/65)

### 1.2.3 (20-Jul-2023)

- fix: fix assumeRole function name on STS.
Expand Down
26 changes: 25 additions & 1 deletion spec/03-credentials/04-RemoteCredentials_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe("RemoteCredentials", function()
end)



it("fetches credentials", function()
local cred = RemoteCredentials:new()
local success, key, secret, token = cred:get()
Expand All @@ -61,3 +60,28 @@ describe("RemoteCredentials", function()
end)

end)


describe("RemoteCredentials with customized full URI", function ()
it("fetches credentials", function ()
local RemoteCredentials

restore()
restore.setenv("AWS_CONTAINER_CREDENTIALS_FULL_URI", "http://localhost:12345/test/path")

local _ = require("resty.aws.config").global -- load config before mocking http client
package.loaded["resty.luasocket.http"] = http

RemoteCredentials = require "resty.aws.credentials.RemoteCredentials"
finally(function()
restore()
end)

local cred = RemoteCredentials:new()
local success, key, secret, token = cred:get()
assert.equal(true, success)
assert.equal("access", key)
assert.equal("secret", secret)
assert.equal("token", token)
end)
end)
2 changes: 1 addition & 1 deletion src/resty/aws/credentials/RemoteCredentials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local FullUri do
end

if (not FULL_URI_UNRESTRICTED_PROTOCOLS[parsed_url.scheme]) and
(not FULL_URI_ALLOWED_HOSTNAMES[parsed_url.hostname]) then
(not FULL_URI_ALLOWED_HOSTNAMES[parsed_url.host]) then
return nil, 'Unsupported hostname: AWS.RemoteCredentials only supports '
.. table.concat(FULL_URI_ALLOWED_HOSTNAMES, ',') .. ' for '
.. parsed_url.scheme .. '; ' .. parsed_url.scheme .. '://'
Expand Down