The Real Fullstack

The Expired Token

Refresh token rotation was supposed to make sessions safer. Why does it log users out of the dashboard?

エンジニア8 分タイムラインシミュレーターコード課題
oauth2openid-connectangularhttp

この課題はまだ日本語に翻訳されていません。英語版を表示しています。

ミッション:Keep sessions seamless when the token expires mid-burst, while keeping refresh token rotation (and its theft detection) enabled.背景 · 学習目標 ▾

Quillfin's Angular app uses short-lived access tokens and rotating refresh tokens. The dashboard fires five API calls on load. When the access token has just expired, users are sometimes thrown back to the login page. The auth server's log says “refresh token reuse detected — revoking session”.

ミッション: Keep sessions seamless when the token expires mid-burst, while keeping refresh token rotation (and its theft detection) enabled.

学習目標

  • Explain access/refresh token lifecycles.
  • Understand refresh token rotation and reuse detection.
  • Coordinate concurrent refreshes (single flight) or refresh proactively.
シミュレーションシミュレーション値

シミュレーションを実行すると出力が表示されます。

シミュレーションを実行
export const authInterceptor: HttpInterceptorFn = (req, next) =>  next(withToken(req)).pipe(catchError((e) => e.status === 401    // every failing request starts its own refresh with the same refresh token    ? inject(Auth).refresh().pipe(switchMap(() => next(withToken(req))))    : throwError(() => e)));

簡略化

Five concurrent requests at the exact moment of expiry; network timing is ignored. 教育用モデルです。数値は挙動を示すためのもので、ベンチマークではありません。

コンセプト

関連する課題

参考資料