Skip to content

Commit

Permalink
fix(STS) fix duplicate regions casusing bad hostnames
Browse files Browse the repository at this point in the history
fixes #45
  • Loading branch information
Tieske committed Feb 13, 2023
1 parent c47b007 commit c75ed47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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

0 comments on commit c75ed47

Please sign in to comment.