aws-samples / aws-samples/cloudfront-authorization-at-edge
Issues with the refresh endpoint endlessly redirecting after signin
- Dominant language
- TypeScript
- Stars
- 534
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
We're using v2.1.0 (vanilla, nothing fancy/special). Occasionally, a user will get stuck in this redirect loop. I suspect it's when the JWT expires, and a lazy evaluation happens. Not all the time, but sometimes, it will put the browser into this constant back and forth redirect ping thing that keeps showing the message/image displayed below. If you look at the XHR request stuff, you'll see that it's just endlessly redirecting from the `/refresh` endpoint, to the cognito `/auth` and `/login` endpoints. I can post the XHR's (once I sanitize them), if needed.
This might be due to a refactor done recently for this version that has the JWT refreshed lazily perhaps?
I've tried with the JWT expiration set to 1 hour, 12 hours, 24 hours, and 5 minutes and the same thing. It just changes how fast the cycles go before this issue manifests/gets recreated.
For the end user, there's no solution other than clearing cookies to correct this problem. Once they sign in again, the problem goes away for several refreshes, some unknown number (can't recreate it consistently, it appears to be a timing thing) before it hits again.
I'm going to try reverting back to a previous version of the app (v2.0.19) to see if this has any positive impact.

Contributor guide
Research direction
Start by reproducing the redirect chain described for `/refresh`, Cognito `/auth`, and `/login` in v2.1.0, then compare its behavior with v2.0.19. The fix is done when expired JWTs no longer cause an endless redirect loop and users can recover without clearing cookies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100