Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate generic method policy for API Gateway #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

valeriomazzeo
Copy link

This pull requests allows the authorizer to be cached and reused with different methods. Perhaps it would be good to add some sort of configuration and document such feature.

Per API Gateway documentation (https://docs.aws.amazon.com/apigateway/latest/developerguide/configure-api-gateway-lambda-authorization-with-console.html):

...
Note
To enable caching, your authorizer must return a policy that is applicable to all methods across an API. To enforce method-specific policy, you can set the TTL value to zero to disable policy caching for the API.
...

This pull requests allows the authorizer to be cached and reused with different methods. Perhaps it would be good to add some sort of configuration and document such feature.

Per API Gateway documentation (https://docs.aws.amazon.com/apigateway/latest/developerguide/configure-api-gateway-lambda-authorization-with-console.html):
>...
>Note
>To enable caching, your authorizer must return a policy that is applicable to all methods across an API. To enforce method-specific policy, you can set the TTL value to zero to disable policy caching for the API.
>...
@chaseconey
Copy link

This actually breaks the current walkthrough on the Auth0 guide located here. It calls for a TTL of 3600 in the setup using this lambda. Highly recommend we either add this PR or update the walk through.

@omichowdhury
Copy link

omichowdhury commented Feb 4, 2020

If anyone else is seeing good tokens seemingly randomly being not accepted by API Gateway and your authorizer not even being called, I may have an answer for you. The symptom is that the first API call you make works, and continue to works but any other method or endpoint doesn't.

See this link that explains why:
https://forums.aws.amazon.com/thread.jspa?threadID=225934

The fix is to make the changes in this PR to your authorizer and enable the authorizer cache - OR don't make this change and disable caching.

@auth0 - please merge and make it the default

patrick-webs added a commit to websdotcom/jwt-rsa-aws-custom-authorizer that referenced this pull request May 13, 2020
@icampana
Copy link

I was having the exact same issue, my calls were working first as long as they were GET calls, as soon as it switched to a POST, they would end up not being "Authorized".

Applied this patch and everything was working, so I can confirm that this is still happening.

@Aaronius
Copy link

Aaronius commented Aug 5, 2022

I would love to see this merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants