Skip to content

fix(STS) fix duplicate regions causing bad hostnames #46

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

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

### unreleased

- fix: STS regional endpoints woudl re-inject the region on every authentication
(after a token expired), causing bad hostnames to be used
[#45](https://github.com/Kong/lua-resty-aws/issues/45)

### 1.1.2 (7-Dec-2022)

- fix: auto detection scheme and default to tls [#42](https://github.com/Kong/lua-resty-aws/pull/42)
Expand Down
10 changes: 7 additions & 3 deletions src/resty/aws/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,13 @@ local function generate_service_methods(service)
-- we use regional endpoints, see
-- https://github.com/aws/aws-sdk-js/blob/307e82673b48577fce4389e4ce03f95064e8fe0d/lib/services/sts.js#L78-L82
assert(service.config.region, "region is required when using STS regional endpoints")
local pre, post = service.config.endpoint:match("^(.+)(%.amazonaws%.com)$")
service.config.endpoint = pre .. "." .. service.config.region .. post
service.config.signingRegion = service.config.region

if not service.config._regionalEndpointInjected then
local pre, post = service.config.endpoint:match("^(.+)(%.amazonaws%.com)$")
service.config.endpoint = pre .. "." .. service.config.region .. post
service.config.signingRegion = service.config.region
service.config._regionalEndpointInjected = true
end
end

local old_sig
Expand Down