Repository navigation
fix(auth): keep the session when the token refresh cannot reach the identity provider - #1014
Merged
Merged
Conversation
…dentity provider A network error, a timeout or a 5xx from the token endpoint was treated like a refused refresh token: the 401 recovery cleared the store and signed the user out. A refresh now reports fresh / ended / unavailable. Refusals (400 invalid_grant, 401) sign out as before without retry; transient failures retry twice with backoff, then keep the identity, send no token, and show a notice. A 5s cool-down stops each refused request on a screen from starting its own retry series. Closes #983 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… sign out first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇을
keycloak.ts는updateToken()이 거부되면 이유와 상관없이 null 을 돌려줬고,init.ts의 401 복구는 null 이면 세션을 비웠습니다. 그래서 토큰 엔드포인트에 닿지 못한 경우(네트워크 오류, 시간 초과, 5xx)도 refresh token 이 거부된 경우와 똑같이 로그아웃으로 이어졌습니다. 세션은 아직 유효한데도 신원, 제공자 키, 계정별로 저장된 상태가 함께 지워졌습니다.Closes #983
어떻게
RefreshOutcome):fresh(쓸 토큰이 있음),ended(세션이 끝남),unavailable(IdP 에 닿지 못함). fix(auth): renew for a forced refresh instead of reusing a regular one in flight #998 의 강제 갱신 합류 규칙은 그대로이고, 합류하는 promise 가 토큰 대신 이 결과를 담습니다.getFreshToken은 시그니처를 유지합니다.invalid_grant, keycloak-js 가 세션을 직접 끝냄), 401, 그리고 알 수 없는 오류는 지금처럼 재시도 없이 로그아웃합니다. 판단이 서지 않으면 막는 쪽입니다.TypeError(fetch 실패), 시도당 10초 시간 초과(keycloak-js 는 시간 제한이 없음), 5xx/408/429 는 0.5초, 1.5초 뒤 두 번 재시도합니다. 그래도 실패하면 신원과 저장 상태를 유지하고, 해당 요청은 다시 보내지 않고 실패시키며, 토큰은 보내지 않습니다(이전 토큰도 안 보냄). 화면 상단에 "로그인 서비스에 연결할 수 없습니다. 로그인 상태는 유지됩니다" 안내를 띄우고, 갱신이 성공하면 사라집니다.unavailable을 돌려주고, 일반 갱신은 재시도 없이 한 번만 시도합니다.확인
__tests__/authTransientRefresh.test.ts(새 파일)init.ts·keycloak.ts·store.ts를origin/main으로 되돌려 실행. 통과하는 3개는 invalid_grant 로그아웃, 401 로그아웃, 이전 토큰을 보내지 않음 — 지켜야 하는 기존 동작)src/features/auth기존 테스트keycloak.test.ts의 #984 테스트 포함)node scripts/run-keycloak-e2e.mjs, 로컬)check-e2e-evidence.mjs--max-warnings 0, 새 위반 없음) · typecheck · i18n 4종 · stale-ui · 전체npm test(3764 통과) · build(번들 예산 안)단위 테스트는 네트워크 오류, 502, 503, 시간 초과, 재시도 중 복구, 재시도 상한, 쿨다운을 다루고, invalid_grant, 토큰 엔드포인트 401, 명시적 로그아웃은 별도로 확인합니다. E2E 는 실제 realm 의 refresh grant 만 가로채서 연결을 끊고(6초 동안 갱신 시도 3번 이하, 로그인 유지, 안내 표시), 다시 열면 갱신되고 안내가 사라지는지, 별도 테스트에서 400
invalid_grant를 돌려주면 한 번만 시도하고 로그인 화면으로 가는지 봅니다.범위
Scope exception: NO
Existing flow or risk: 기존 로그인·로그아웃 흐름은 그대로입니다. 바뀌는 것은 IdP 에 닿지 못했을 때뿐이고, 그때 세션을 비우지 않습니다. 위험은 IdP 장애 중 일시적인 실패로 분류된 상태가 길어지는 것인데, 그동안 토큰은 보내지 않으므로 보호된 요청은 실패한 채로 막혀 있습니다. 새 공개 API, 새 사용자 흐름, 새 서비스는 없습니다.
하지 않은 것
🤖 Generated with Claude Code