Which Category is your question related to?
Auth
What AWS Services are you utilizing?
AWS Cognito
Provide additional details e.g. code snippets
My stack is a React application using aws-amplify to authenticate with AWS Cognito identity pool.
I am wondering what happens when a user authenticates into an app that is using AWS Amplify, and the refresh token validity expires for that user? Will aws-amplify automatically send the user to AWS Cognito for re-authentication? If not, is there a Hub event to catch when a user's refresh token expires?
When you say 'send the user to AWS Cognito for re-authentication', am I correct in assuming that you are using Hosted UI?
Yes, I am using the Hosted UI.
When the refresh token expires, Amplify does not automatically sign the user out nor send the user to Hosted UI.
Hub does not currently emit an event when a refresh token expires.
What behavior would best work for your use case in this scenario? Please feel free to describe it in a new feature request.
Is your feature request related to a problem? Please describe.
When the current user's refresh token expires, there is no easy way for the application to know when that happens. When refresh tokens expire certain applications may want to send the user to re-authenticate, or display a dialog notifying the user that their session has expired and they need to log in again.
Describe the solution you'd like
A hub authentication event channel is created for the application to listen for the event of when the user's refresh token expires.
Describe alternatives you've considered
The user is automatically sent back to the hosted UI to re-authenticate when the refresh token expires (but this solution does not provide as much flexibility).
Additional context
In my scenario I have a react application using aws-amplify for authentication with a Cognito Identity pool. For security reasons the refresh token expiration is set to 1 day (the minimum allowed by Cognito). After a signed in user's refresh token expires, the user is still logged in, but no calls to Cognito or the application's backend work. We need a way to know when the current logged in user's refresh token expires so we can sign the user out or force the user to re-authenticate by sending them to the hosted UI.
Hi @ErikOwen - thanks for providing this info. I will make this a feature request and leave this open so the team can address it.
Most helpful comment
Hi @ErikOwen - thanks for providing this info. I will make this a feature request and leave this open so the team can address it.