Repository navigation
Conversation
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
049c6d1 to
56c7353
Compare
…bsence Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
6aa6f52 to
f97e9a4
Compare
|
We tested this PR (head f97e9a4, only the Setup: Nextcloud 35.0.1, user_oidc 8.11.0, Before the patch (8.11.0): Over 8 days, 615 of ~2,300 refresh tokens were redeemed more than once (up to 13 times), always less than 1 s apart, same IdP session, same Nextcloud host. In the debug log it is two parallel background requests of the same browser session (e.g. With the patch, race: 43 of 44 refresh tokens were redeemed exactly once (90 min before: 2 of 31 redeemed 2× and 5×). One real concurrent case was adopted from the cache ("Token already refreshed by another request (cache)"), 48 proactive refreshes were throttled. So the core idea — re-reading from the distributed cache after taking the lock and refreshing with the freshest refresh token — fixes the race for us. With the patch, regression: After the IdP session ended (the IdP session was ended by another app sharing it), the IdP rejected the refresh token ("Session not active"). With the patch, background requests kept the Nextcloud session ("reauthenticate skipped: not a top-level HTML navigation, keeping the session") and the same dead refresh token was retried roughly every 30 s (throttle TTL) with no end — 53 rejected attempts in ~30 min until we rolled back. The Nextcloud session stayed open without a valid IdP session. With 8.11.0 the same situation ends after a few attempts with a logout. Suggestions:
Happy to test an updated version. |
Fix #1449
After #1391 introduced proactive token refresh at half the token lifetime, users on rotating-refresh-token IdPs (reported with Authentikk #1175 and #1449 for context.) get bounced through the full OIDC re-login flow during active sessions, losing unsaved work.
TokenService::checkLoginToken()runs on every request (wired inApplication::boot). Once the token passes half-life, every request, including parallel background polls (notifications, user_status heartbeat), attempts a refresh. With refresh-token rotation, two concurrent requests race: the winner refreshes and the IdP rotates/invalidates the old refresh token; the loser then presents that already-rotated token, which the IdP rejects (or treats as token-reuse and revokes the whole family).The token can no longer be refreshed, so
reauthenticate()issues a hard redirect.The per-session lock added in #1391 didn't prevent this: its double-check read
$this->session(a per-request in-memory snapshot), which is stale on non-locking session backends (Redis/memcached), exactly the setups where parallel requests aren't serialized.🤖 AI (if applicable)