API gateway accepting revoked access tokens from header

0

I have a lambda being invoked by API gateway. The endpoint is protected with Cognito access token. The issue is, I have noticed that even a revoked access token is being accepted by the endpoint which shouldn't be the caser. How can I overcome this situation?

2 個答案
1

API Gateway allows access based on the information contained in the token. If you revoke the token in Cognito but the expiry of the token is still in the future then access will still be allowed by API Gateway - for performance it doesn't check with Cognito to see if every token is revoked; it's relying on the information that has been passed with the token.

One way to solve this is to use very short-lived tokens that are refreshed by the client application on a regular basis. That way revoked tokens are not valid for very long.

Another way would be to use Lambda Authorizer which could check to see if each token passed to API Gateway has been revoked or not. It could do this by checking with Cognito; or some other data source such as a DynamoDB table. However, this adds delay and cost to each API call.

profile pictureAWS
專家
已回答 10 個月前
0

Do you have cacheing enabled for the token? This page talks about how to enable. You should check if you have it enabled and look at the TTL.

https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-caching-tokens.html

profile pictureAWS
專家
iBehr
已回答 10 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南