- Newest
- Most votes
- Most comments
To invalidate existing ID tokens of a deleted Cognito user in API Gateway Authorizer, you need to configure the API Gateway Authorizer to validate the token against the Cognito User Pool's public keys. This way, when a user is deleted, their tokens will no longer be validated by the User Pool, and the API Gateway Authorizer will reject them.
Here are the steps:
-
In the Cognito User Pool, navigate to the "App integration" section and make a note of the "Issuer" URL. This URL contains the public keys used to validate JWT tokens.
-
In the API Gateway Authorizer configuration, select the "TOKEN_SOURCE" as "Authorization" and the "TOKEN VALIDATION" as "validateSignature".
-
For the "Audience" field, enter your API Gateway API's ID (e.g., "abcdef123").
-
For the "Issuer" field, enter the "Issuer" URL from the Cognito User Pool noted in step 1.
With this configuration, the API Gateway Authorizer will validate the token's signature against the Cognito User Pool's public keys. When a user is deleted, their tokens will no longer be validated by the User Pool, and the API Gateway Authorizer will reject them.
Note: This approach ensures that deleted users' tokens are immediately invalidated. However, if you want to revoke active sessions for deleted users, you'll need to implement additional logic in your application to handle this case.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
I noticed that the JWT Option is not available for REST API Endpoint only for HTTP. For REST We have Cognito and Lambda, for HTTP we have JWT and Lambda. We are currently using the Cognito option and expected it to reject the token of a deleted user.
Edit: I tried to test using HTTP API with
--identity-source '$request.header.Authorization'
audience client-id-from-cognito
and issuer url. Authorizer works but if I delete the perform global signout and delete user the token which was generated can still be used to access.Reference: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html#http-api-jwt-authorizer.create