serverless-authorizers icon indicating copy to clipboard operation
serverless-authorizers copied to clipboard

specify *

Open jonathanalberghini opened this issue 7 years ago • 5 comments

This code is wrong if you have caching on and resource is the method and you have more than one method it will fail.

jonathanalberghini avatar Jan 26 '19 22:01 jonathanalberghini

There is not one project in this repo, could you point out which one you are talking about, and which line of codes?

say something but with no details in github world is not the right way. Use the codes to speak, thanks.

ozbillwang avatar Jan 27 '19 03:01 ozbillwang

Sorry I should of put in more detail and your code is not really wrong. Everywhere I found uses the same code. And none of them talk about how to use the authorizer cache. I have been experimenting with api gateway cache and authorizer cache and ran into a few weird results.

So if you use the same authorizer on more than one function in a project and have caching setup, the first call to function one will call the authorizer and will get permission to that specific lambda function with the code you have. If you call function 2 before the cache expires it will use the cached policy and the 2nd call will fail as the policy only allows function one permission resource. Tomorrow I will add the other issues I found. I ended up doing the resource as all functions in the project / stage. I am using request-type authorizer. I wasn't blaming anyone just thought since you have this repo you could let people know my findings so they did not have to suffer through what I had too. The authorizer cache has some weird affects on api gateway function cache I will detail those tomorrow.

jonathanalberghini avatar Jan 28 '19 00:01 jonathanalberghini

If function "one" and "two" need different permissions, you need work with two functions.

Any thing to stop you doing that?

ozbillwang avatar Jan 28 '19 03:01 ozbillwang

Or you can disable cache, if it is really matter.

ozbillwang avatar Jan 28 '19 03:01 ozbillwang

It is just something that is not documented anywhere. And for my case the authorizer function is in a different project. There are 3 projects and over 100 functions that use the same authorizser. And cache really helps our response as the authorizer does a good amount of work to calculate the feed the user can access.

jonathanalberghini avatar Jan 28 '19 14:01 jonathanalberghini