authts / oidc-client-ts

OpenID Connect (OIDC) and OAuth2 protocol support for browser-based JavaScript applications
https://authts.github.io/oidc-client-ts/
Apache License 2.0
1.33k stars 196 forks source link

Issue with Refresh Token Rotation in oidc-client-ts: Concurrent Execution Problem in signinSilent() #1618

Open Lucklj521 opened 1 month ago

Lucklj521 commented 1 month ago

Hello there,

I've been using the oidc-client-ts package, and I've encountered an issue regarding the support for refresh token rotation. This feature is a requirement for being able to securely store refresh tokens on the client side, and it's an important security measure that we currently have to disable, which unfortunately lowers our security standards.

Apart from the multiple tabs issue mentioned in #430, we've identified another problem that we hope can be addressed alongside. The issue is described as follows:

Currently, signinSilent() lacks a mechanism to prevent concurrent executions. When signinSilent() is executed concurrently, it attempts to use the same refresh token for multiple requests. However, due to refresh token rotation being enabled, subsequent requests fail because the refresh token has already been used to obtain a new access token and refresh token.

In scenarios where automatic silent renewal is enabled, there are timer tasks set to refresh tokens periodically. This makes it impractical to manually trigger signinSilent() as concurrent executions are inevitable. As a result, in certain situations, such as when the browser is just activated, it becomes impossible to manually trigger signinSilent(), and we have to rely on the automatic refresh mechanism.

Implementing a mechanism within signinSilent() to prevent concurrent executions could potentially resolve this issue. This would ensure that only one refresh operation is ongoing at any given time, thereby avoiding the aforementioned problems.

Looking forward to your assistance in addressing this matter. Thank you for your time and consideration.

pamapa commented 3 weeks ago

related to https://github.com/authts/oidc-client-ts/issues/430