Skip to content

Commit 1b8d73c

Browse files
authored
fix(apigateway): allow overriding authorizer on methods (#30415)
### Issue # (if applicable) Closes #8827. ### Reason for this change Customers could not override the authorizer defined in the default method configuration if they want to set the authorization type to None. ### Description of changes If the customer set the authorization type to None while creating a new method, we will not use the authorizer value defined in the default configuration and instead we will set it to undefined. ### Description of how you validated changes added unit, and integration test cases. ### Checklist - [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 09098af commit 1b8d73c

11 files changed

+1125
-3
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.api-with-overriding-default-authorizer.js.snapshot/apigatewaywithoverridingdefaultauthorizerDefaultTestDeployAssert5491B2D1.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.api-with-overriding-default-authorizer.js.snapshot/apigatewaywithoverridingdefaultauthorizerDefaultTestDeployAssert5491B2D1.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.api-with-overriding-default-authorizer.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.api-with-overriding-default-authorizer.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/authorizers/integ.api-with-overriding-default-authorizer.js.snapshot/integtest-restapi-with-overriding-default-authorizer.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
{
2+
"Resources": {
3+
"UserPool6BA7E5F2": {
4+
"Type": "AWS::Cognito::UserPool",
5+
"Properties": {
6+
"AccountRecoverySetting": {
7+
"RecoveryMechanisms": [
8+
{
9+
"Name": "verified_phone_number",
10+
"Priority": 1
11+
},
12+
{
13+
"Name": "verified_email",
14+
"Priority": 2
15+
}
16+
]
17+
},
18+
"AdminCreateUserConfig": {
19+
"AllowAdminCreateUserOnly": false
20+
},
21+
"AutoVerifiedAttributes": [
22+
"email"
23+
],
24+
"EmailVerificationMessage": "The verification code to your new account is {####}",
25+
"EmailVerificationSubject": "Verify your new account",
26+
"SmsVerificationMessage": "The verification code to your new account is {####}",
27+
"UsernameAttributes": [
28+
"email"
29+
],
30+
"VerificationMessageTemplate": {
31+
"DefaultEmailOption": "CONFIRM_WITH_CODE",
32+
"EmailMessage": "The verification code to your new account is {####}",
33+
"EmailSubject": "Verify your new account",
34+
"SmsMessage": "The verification code to your new account is {####}"
35+
}
36+
},
37+
"UpdateReplacePolicy": "Retain",
38+
"DeletionPolicy": "Retain"
39+
},
40+
"AuthorizerBD825682": {
41+
"Type": "AWS::ApiGateway::Authorizer",
42+
"Properties": {
43+
"IdentitySource": "method.request.header.Authorization",
44+
"Name": "integtestrestapiwithoverridingdefaultauthorizerAuthorizerF0743170",
45+
"ProviderARNs": [
46+
{
47+
"Fn::GetAtt": [
48+
"UserPool6BA7E5F2",
49+
"Arn"
50+
]
51+
}
52+
],
53+
"RestApiId": {
54+
"Ref": "ActionsApiGatewayF80386B7"
55+
},
56+
"Type": "COGNITO_USER_POOLS"
57+
}
58+
},
59+
"ActionsApiGatewayF80386B7": {
60+
"Type": "AWS::ApiGateway::RestApi",
61+
"Properties": {
62+
"Name": "Actions-ApiGateway"
63+
}
64+
},
65+
"ActionsApiGatewayDeployment50B6E6A66403e42852ae63ad13a2b7635300f8a9": {
66+
"Type": "AWS::ApiGateway::Deployment",
67+
"Properties": {
68+
"Description": "Automatically created by the RestApi construct",
69+
"RestApiId": {
70+
"Ref": "ActionsApiGatewayF80386B7"
71+
}
72+
},
73+
"DependsOn": [
74+
"ActionsApiGatewayANY11FE5E47",
75+
"ActionsApiGatewayGET12E87C75",
76+
"ActionsApiGatewayOPTIONS8EA1F997",
77+
"AuthorizerBD825682"
78+
]
79+
},
80+
"ActionsApiGatewayDeploymentStageprod812022BF": {
81+
"Type": "AWS::ApiGateway::Stage",
82+
"Properties": {
83+
"DeploymentId": {
84+
"Ref": "ActionsApiGatewayDeployment50B6E6A66403e42852ae63ad13a2b7635300f8a9"
85+
},
86+
"RestApiId": {
87+
"Ref": "ActionsApiGatewayF80386B7"
88+
},
89+
"StageName": "prod"
90+
}
91+
},
92+
"ActionsApiGatewayOPTIONS8EA1F997": {
93+
"Type": "AWS::ApiGateway::Method",
94+
"Properties": {
95+
"ApiKeyRequired": false,
96+
"AuthorizationType": "NONE",
97+
"HttpMethod": "OPTIONS",
98+
"Integration": {
99+
"IntegrationResponses": [
100+
{
101+
"ResponseParameters": {
102+
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'",
103+
"method.response.header.Access-Control-Allow-Origin": "'*'",
104+
"method.response.header.Access-Control-Allow-Methods": "'OPTIONS,GET,PUT,POST,DELETE,PATCH,HEAD'",
105+
"method.response.header.Access-Control-Max-Age": "'864000'"
106+
},
107+
"StatusCode": "204"
108+
}
109+
],
110+
"RequestTemplates": {
111+
"application/json": "{ statusCode: 200 }"
112+
},
113+
"Type": "MOCK"
114+
},
115+
"MethodResponses": [
116+
{
117+
"ResponseParameters": {
118+
"method.response.header.Access-Control-Allow-Headers": true,
119+
"method.response.header.Access-Control-Allow-Origin": true,
120+
"method.response.header.Access-Control-Allow-Methods": true,
121+
"method.response.header.Access-Control-Max-Age": true
122+
},
123+
"StatusCode": "204"
124+
}
125+
],
126+
"ResourceId": {
127+
"Fn::GetAtt": [
128+
"ActionsApiGatewayF80386B7",
129+
"RootResourceId"
130+
]
131+
},
132+
"RestApiId": {
133+
"Ref": "ActionsApiGatewayF80386B7"
134+
}
135+
}
136+
},
137+
"ActionsApiGatewayANY11FE5E47": {
138+
"Type": "AWS::ApiGateway::Method",
139+
"Properties": {
140+
"AuthorizationType": "NONE",
141+
"HttpMethod": "ANY",
142+
"Integration": {
143+
"IntegrationResponses": [
144+
{
145+
"StatusCode": "200"
146+
}
147+
],
148+
"PassthroughBehavior": "NEVER",
149+
"RequestTemplates": {
150+
"application/json": "{ \"statusCode\": 200 }"
151+
},
152+
"Type": "MOCK"
153+
},
154+
"MethodResponses": [
155+
{
156+
"StatusCode": "200"
157+
}
158+
],
159+
"ResourceId": {
160+
"Fn::GetAtt": [
161+
"ActionsApiGatewayF80386B7",
162+
"RootResourceId"
163+
]
164+
},
165+
"RestApiId": {
166+
"Ref": "ActionsApiGatewayF80386B7"
167+
}
168+
}
169+
},
170+
"ActionsApiGatewayGET12E87C75": {
171+
"Type": "AWS::ApiGateway::Method",
172+
"Properties": {
173+
"AuthorizationScopes": [
174+
"scope"
175+
],
176+
"AuthorizationType": "COGNITO_USER_POOLS",
177+
"AuthorizerId": {
178+
"Ref": "AuthorizerBD825682"
179+
},
180+
"HttpMethod": "GET",
181+
"Integration": {
182+
"IntegrationResponses": [
183+
{
184+
"StatusCode": "200"
185+
}
186+
],
187+
"PassthroughBehavior": "NEVER",
188+
"RequestTemplates": {
189+
"application/json": "{ \"statusCode\": 200 }"
190+
},
191+
"Type": "MOCK"
192+
},
193+
"MethodResponses": [
194+
{
195+
"StatusCode": "200"
196+
}
197+
],
198+
"ResourceId": {
199+
"Fn::GetAtt": [
200+
"ActionsApiGatewayF80386B7",
201+
"RootResourceId"
202+
]
203+
},
204+
"RestApiId": {
205+
"Ref": "ActionsApiGatewayF80386B7"
206+
}
207+
}
208+
}
209+
},
210+
"Outputs": {
211+
"ActionsApiGatewayEndpoint261B645B": {
212+
"Value": {
213+
"Fn::Join": [
214+
"",
215+
[
216+
"https://",
217+
{
218+
"Ref": "ActionsApiGatewayF80386B7"
219+
},
220+
".execute-api.",
221+
{
222+
"Ref": "AWS::Region"
223+
},
224+
".",
225+
{
226+
"Ref": "AWS::URLSuffix"
227+
},
228+
"/",
229+
{
230+
"Ref": "ActionsApiGatewayDeploymentStageprod812022BF"
231+
},
232+
"/"
233+
]
234+
]
235+
}
236+
}
237+
},
238+
"Parameters": {
239+
"BootstrapVersion": {
240+
"Type": "AWS::SSM::Parameter::Value<String>",
241+
"Default": "/cdk-bootstrap/hnb659fds/version",
242+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
243+
}
244+
},
245+
"Rules": {
246+
"CheckBootstrapVersion": {
247+
"Assertions": [
248+
{
249+
"Assert": {
250+
"Fn::Not": [
251+
{
252+
"Fn::Contains": [
253+
[
254+
"1",
255+
"2",
256+
"3",
257+
"4",
258+
"5"
259+
],
260+
{
261+
"Ref": "BootstrapVersion"
262+
}
263+
]
264+
}
265+
]
266+
},
267+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
268+
}
269+
]
270+
}
271+
}
272+
}

0 commit comments

Comments
 (0)