Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: handle expiration of refresh token #271

Merged
merged 1 commit into from
May 10, 2024

Conversation

ottokruse
Copy link
Collaborator

@ottokruse ottokruse commented May 8, 2024

Issue #, if available: N/A

Description of changes: When the ID and Access tokens have expired, and the Refresh token too, the user is now redirected to the Cognito Hosted UI to sign-in. Previously, this resulted in the custom Auth@Edge error page to be shown, which made the user explicitly click the sign-in button to be redirected to the Cognito Hosted UI to sign-in. That page should be shown for edge cases only.

Implemented as follows:

  1. RefreshAuth function: if the refresh fails with invalid_grant message from Cognito, we assume the refresh token expired and clear the cookie
  2. CheckAuth function: if the ID and Access token are expired and there is no refresh token (because it was now cleared), the user is redirected to Cognito for sign-in

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

@shanant321 shanant321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ottokruse ottokruse merged commit 5d54c4c into aws-samples:master May 10, 2024
@ottokruse ottokruse deleted the log-cognito-response branch May 10, 2024 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants