- Newest
- Most votes
- Most comments
Yes, this is the expected behavior with AWS Cognito tokens. When you call GlobalSignOut or AdminUserGlobalSignOut, Amazon Cognito invalidates the tokens in its own systems, but this doesn't automatically invalidate JWT tokens that have already been issued and are being used with API Gateway.
Here's what happens when you call GlobalSignOut:
- Amazon Cognito no longer accepts token-authorized user operations that use the signed-out user's access tokens.
- The user's ID token is no longer accepted in GetId requests to an identity pool with ServerSideTokenCheck enabled.
- Refresh tokens are no longer accepted in refresh requests.
However, API Gateway authorizers typically validate tokens locally by checking the signature and expiration without making a call back to Cognito. This is why your tokens continue to work with API Gateway until they expire naturally.
To force immediate invalidation and prevent use of invalidated tokens, you have a few options:
-
Implement server-side token validation by creating a custom authorizer for API Gateway that checks with Cognito if the token has been revoked.
-
Use shorter token expiration times to reduce the window of vulnerability after sign-out.
-
Implement a token blacklist or revocation list in your application, where you store revoked tokens and check against this list in your API authorizer.
-
Use the
/oauth2/revokeendpoint to revoke specific refresh tokens. This endpoint revokes both the refresh token and all access and identity tokens that were issued with it. -
For highly sensitive operations, consider requiring re-authentication or additional verification steps.
Best practice is to use a combination of these approaches based on your security requirements, with shorter token lifetimes for sensitive applications and potentially implementing server-side validation for critical endpoints.
Sources
GlobalSignOut - Amazon Cognito User Pools
AdminUserGlobalSignOut - Amazon Cognito User Pools
The token revocation endpoint - Amazon Cognito
Ending user sessions with token revocation - Amazon Cognito
answered a year ago
Relevant content
asked 5 years ago
