Hockenba commented on PR #14242: URL: https://github.com/apache/apisix/pull/14242#issuecomment-7112850154
> Thanks for moving the logout and session changes upstream. **Before merging this PR, could you fix partial-write recovery in [lua-resty-session #217](https://github.com/bungle/lua-resty-session/pull/217) and add a regression test for a second HTTP logout request?** > > In the current candidate, `destroy()` writes the presented cookie's SID marker before it writes the login's lineage marker. If the first write succeeds and the second fails in `closed` mode, the client gets a 503 and keeps its cookie. On retry, even after Redis recovers, `open()` sees the persisted SID marker and returns `"session revoked"` before it loads the lineage. OpenIDC only calls `destroy()` for an open session, so the retry can finish without writing the missing marker. A sibling cookie issued by an earlier refresh can remain valid. This follows from the [write order](https://github.com/bungle/lua-resty-session/blob/aebf8cfdf1089d5a20e520a3e3f3ae5bf5ed8f12/lib/resty/session.lua#L1619-L1627), the [SID check on open](https://github.com/bungle/lua-resty-session/blob/aebf8cfdf1089d5a20e520a3e3f3ae5bf5ed8f12/lib/resty/session.lua#L1014-L1020), and [OpenIDC's destroy guard](https://github.com/zmartzone/lua-resty-openidc/blob/8538372972dcbb87c1defe67f694312f6c221cdf/lib/resty/ openidc.lua#L296-L330). > > Please extend the upstream test that currently stops at the first write error, and cover the browser-visible retry through APISIX with real Keycloak and Redis: > > 1. Log in, refresh the session, and retain two distinct, still-valid cookies from that login. Verify both reach the protected route before logout. > 2. Exercise the partial write in `closed` mode. Verify the SID marker was persisted, the lineage marker was not, and the first logout returns 503 without clearing the browser cookie. > 3. Restore writes and issue a **new HTTP logout request with the same cookie**. Verify logout completes and both cookies now redirect to authentication while they would otherwise still be valid. Checking only the retry's 302 would miss the bug. > > For this PR, please also pin mutually compatible releases containing both upstream fixes. The [current CI job](https://github.com/apache/apisix/actions/runs/44822431112/job/136688945719) installed session 4.3.0, then replaced it with 4.2.0 to satisfy OpenIDC 1.9.3. Both cookie replays returned 200 on the initial run and on retry. Finally, please qualify the English and Chinese docs: cookies issued before lineage IDs existed only support per-SID revocation, and checking Redis on every request requires setting **both** lookup and error cache TTLs to zero. Addressed. Session [bungle/lua-resty-session#217 · feat(*): revoke every cookie of…](https://github.com/bungle/lua-resty-session/pull/217): destroy() now writes the lineage mark before the session ID mark, so a failure between the two writes no longer leaves a cookie that the retry would miss. Added specs for a failed lineage write, a failed session ID write, and the cached write error. Added the regression tests through APISIX with real Keycloak and Redis. TEST 6 logs in and refreshes to get two valid cookies, fails the first logout (503, cookie kept, no marks written), then retries with the same cookie and checks that both cookies are rejected. TEST 7 does the same for a partial write, using a Redis ACL that allows only the lineage mark. Docs (English and Chinese): cookies issued before lineage IDs are revoked one by one, and both cache TTLs must be 0 to check Redis on every request. Pins: waiting on the session and openidc releases. I'll bump them in this PR once they are out. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
