I am building a serverless react app which uses Cognito for sign-in/sign-out. The app calls API Gateway which is configured to use the Cognito User pool as the custom authorizer.
I also build a lambda function to sign out a user (cognitoIdentityServiceProvider.globalSignOut
).
When I sign into the app, and then call the lambda function to perform an admin sign-out, calls to protected API gateway functions from the app are still valid (with Cognito ID token passed in Authorization
header);
Are admin calls such as cognitoIdentityServiceProvider.globalSignOut
and cognitoIdentityServiceProvider.adminUserGlobalSignOut
not realtime, or is API Gateway configured to only validate after an hour?
Revoke a token You can revoke a refresh token using the RevokeToken API operation. You can also use the aws cognito-idp revoke-token CLI command to revoke tokens. Finally, you can revoke tokens using the revocation endpoint. This endpoint is available after you add a domain to your user pool.
Initiate new refresh tokens (API) Use the API or hosted UI to initiate authentication for refresh tokens. To use the refresh token to get new ID and access tokens with the user pool API, use the AdminInitiateAuth or InitiateAuth API operations. Pass REFRESH_TOKEN_AUTH for the AuthFlow parameter.
By default, Amazon Cognito refresh tokens expire 30 days after a user signs in to a user pool. When you create an app, you can set the app's refresh token expiration to any value between 60 minutes and 10 years.
Just found the answer, unfortunately not what I wanted to hear:
Because IdToken is represented as a JSON Web Key Token, it's signed with a secret or private/public key pairs, which means even if you revoke the IdToken, there is no way to revoke the distributed public key. And IdToken has a short life span, it will expire in a short time.
Is it possible to revoke AWS Cognito IdToken?
https://github.com/aws/aws-sdk-js/issues/1687
https://github.com/aws/amazon-cognito-identity-js/issues/21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With