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 = {
151151 let identityValidationExpression ;
152152 let claims ;
153153 let authorizerId ;
154+ let scopes ;
154155
155156 if ( typeof authorizer === 'string' ) {
156157 if ( authorizer . toUpperCase ( ) === 'AWS_IAM' ) {
@@ -186,6 +187,10 @@ module.exports = {
186187 type = authorizer . type ;
187188 }
188189
190+ if ( Array . isArray ( authorizer . scopes ) ) {
191+ scopes = authorizer . scopes ;
192+ }
193+
189194 resultTtlInSeconds = Number . parseInt ( authorizer . resultTtlInSeconds , 10 ) ;
190195 resultTtlInSeconds = Number . isNaN ( resultTtlInSeconds ) ? 300 : resultTtlInSeconds ;
191196 claims = authorizer . claims || [ ] ;
@@ -226,6 +231,7 @@ module.exports = {
226231 identitySource,
227232 identityValidationExpression,
228233 claims,
234+ scopes,
229235 } ;
230236 } ,
231237
Original file line number Diff line number Diff line change @@ -450,6 +450,38 @@ describe('#httpValidate()', () => {
450450 expect ( authorizer . identityValidationExpression ) . to . equal ( 'foo' ) ;
451451 } ) ;
452452
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+
453485 it ( 'should accept authorizer config with a type' , ( ) => {
454486 serverlessStepFunctions . serverless . service . functions = {
455487 foo : { } ,
@@ -509,7 +541,6 @@ describe('#httpValidate()', () => {
509541 expect ( validated . events [ 0 ] . http . authorizer . authorizerId ) . to . equal ( '12345' ) ;
510542 } ) ;
511543
512-
513544 it ( 'should accept authorizer config with a lambda arn' , ( ) => {
514545 serverlessStepFunctions . serverless . service . stepFunctions = {
515546 stateMachines : {
You can’t perform that action at this time.
0 commit comments