You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API Endpoints often require authorization permissions, e.g. only IAM users. Ideally, AWS::Serverless::Api would also support AuthorizationType available for API Gateway.
For example, using IAM user:
Events:
Type: Api
Properties:
Path: /secrets
Method: get
AuthorizationType: AWS_IAM
Or a custom authorizer:
Events:
Type: Api
Properties:
Path: /secrets
Method: get
AuthorizationType: CUSTOM
Authorizer: <ARN_CUSTOM_AUTHORIZER>
Realize this may be challenging in referencing the custom authorizer function if not a function defined within the template though.
Reacted by Gert Jansen van Rensburg, Eran Medan, Samir, Kaylee Cummings, Tom Garretty, Jeremy Olexa, andrewejones88, Carlos Sanchiz, Guy Wald, RJW and 47 more
If I'm understanding you correctly, have you tried defining what you're trying to get in the console and exporting the swagger file? I've found that my SAM templates support Cognito Authorization definitions by exporting an existing API built in the console and just using it as a starting point.
Agreed, it is possible to make this work with a Swagger file, but that feels like an unnecessary step (export Swagger, modify, upload + manage separately) for something reasonably simple to configure as part of the API definition.
Reacted by Pragathi Sharma, Samuel Wan, Austin Nevins, Taras Romanyk and Zeust the Unoobian
Thanks for the request. This is a good feature to have.
Reacted by Guy Wald, Joe Lafiosca, Stefan Dimitrov, Steven Pardo, Andrew O'Hara, David Sheffield, Shaun Egan, mouscous, Daniel Cornelison, Martijn van de Grift and 7 more
does not seem to work for me in an inline swagger file and fails with the following error: Status: FAILED. Reason: Template error: instance of Fn::Sub references invalid resource attribute stageVariables.MyVariableName.
Could someone confirm that this should work? Or maybe there is another way to access these variables with an inline swagger spec?
Whew, I spent most of the day trying to understand the workarounds and just checked this issue a few minutes ago! :-) Does #248 mean it will be straightforward to declare a AWS::ApiGateway::Authorizer resource with Type: "Cognito_user_pool"?
@sanathkr Still don't understand what I should use for adding Authorizer to my Api Event. Where I can found any documentation about it?
What the syntax?
Reacted by Taras Romanyk, Alec Hewitt, red8888 and ajhool
I struggle to understand if Cognito is considered as a custom authorizer or not ?
And so I do understand that SAM don't support Authorizer in the Serverless::Function right? Is there any workaround without writing swagger?
Thanks a lot in advance!
Reacted by Guillaume Van der Schueren, Glenn, Marijn Hurkens and red8888
If you're interested in Authorizers and want to help shape the syntax, the RFC is over here #512. I'm going to extend the RFC closure date until end of this week.
Activity
collinforrester commentedon Dec 29, 2016
If I'm understanding you correctly, have you tried defining what you're trying to get in the console and exporting the swagger file? I've found that my SAM templates support Cognito Authorization definitions by exporting an existing API built in the console and just using it as a starting point.
jkahn117 commentedon Dec 29, 2016
Agreed, it is possible to make this work with a Swagger file, but that feels like an unnecessary step (export Swagger, modify, upload + manage separately) for something reasonably simple to configure as part of the API definition.
sanathkr commentedon Jan 3, 2017
Thanks for the request. This is a good feature to have.
mparaz commentedon Feb 1, 2017
It looks like using Swagger stopped working. This was previously working:
But now I get:
What is the correct syntax now?
demurray commentedon May 9, 2017
@mparaz, try nesting the authorizerUri value under a Fn::Sub element, i.e.:
lafiosca commentedon May 18, 2017
I don't think the Fn::Sub will help here. That looks to be an API Gateway stage variable rather than a CloudFormation variable.
jaccus commentedon Jun 9, 2017
Fn::Subtogether with${stageVariables.MyVariableName}, where the variable is in the Variables section of the SAM template,does not seem to work for me in an inline swagger file and fails with the following error:
Status: FAILED. Reason: Template error: instance of Fn::Sub references invalid resource attribute stageVariables.MyVariableName.Could someone confirm that this should work? Or maybe there is another way to access these variables with an inline swagger spec?
sanathkr commentedon Jan 10, 2018
Its happening! #248
samwan commentedon Jan 11, 2018
Whew, I spent most of the day trying to understand the workarounds and just checked this issue a few minutes ago! :-) Does #248 mean it will be straightforward to declare a AWS::ApiGateway::Authorizer resource with Type: "Cognito_user_pool"?
johnbest commentedon Jan 16, 2018
New to AWS, and I am incredibly interested in the CORS/Authorizer thing.
(As I want to build a web stack using Cognito).
WilixLead commentedon Feb 14, 2018
@sanathkr Still don't understand what I should use for adding Authorizer to my Api Event. Where I can found any documentation about it?
What the syntax?
sanathkr commentedon Mar 8, 2018
@WilixLead Authorizer is not yet supported natively in SAM. #248 is parent tracking issue for all APIGW features.
You can always enable custom authorizers by explicitly defining APIs using Swagger file and including the Swagger with
AWS::Serverless::Apiresource - https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authorizer.html. Checkoug #25 for more discussion on how this could be implemented in Swagger.marczis commentedon Mar 20, 2018
I got really confused with this.
So I can create an Authorizer like this:
I struggle to understand if Cognito is considered as a custom authorizer or not ?
And so I do understand that SAM don't support Authorizer in the Serverless::Function right? Is there any workaround without writing swagger?
Thanks a lot in advance!
brettstack commentedon Jul 31, 2018
If you're interested in Authorizers and want to help shape the syntax, the RFC is over here #512. I'm going to extend the RFC closure date until end of this week.
@jkahn117 @collinforrester @mparaz @demurray @WilixLead @marczis @johnbest @jaccus @lafiosca
sparrowt commentedon Oct 31, 2018
See #546 for recently added support