fix(api): sign-out fails closed when the session delete does not commit (FIX-LOGOUT) - #131
Merged
Merged
Conversation
…it (FIX-LOGOUT) POST /v1/logout logged a session-store Delete error, expired the cookie and answered 204/200 while the server-side session stayed live — a copied cookie kept working. The delete is now the ordering's point of no return: on failure the handler answers retryable 503 UNAVAILABLE + Retry-After and tears nothing down (no cookie expiry, no lease/ticket revoke), so the response never claims a sign-out that did not commit and the still-valid session keeps its live leases until a retry completes the destroy. Revoke-all already fails closed (single transaction, 500, cookie kept); pinned by a retry test that mirrors the real row deletion. Portal copy (en/vi) now states the user is still signed in and can retry. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Summary
POST /v1/logoutlogged a session-storeDeleteerror, expired the session cookie and answered204/200— while the server-side session stayed live (a copied cookie kept working;/v1/mestill 200). The response claimed a sign-out that never committed.Deleteis now the ordering's point of no return. On a store error the handler answers retryable503 UNAVAILABLE+Retry-Afterand tears nothing down — no cookie expiry, no S17 lease/ticket revoke. The refusal's claim ("not signed out — retry") then matches reality: the session still validates and its desktops are still alive.POST /v1/me/sessions:revoke-all) reviewed: already fails closed — the revocation is one transaction; an error answers500 INTERNAL(retryable: true) and the cookie is only expired after commit. Kept as 500 (changing the pinned test's expectation buys nothing); a new retry test pins the contract.POST /v1/logoutalready listed503— the description now documents the fail-closed semantics;schema.d.tsregenerated. Threat-model S17 status line updated.Test plan
TestLogout_StoreDeleteFailureReturns503(new regression test): fails on v0.5.0 —go test ./internal/api/ -run TestLogout_StoreDeleteFailureReturns503 -count=1→logout status = 204, want 503on the pre-fix handler; passes with the fix (503 +Retry-After+UNAVAILABLE/retryable, noMax-Age=0, session still validates, revoker untouched, then a retry completes the destroy and/v1/me→ 401).TestRevokeAll_StoreFailureThenRetrySignsOut(new): failure keeps the session; retry commits and the session no longer validates.go test ./internal/api/ -count=1→ok(all existing logout/S17/revoke-all tests green);go test -race ./internal/api/ -count=1→ok;go vet ./...clean.npm run test:unit→ 305 passed (incl. new "a refused sign-out (503 UNAVAILABLE) can simply be retried");npm run typecheck,npm run lint:stringsclean.v1.0 fix task, requested by the project orchestrator; the advisor reviews and merges.
Generated with Devin