Skip to content

Commit d9fbf0f

Browse files
committed
new config parameter
1 parent 3f5a65c commit d9fbf0f

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

Readme.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ Note that this plugin cannot be used in combination with Kong [upstreams](https:
1717
## Plugin configuration parameters
1818

1919
```lua
20-
aws_assume_role_arn -- ARN of the IAM role that the plugin will try to assume
20+
aws_assume_role_arn -- ARN of the IAM role that the plugin will try to assume, cannot be supplied together with `aws_account_id`. At least one must be specified.
2121
type = "string"
22-
required = true
22+
required = false
23+
24+
aws_account_id -- ID of the AWS account the lambda is deployed to. Used to generate the ARN of the IAM role to be assumed. Cannot be specified together with `aws_assume_role_arn`. At least one must be specified.
25+
type = "number"
26+
required = false
2327

2428
aws_assume_role_name -- Name of the role above.
2529
type = "string"

kong/plugins/aws-request-signing/handler.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function AWSLambdaSTS:access(conf)
112112
local auth_header_key = conf.auth_header or "authorization"
113113
local auth_header_value = request_headers[auth_header_key]
114114
if not auth_header_value then
115-
kong.log.notice("header value missing for: '".. auth_header_key .. "', skipping signing")
115+
kong.log.notice("header value missing for: '" .. auth_header_key .. "', skipping signing")
116116
return
117117
end
118118

@@ -164,7 +164,8 @@ function AWSLambdaSTS:access(conf)
164164

165165

166166
local sts_conf = {
167-
RoleArn = conf.aws_assume_role_arn,
167+
RoleArn = conf.aws_assume_role_arn or
168+
('arn:aws:iam::' .. conf.aws_account_id .. ':role/' .. conf.aws_assume_role_name),
168169
WebIdentityToken = retrieve_token(auth_header_value),
169170
RoleSessionName = conf.aws_assume_role_name,
170171
}

kong/plugins/aws-request-signing/schema.lua

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ return {
1919
aws_assume_role_arn = {
2020
type = "string",
2121
encrypted = true, -- Kong Enterprise-exclusive feature, does nothing in Kong CE
22-
required = true,
22+
required = false,
23+
}
24+
},
25+
{
26+
aws_account_id = {
27+
type = "number",
28+
required = false,
2329
}
2430
},
2531
{
@@ -67,9 +73,9 @@ return {
6773
required = true,
6874
default = false,
6975
description =
70-
"Instructs the plugin to use the context target if its host or port were altered "..
71-
" (by other plugins) during the signing, bypassing the override_target_host "..
72-
"and override_target_port parameters. Works by comparing the service target parameters"..
76+
"Instructs the plugin to use the context target if its host or port were altered " ..
77+
" (by other plugins) during the signing, bypassing the override_target_host " ..
78+
"and override_target_port parameters. Works by comparing the service target parameters" ..
7379
" with the context target parameters. Ignored if the target was not altered."
7480
}
7581
},
@@ -112,5 +118,17 @@ return {
112118
}
113119
},
114120
entity_checks = {
121+
{
122+
mutually_exclusive = {
123+
"aws_account_id",
124+
"aws_assume_role_arn",
125+
},
126+
},
127+
{
128+
at_least_one_of = {
129+
"aws_account_id",
130+
"aws_assume_role_arn",
131+
},
132+
},
115133
}
116134
}

0 commit comments

Comments
 (0)