fix(auth): `auth logout` removes the saved Altimate gateway key

Merged
SA
6d ago
+295-3

Problem

altimate-code auth logout → "altimate-backend" removed only the auth.json entry. Browser sign-in also saves the gateway key to ~/.altimate/altimate.json, and the provider loader and all workspace calls (api-client, state, identity, memory/skill sync, link, datamate) read that file first. After sign-out the key stayed on disk and still worked, so delegated runs (e.g. /altimate-code:altimate from Claude Code) kept sending requests as the signed-out user. On a shared machine, the next person's runs go out under the previous user's identity.

Fix

  • AltimateApi.signOut(projectDir): removes MCP entries in the global and project config whose Authorization header is exactly Bearer <saved key> (standalone datamate add writes the key there), then deletes ~/.altimate/altimate.json. CLI logout and TUI /logout both call it and list what they removed. Entries in other projects' config files aren't reachable; the follow-up is to stop saving the key in MCP headers.

  • providers.ts: logging out of altimate-backend calls signOut (via cliTry; on failure it names the file to delete manually instead of reporting "Logout successful").

  • providers.ts: the logout picker lists altimate-backend when only altimate.json exists (credentials pasted in the TUI dialog). Before, the CLI reported "No credentials found" and gave no way to sign out.

  • provider-credentials.tsx: TUI /logout also removes the auth.json entry (with throwOnError, so a failure shows an error toast). A pasted url::instance::key there would otherwise keep the provider loader's fallback path working.

After sign-out, workspace calls hit NotConfiguredError ("Altimate credentials not configured — sign in first.").

Not in scope

The key is only removed locally; it is not revoked on the server. Revoking it at sign-out needs a backend endpoint.

Testing

  • New CLI tests in test/cli/providers-logout.test.ts cover browser sign-in (both stores), file-only credentials, and MCP entry removal (an unrelated entry is kept). It fails on main (altimate.json still present) and passes with this change.
  • bun test test/cli test/upstream/fork-feature-guards.test.ts: 1187 pass. 4 failures in test/cli/run/{json-output,budget-finalization}.test.ts also fail on main and are unrelated.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Logging out of the Altimate backend removes saved credentials from both Altimate settings and the shared authentication store, while preserving credentials for other providers.
    • Logout removes remote MCP servers with a matching authorization key from global and current-project configurations. Other project configurations remain unchanged.
    • Command-line and interface logout report which entries were removed. If the saved key cannot be read, logout fails without deleting credentials.
  • Documentation
    • Added instructions for signing out of the Altimate LLM Gateway, including which configurations are affected and when sessions may need to be restarted.