Skip to content

feat(auth): encrypted credential store, sandbox-safe refresh, account in auth status [ENG-5285] - #41

Merged
Arlieeee merged 1 commit into
mainfrom
arliexubindu/eng-5285
Nov 3, 2026
Merged

Arlieeee merged 1 commit into
mainfrom
arliexubindu/eng-5285

Conversation

@Arlieeee

@Arlieeee Arlieeee commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Stored credentials are encrypted under a key the OS keeps, a shell that cannot write the credentials directory no longer loses its login, and auth status shows who is signed in.

Added

  • Encrypted credential store. API keys and tokens in credentials.v2.json are encrypted (AES-256-GCM) under a key held by the macOS Keychain, Windows DPAPI or the Linux Secret Service. Where none is available (CI, containers, SSH sessions, a HOME without a keychain, or MESHY_KEYRING=file) the key is a 0600 file next to the credentials.
  • Signed-in account. auth status and auth list report account (name and email) when the site provides it; logins ask for openid profile email.
  • auth status --show-token prints the credential, for host apps that hand it to sandboxed tools.
  • Host-provided session. DSH_MESHY_CREDENTIAL, DSH_MESHY_REGION, DSH_MESHY_SUBJECT and DSH_MESHY_STATE_DIR let the DeepSeek Harness plugin give its sandboxed shells a current credential and a writable directory for the operation journal.

Fixed

  • In a shell that cannot write the credentials directory, an expired OAuth token was refreshed and the result could not be saved, which ended the login. The CLI now skips the refresh there: a valid token keeps working, an expired one exits 3 and the stored login stays intact. auth login checks the directory before it starts a flow.
  • A token refresh dropped the profile's region, so a China-site login moved to the global site an hour after sign-in.

Changed

  • OAuth tokens are refreshed 30 minutes before they expire (was 60 seconds).
  • The pre-0.8 plaintext credentials.json is read until the first write, which moves its profiles into the encrypted file and deletes it. An older CLI on the same machine then signs in once on its own.
  • CI runs the key-store tests on macOS and Windows.

🤖 Generated with Claude Code

… store that cannot be written, report the account [ENG-5285]

- Stored API keys and tokens are AES-256-GCM encrypted in
  credentials.v2.json; the key is kept by the OS (Keychain on macOS, DPAPI
  on Windows, Secret Service on Linux desktops), with a 0600 key file where
  none is usable or MESHY_KEYRING=file. The pre-0.8 credentials.json is read
  until the first write, which moves its profiles over and deletes it.
- A refresh is skipped when the credentials directory cannot be written
  (a sandboxed agent shell): the API replaces the refresh token on use, so
  an unsaved refresh spent the login. A valid token is used as-is; an
  expired one exits 3 with the stored login intact. `auth login` checks
  this before any flow starts.
- Refresh 30 minutes ahead instead of 60 seconds; a refresh keeps the
  profile's region (it used to drop it) and account.
- A host app can hand over the session: DSH_MESHY_CREDENTIAL (used as-is),
  DSH_MESHY_REGION, DSH_MESHY_SUBJECT and DSH_MESHY_STATE_DIR (operation
  journal). `auth status --show-token` prints the credential for it.
- Logins ask for `openid profile email`; `auth status` and `auth list`
  report the account.
- CI runs the key-store tests on macOS and Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Arlieeee
Arlieeee merged commit 18b233a into main Nov 3, 2026
7 checks passed
@Arlieeee
Arlieeee deleted the arliexubindu/eng-5285 branch November 3, 2026 07:17
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.

1 participant