Skip to content

Commit d1f615b

Browse files
committed
fix: pass authorization properties to s3 method
1 parent ddb11e9 commit d1f615b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/package/s3/compileMethodsToS3.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ module.exports = {
1414
Properties: {
1515
HttpMethod: event.http.method.toUpperCase(),
1616
RequestParameters: {},
17-
AuthorizationType: 'NONE',
17+
AuthorizationType: event.http.auth.authorizationType,
18+
AuthorizationScopes: event.http.auth.authorizationScopes,
19+
AuthorizerId: event.http.auth.authorizerId,
1820
ApiKeyRequired: Boolean(event.http.private),
1921
ResourceId: resourceId,
2022
RestApiId: this.provider.getApiGatewayRestApiId()

lib/package/s3/compileMethodsToS3.test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const template = {
1212
Properties: {
1313
RequestParameters: {},
1414
AuthorizationType: 'NONE',
15+
AuthorizationScopes: undefined,
16+
AuthorizerId: undefined,
1517
ApiKeyRequired: false,
1618
ResourceId: { Ref: 'ApiGatewayResourceS3' },
1719
RestApiId: { Ref: 'ApiGatewayRestApi' },
@@ -146,7 +148,8 @@ describe('#compileMethodsToS3()', () => {
146148
Ref: 'MyBucket'
147149
},
148150
action: 'GetObject',
149-
key
151+
key,
152+
auth: { authorizationType: 'NONE' }
150153
}
151154

152155
const requestParams = {}
@@ -210,7 +213,8 @@ describe('#compileMethodsToS3()', () => {
210213
Ref: 'MyBucket'
211214
},
212215
action: 'PutObject',
213-
key
216+
key,
217+
auth: { authorizationType: 'NONE' }
214218
}
215219

216220
const requestParams = {
@@ -278,7 +282,8 @@ describe('#compileMethodsToS3()', () => {
278282
Ref: 'MyBucket'
279283
},
280284
action: 'DeleteObject',
281-
key
285+
key,
286+
auth: { authorizationType: 'NONE' }
282287
}
283288

284289
const requestParams = {}
@@ -362,7 +367,8 @@ describe('#compileMethodsToS3()', () => {
362367
'X-Amz-User-Agent'
363368
],
364369
allowCredentials: false
365-
}
370+
},
371+
auth: { authorizationType: 'NONE' }
366372
}
367373
}
368374
]
@@ -386,6 +392,8 @@ describe('#compileMethodsToS3()', () => {
386392
'method.request.path.key': true
387393
},
388394
AuthorizationType: 'NONE',
395+
AuthorizationScopes: undefined,
396+
AuthorizerId: undefined,
389397
ApiKeyRequired: false,
390398
ResourceId: { Ref: 'ApiGatewayResourceS3' },
391399
RestApiId: { Ref: 'ApiGatewayRestApi' },

0 commit comments

Comments
 (0)