Brinsley
10/20/2021, 6:19 AMApi
construct that I’m trying hide behind an authorizer.
Problem 1
I initially set up to use a UserPool authorizer, and all was well until I tried to use a JWT that I knew had expired - api returned with a 200 and everything processed as though the JWT was valid. I did some reacding around and fixing for about 8 hours and found out that Cognito doesn’t revoke access tokens unless a global sign out is triggered, obvious not what I want. I couldn’t find any settings in the AWS Console or in the CDK (or SST) docs that would help me with rejecting the request if the JWT was expired.
Problem 2
So I started looking at using a Lambda authorizer instead, more work but at least I can guarantee it handles the token as I expect. I got a lambda in place, it’s being called and is kicking out a callback("Unauthorized");
response. The api, however, returns a 500 response instead of the 401.
I’m at a complete loss on both of these approaches. Any thoughts/feelings?Ross Coundon
10/20/2021, 6:26 AMBrinsley
10/20/2021, 7:03 AMChad (cysense)
10/20/2021, 7:48 AMChad (cysense)
10/20/2021, 7:55 AMChad (cysense)
10/20/2021, 8:04 AMChad (cysense)
10/20/2021, 8:09 AMAPI-Gateway-Execution-Logs_fga9pxb11l/prod 50f4aa6af842e8cdd66992c877d5c19d (32738d7a-4c0a-49ad-85ab-c889a8ac3d4f) Extended Request Id: Hf0j-HVtvHcFjMw=
API-Gateway-Execution-Logs_fga9pxb11l/prod 50f4aa6af842e8cdd66992c877d5c19d (32738d7a-4c0a-49ad-85ab-c889a8ac3d4f) Starting authorizer: 1ikffo for request: 32738d7a-4c0a-49ad-85ab-c889a8ac3d4f
API-Gateway-Execution-Logs_fga9pxb11l/prod 50f4aa6af842e8cdd66992c877d5c19d (32738d7a-4c0a-49ad-85ab-c889a8ac3d4f) Unauthorized request: 32738d7a-4c0a-49ad-85ab-c889a8ac3d4f
Ross Coundon
10/20/2021, 8:10 AMBrinsley
10/20/2021, 9:06 AMcallback(string)
method for rejecting the request. A DENY policy might just be the way to get it working though.Ross Coundon
10/20/2021, 9:23 AMBrinsley
10/20/2021, 9:52 AMRoss Coundon
10/20/2021, 9:53 AMRoss Coundon
10/20/2021, 10:18 AMif (!authToken) {
return Promise.resolve(generatePolicy('user', 'Deny', event.methodArn));
}
Brinsley
10/20/2021, 4:46 PMFrank