Skip to content

fix(auth): persist Server App logout revocation - #1116

Merged
khaira777 merged 3 commits into
mainfrom
fm/flocafe-issue-1090-r1
Oct 13, 2026
Merged

khaira777 merged 3 commits into
mainfrom
fm/flocafe-issue-1090-r1

Conversation

@khaira777

@khaira777 khaira777 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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 ServerAppUser after jwt.verify in main/server-app.ts and pass typeof user.exp === 'number' ? user.exp * 1000 : undefined to revokeToken(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 the no-mistakes pipeline as its own PR (Fixes #1090).

What Changed

  • Stored the verified JWT exp claim on ServerAppUser in requireServerAppAuth (main/server-app.ts) and passed typeof user.exp === 'number' ? user.exp * 1000 : undefined to revokeToken during /api/auth/logout so Server App logouts persist durable token revocations in SQLite (revoked_tokens).
  • Expanded tests/server-app-server-role.test.ts to verify durable revoked_tokens rows 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.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Staff member logs out from Server App (POST /api/auth/logout) and a durable SHA-256 token hash row with expires_at = decoded.exp * 1000 is persisted in SQLite revoked_tokens ✅ pass live npm run test:server-app-server-role and ~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json
After clearing in-memory revocations (clearInMemoryRevokedTokens()), a token logged out via Server App remains rejected with 401 on Server App (/api/auth/me, /api/auth/logout), Main API (`/api/a… ✅ pass live npm run test:server-app-server-role and ~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json
Adversarial logout attempts with missing, malformed, or expired Bearer tokens are rejected with 401 by requireServerAppAuth without writing rows to revoked_tokens, and a signed JWT without a numer… ✅ pass live npm run test:server-app-server-role and ~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json
Evidence: 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 } }

{
  "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.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Staff member logs out from Server App (POST /api/auth/logout) and a durable SHA-256 token hash row with expires_at = decoded.exp * 1000 is persisted in SQLite revoked_tokens ✅ pass live npm run test:server-app-server-role and ~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json
After clearing in-memory revocations (clearInMemoryRevokedTokens()), a token logged out via Server App remains rejected with 401 on Server App (/api/auth/me, /api/auth/logout), Main API (`/api/a… ✅ pass live npm run test:server-app-server-role and ~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json
Adversarial logout attempts with missing, malformed, or expired Bearer tokens are rejected with 401 by requireServerAppAuth without writing rows to revoked_tokens, and a signed JWT without a numer… ✅ pass live npm run test:server-app-server-role and ~/.no-mistakes/evidence/01M4V9PHGGT8GMH8NXJ5FYDC3F/server-app-logout-revocation-evidence.json
  • npm run test:server-app-server-role
  • node tests/run-electron-node-test.cjs tests/jwt-logout-lifecycle.test.ts
  • node tests/run-electron-node-test.cjs tests/token-revocation-fail-closed.test.ts
  • npm run test:script-coverage
  • Live 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.

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
@khaira777 khaira777 changed the title fix(main): persist durable token revocation on Server App logout fix(auth): persist Server App logout revocation Oct 13, 2026
@FreeOpenSourcePOS FreeOpenSourcePOS deleted a comment from coderabbitai Bot Oct 13, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; no actionable issues were found.

Summary

Server App logout now passes the verified JWT expiry to revokeToken, allowing SQLite to retain the token’s revocation.

  • Server App logout keeps revoked tokens blocked across servers.

Diagram

sequenceDiagram
    participant Client
    participant ServerApp as Server App
    participant SQLite
    participant APIs as Server App / Main API / KDS
    Client->>ServerApp: POST /api/auth/logout with JWT
    ServerApp->>ServerApp: Verify JWT and retain exp
    ServerApp->>SQLite: Store SHA-256 token hash and exp × 1000
    ServerApp-->>Client: success
    Note over APIs: After in-memory revocations are cleared
    Client->>APIs: Reuse logged-out JWT
    APIs->>SQLite: Look up token hash
    SQLite-->>APIs: Token is revoked
    APIs-->>Client: 401
Loading

Reviews (1) · Last reviewed commit: "no-mistakes(document): Fix lint budget w..." · Reviewed by Greptile

@khaira777
khaira777 enabled auto-merge (squash) October 13, 2026 20:31
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c61586b5-d4ea-4f56-a2f5-3dfc77b061ce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaira777
khaira777 merged commit 0676012 into main Oct 13, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-issue-1090-r1 branch October 13, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(auth): persist token revocation to SQLite revoked_tokens during Server App logout

1 participant