Repository navigation
fix(auth): persist Server App logout revocation - #1116
Conversation
Persist verified JWT exp on ServerAppUser after jwt.verify and pass exp * 1000 to revokeToken on Server App logout so SQLite stores durable SHA-256 revocation rows across Server App, main API, and KDS. Fixes #1090
|
@greptile review |
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1090
Intent
Implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1090 ("Server App logout omits durable token revocation"): persist the verified JWT expiry on
ServerAppUserafterjwt.verifyinmain/server-app.tsand passtypeof user.exp === 'number' ? user.exp * 1000 : undefinedtorevokeToken(token, ...)on Server App logout so logout writes a durable SHA-256 revocation row to SQLite that survives in-memory reset and is enforced across Server App and main API. Deliver via theno-mistakespipeline as its own PR (Fixes #1090).What Changed
expclaim onServerAppUserinrequireServerAppAuth(main/server-app.ts) and passedtypeof user.exp === 'number' ? user.exp * 1000 : undefinedtorevokeTokenduring/api/auth/logoutso Server App logouts persist durable token revocations in SQLite (revoked_tokens).tests/server-app-server-role.test.tsto verify durablerevoked_tokensrows on Server App logout, rejection of revoked tokens across Server App, main API, and KDS after clearing in-memory revocations, rejection of invalid/expired/unauthenticated logout attempts, and continued access for unrelated live sessions.Risk Assessment
✅ Low: The change is a small, well-bounded fix in main/server-app.ts that passes the verified JWT exp claim (in milliseconds) to revokeToken on Server App logout, matching main API and KDS logout behavior and covered by end-to-end integration assertions across Server App, main API, and KDS.
Testing
Stood up the real Server App, Main API, and KDS Server against an isolated SQLite database, ran the targeted Server App, JWT logout lifecycle, fail-closed revocation, and script-coverage suites, and captured HTTP and SQLite evidence confirming durable SHA-256 token revocation on Server App logout and 401 enforcement across all servers after in-memory revocation reset; no visual artifact applies because this is a backend authentication and SQLite persistence change with no UI surface.
POST /api/auth/logout) and a durable SHA-256 token hash row withexpires_at = decoded.exp * 1000is persisted in SQLiterevoked_tokensnpm run test:server-app-server-roleand~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.jsonclearInMemoryRevokedTokens()), a token logged out via Server App remains rejected with 401 on Server App (/api/auth/me,/api/auth/logout), Main API (`/api/a…npm run test:server-app-server-roleand~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.jsonrequireServerAppAuthwithout writing rows torevoked_tokens, and a signed JWT without a numer…npm run test:server-app-server-roleand~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.jsonEvidence: Live Server App logout durable revocation and cross-server enforcement transcript
{ "adversarial_rejected_logouts": { "missing_token": { "status": 401, "body": { "error": "No token provided" } }, "invalid_token": { "status": 401, "body": { "error": "Invalid token" } }, "expired_token": { "status": 401, "body": { "error": "Invalid token" } }, "revoked_tokens_rows_written": 0 }, "durable_server_app_logout": { "logout_response": { "status": 200, "body": { "success": true } }, "jwt_verified_exp_seconds": 1792004142, "expected_expires_at_ms": 1792004142000, "sqlite_revoked_tokens_row": { "token_hash": "3026872705e8e1b53d97401ba0585ab6607af7d1490d45f84afb1f22dd1ad925", "expires_at": 1792004142000, "revoked_at": "2026-10-13 18:55:42" }, "hash_matches_sha256": true, "expires_at_matches_exp_ms": true }, "post_memory_reset_enforcement": { "server_app_auth_me": { "status": 401, "body": { "error": "Invalid token" } }, "main_api_auth_me": { "status": 401, "body": { "error": "Invalid token" } }, "main_api_categories": { "status": 401, "body": { "error": "Invalid or expired token" } }, "kds_owner_auth_me": { "status": 401, "body": { "error": "Invalid token" } }, "repeat_logout_with_revoked_token": { "status": 401, "body": { "error": "Invalid token" } } }, "unrelated_session_isolation": { "sibling_server_app_me_status": 200, "sibling_kds_me_status": 200 }, "expless_jwt_guard_branch": { "logout_response": { "status": 200, "body": { "success": true } }, "sqlite_row": null, "in_memory_revocation_enforced_status": 401 } }Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
POST /api/auth/logout) and a durable SHA-256 token hash row withexpires_at = decoded.exp * 1000is persisted in SQLiterevoked_tokensnpm run test:server-app-server-roleand~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.jsonclearInMemoryRevokedTokens()), a token logged out via Server App remains rejected with 401 on Server App (/api/auth/me,/api/auth/logout), Main API (`/api/a…npm run test:server-app-server-roleand~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.jsonrequireServerAppAuthwithout writing rows torevoked_tokens, and a signed JWT without a numer…npm run test:server-app-server-roleand~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.jsonnpm run test:server-app-server-rolenode tests/run-electron-node-test.cjs tests/jwt-logout-lifecycle.test.tsnode tests/run-electron-node-test.cjs tests/token-revocation-fail-closed.test.tsnpm run test:script-coverageLive multi-server HTTP + SQLite verification script writing~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.