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
{{ message }}
Repository navigation
Feature Request: API Gateway Authorizer support in SAM Local #137
Any help pointing in the right direction is greatly appreciated!
Reacted by Emanuel Posescu, KGitAccount, Yuuki TSUBOUCHI, Keshav Varma, Hayato Tomoda, rowan, Yves M., Alan Corvalis, Maxwell O'Roark, Taras Romanyk and 168 more
If I understand the model correctly, it shouldn't matter if my custom authorizer does not run locally, right? In AWS, only authorized requests can trigger the lambda function, correct?
I'm also looking for examples of how to integrate a Cognito Authorizer with lambdas made via SAM templates.
Reacted by Danny McPherson, Eran Medan, Yves M., nibab, Maxwell O'Roark, Duncan Crawford, benswatson, Jun, Adriano Raiano, Alexander KIRILOV and 28 more
This is a good to have feature in SAM Local, so we can test the authorization functions before deploying
Reacted by Karan Talati, Eran Medan, Sergio Garcez, Scott Olson, Jason Mac, studds, Alexander KIRILOV, John McEnery, John Gabriel Colombo, Tuomas Järvensivu and 35 more
Hi is there a resolution yet for including Custom Authoriser lambda over SAM template itself or is this still a feature request AWS SAM Team is working on?
Reacted by Andrew Larsen, barbasa, nibab, Musa Siddeeq, OOTPAppsDotCom and jwaterbury26
My database url will not work as it contains '=' and other special characters, int he env variables.
How would I get around this? This is a reliant to my company
Reacted by Jason Haines, John Gabriel Colombo, Matthew Duren, Vadym Tyemirov, Rob S., Zeust the Unoobian, twbrodsky, Chris Owens, Ben, Prasanth Louis and 1 more
@alanchavez88 did you ever figure out how to configure an authorizer, I notice that the question was never answered. It went off on a tangent about Sam local.
Reacted by Chris Owens, Alan Corvalis, Marcos Paulo Amorim and Rodgers Wanyonyi
Hi, thanks for raising your concerns. While I unfortunately do not have a date for when this will be complete, implementation of custom Lambda authorizer support for sam local start-api is currently underway.
Reacted by Jerome DPG, melvincaraangJC, clotodex, Nate Mellendorf, Kristian Suhartono, omizzolo-cutowl, Willis Chou, WillisChou and rdupz
Hi all, custom Lambda authorizer support for sam local start-api has been released as of SAM CLI v1.80.0. Feel free to create new issues or discussion threads if there are any problems or features that would fit for SAM CLI.
Reacted by Jonas Pohren, Nick Lane-Smith, Nick Eldridge, Alex Berriman, Bar Miliavsky, koji-sano-sutech, WillisChou, Felipe Rodrigues, Sean Winters and Albert Rannetsperger
Reacted by rdupz, Fabiano Nascimento, Nick Eldridge, Alex Berriman, Bar Miliavsky, Natalia LaFever, WillisChou, Felipe Rodrigues and Albert Rannetsperger
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
@lucashuy nice work! Can we please get a usage tutorial on this new feature? I have tried getting this to work and am referencing a local authorizer, yet it is still "not found". Usage details would be great 👍
Reacted by Matt Armstrong, Abel McElroy, Seamus Lowry, Aaron Murray, Lewis Cowles, mariomo30, Jacob Phillips, WillisChou and David
Hi @Willis0826,
I'm currently working on a project that uses AWS Serverless HttpApi (Type: AWS::Serverless::HttpApi). I was wondering if you have any experience with integrating Lambda Authorizer in this V2 version of the API Gateway?
When running sam local start-api -n envs.json --skip-pull-image --warm-containers EAGER, if I use curl -H "Authorization: abc" http://127.0.0.1:3000/api/users or curl http://127.0.0.1:3000/api/users, it seems that the AuthorizerFunction isn't invoked (I have a console.log("Hello authorizer") inside), but the request is processed directly by ApiUsersFunction.
@CeccoCQ the AuthorizerPayloadFormatVersion field should be "2.0" (a string) instead of 2.0. If you run sam build with AuthorizerPayloadFormatVersion: 2.0, you should see an error message Error: 'AuthorizerPayloadFormatVersion' must be of type string for Lambda Authorizer 'LambdaTokenAuthorizer'..
Am thinking maybe you can create an issue in my example repository. we can figure it out there.
Activity
PaulMaddox commentedon Sep 25, 2017
Hi @alanchavez88,
Currently configuring a custom authorizer isn't supported when running locally with SAM Local.
I'll leave this issue open as a feature request for our backlog.
Thanks
azcdev commentedon Sep 25, 2017
Thanks @PaulMaddox for the response!
If I understand the model correctly, it shouldn't matter if my custom authorizer does not run locally, right? In AWS, only authorized requests can trigger the lambda function, correct?
sanathkr commentedon Sep 25, 2017
Yes, an authorization request should trigger the Lambda in AWS cloud
bradwoods commentedon Jan 5, 2018
I'm also looking for examples of how to integrate a Cognito Authorizer with lambdas made via SAM templates.
mohithg commentedon Jan 10, 2018
This is a good to have feature in SAM Local, so we can test the authorization functions before deploying
sujithsnair86 commentedon Jan 19, 2018
Hi is there a resolution yet for including Custom Authoriser lambda over SAM template itself or is this still a feature request AWS SAM Team is working on?
ThomasSmWatson commentedon Jan 25, 2018
My database url will not work as it contains '=' and other special characters, int he env variables.
How would I get around this? This is a reliant to my company
gregaeq commentedon Mar 22, 2018
Interested in this feature as well. Attempting to use sam-local to auth with Cognito before making subsequent requests.
kanchen commentedon Mar 30, 2018
Same here. Anyone knows the timeline to support SAM local custom authorizer ?
margic commentedon Apr 7, 2018
@alanchavez88 did you ever figure out how to configure an authorizer, I notice that the question was never answered. It went off on a tangent about Sam local.
azcdev commentedon Apr 7, 2018
@margic no, I never figured it out. I ended up assuming that it worked and moved on :( If you find a way to do it please post it here.
153 remaining items
lucashuy commentedon Mar 15, 2023
Hi, thanks for raising your concerns. While I unfortunately do not have a date for when this will be complete, implementation of custom Lambda authorizer support for
sam local start-apiis currently underway.alb3rtuk commentedon Apr 9, 2023
Would love to see this when it's built and ready to use. @lucashuy Please keep us updated :)
lucashuy commentedon Apr 17, 2023
Hi all, custom Lambda authorizer support for
sam local start-apihas been released as of SAM CLI v1.80.0. Feel free to create new issues or discussion threads if there are any problems or features that would fit for SAM CLI.github-actions commentedon Apr 17, 2023
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
nickls commentedon Apr 21, 2023
For anyone trying to get this working:
FunctionPayloadType: TOKENeven though that is the default value.FunctionArnas they fail a format sanity check.ChronosMasterOfAllTime commentedon May 15, 2023
@lucashuy nice work! Can we please get a usage tutorial on this new feature? I have tried getting this to work and am referencing a local authorizer, yet it is still "not found". Usage details would be great 👍
supagu commentedon Jul 25, 2023
Is there a proper example on how to do this?
ChronosMasterOfAllTime commentedon Jul 25, 2023
There isn't. I requested documentation in issue #5172
le0kar0ub1 commentedon Sep 26, 2023
Hi, for those which are struggling to make the thing works, I just found how to after some long hours.
The problems seems to be that:
FunctionNamefield in your lambda authorizer.FunctionPayloadType: TOKENin the API Auth despite the fact that it's the default value.Minimal example:
SAM CLI version 1.97.0
AWS CLI version 2.7.21
Hope this can save some hours of many !
Willis0826 commentedon Sep 26, 2023
a working TypeScript example can be found here as well.
CeccoCQ commentedon Sep 27, 2023
Hi @Willis0826,
I'm currently working on a project that uses AWS Serverless HttpApi (Type: AWS::Serverless::HttpApi). I was wondering if you have any experience with integrating Lambda Authorizer in this V2 version of the API Gateway?
Willis0826 commentedon Oct 2, 2023
@CeccoCQ Hey, sorry for the late reply. I tried HTTP APIs (V2), and it works great. Please refer to this example
CeccoCQ commentedon Oct 2, 2023
Hi @Willis0826 , thanks for you example!
I have a doubt regarding my case, following your sample.
With this
template.ymland these resources:When running
sam local start-api -n envs.json --skip-pull-image --warm-containers EAGER, if I usecurl -H "Authorization: abc" http://127.0.0.1:3000/api/usersorcurl http://127.0.0.1:3000/api/users, it seems that theAuthorizerFunctionisn't invoked (I have aconsole.log("Hello authorizer")inside), but the request is processed directly byApiUsersFunction.What is wrong?
Willis0826 commentedon Oct 2, 2023
@CeccoCQ the
AuthorizerPayloadFormatVersionfield should be"2.0"(a string) instead of2.0. If you runsam buildwithAuthorizerPayloadFormatVersion: 2.0, you should see an error messageError: 'AuthorizerPayloadFormatVersion' must be of type string for Lambda Authorizer 'LambdaTokenAuthorizer'..Am thinking maybe you can create an issue in my example repository. we can figure it out there.