File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
lib/deploy/events/apiGateway Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ module.exports = {
151
151
let identityValidationExpression ;
152
152
let claims ;
153
153
let authorizerId ;
154
+ let scopes ;
154
155
155
156
if ( typeof authorizer === 'string' ) {
156
157
if ( authorizer . toUpperCase ( ) === 'AWS_IAM' ) {
@@ -186,6 +187,10 @@ module.exports = {
186
187
type = authorizer . type ;
187
188
}
188
189
190
+ if ( Array . isArray ( authorizer . scopes ) ) {
191
+ scopes = authorizer . scopes ;
192
+ }
193
+
189
194
resultTtlInSeconds = Number . parseInt ( authorizer . resultTtlInSeconds , 10 ) ;
190
195
resultTtlInSeconds = Number . isNaN ( resultTtlInSeconds ) ? 300 : resultTtlInSeconds ;
191
196
claims = authorizer . claims || [ ] ;
@@ -226,6 +231,7 @@ module.exports = {
226
231
identitySource,
227
232
identityValidationExpression,
228
233
claims,
234
+ scopes,
229
235
} ;
230
236
} ,
231
237
Original file line number Diff line number Diff line change @@ -450,6 +450,38 @@ describe('#httpValidate()', () => {
450
450
expect ( authorizer . identityValidationExpression ) . to . equal ( 'foo' ) ;
451
451
} ) ;
452
452
453
+ it ( 'should accept authorizer config with scopes' , ( ) => {
454
+ serverlessStepFunctions . serverless . service . functions = {
455
+ foo : { } ,
456
+ } ;
457
+
458
+ serverlessStepFunctions . serverless . service . stepFunctions = {
459
+ stateMachines : {
460
+ first : {
461
+ events : [
462
+ {
463
+ http : {
464
+ method : 'GET' ,
465
+ path : 'foo/bar' ,
466
+ integration : 'MOCK' ,
467
+ authorizer : {
468
+ name : 'authorizer' ,
469
+ arn : 'arn:aws:cognito-idp:eu-west-1:xxxxxxxxxx' ,
470
+ identitySouce : 'method.request.header.Authorization' ,
471
+ scopes : [ 'scope1' , 'scope2' ] ,
472
+ } ,
473
+ } ,
474
+ } ,
475
+ ] ,
476
+ } ,
477
+ } ,
478
+ } ;
479
+
480
+ const validated = serverlessStepFunctions . httpValidate ( ) ;
481
+ const authorizer = validated . events [ 0 ] . http . authorizer ;
482
+ expect ( authorizer . scopes ) . to . deep . equal ( [ 'scope1' , 'scope2' ] ) ;
483
+ } ) ;
484
+
453
485
it ( 'should accept authorizer config with a type' , ( ) => {
454
486
serverlessStepFunctions . serverless . service . functions = {
455
487
foo : { } ,
@@ -509,7 +541,6 @@ describe('#httpValidate()', () => {
509
541
expect ( validated . events [ 0 ] . http . authorizer . authorizerId ) . to . equal ( '12345' ) ;
510
542
} ) ;
511
543
512
-
513
544
it ( 'should accept authorizer config with a lambda arn' , ( ) => {
514
545
serverlessStepFunctions . serverless . service . stepFunctions = {
515
546
stateMachines : {
You can’t perform that action at this time.
0 commit comments