Skip to content

Treat account tokens as runtime-only; remove token-only account support and always refresh tokens on admin actions#122

Merged
CJackHwang merged 2 commits intodevfrom
codex/refactor-configuration-to-remove-token-support
Mar 21, 2026
Merged

Treat account tokens as runtime-only; remove token-only account support and always refresh tokens on admin actions#122
CJackHwang merged 2 commits intodevfrom
codex/refactor-configuration-to-remove-token-support

Conversation

@CJackHwang
Copy link
Owner

Motivation

  • Prevent storing sensitive DeepSeek tokens in persistent config or exports by treating token as a runtime-only value.
  • Simplify account identity model to require email or mobile and remove legacy support for token-only accounts.
  • Ensure admin operations that rely on tokens always refresh/login to obtain a fresh runtime token to avoid using expired tokens.
  • Update UI wording to reflect that admin "tests" refresh tokens rather than perform a generic API test.

Description

  • Added Config.ClearAccountTokens() and call it when loading from env/file, when computing sync hash, and when saving/exporting (Store.Save, saveLocked, ExportJSONAndBase64) to strip token from persisted or exported JSON.
  • Removed synthetic token-based identifiers by making Account.Identifier() return empty when neither email nor mobile is present, and removed token-only account handling across the admin/pool codepaths.
  • Updated admin handlers to always call DS.Login(...) to refresh runtime tokens during account testing and deleteAllSessions, and persist the refreshed token only at runtime via Store.UpdateAccountToken (not in persisted config).
  • Prevent token from being accepted during incoming account import/updates by ignoring token in toAccount and updateConfig merge logic, and added incoming.ClearAccountTokens() in configImport.
  • Adjusted account pool behavior and tests to skip token-only accounts and update expectations accordingly in internal/account tests and internal/admin tests.
  • UI text updates in webui to change labels from "Test"/"Testing" to "Refresh token"/"Refreshing..." and related copy reflecting token-refresh semantics.
  • Added new HTTP tests in internal/admin/token_runtime_http_test.go to validate that imported token fields are ignored and that runtime token refresh occurs but exported config omits tokens.

Testing

  • Ran unit tests including internal/config, internal/account, internal/admin and internal/auth test suites such as TestLoadStoreClearsTokensFromConfigInput, TestPoolSkipsTokenOnlyAccount, TestListAccountsUsesEmailIdentifier, TestTestAccount_BatchModeOnlyCreatesSession, and new TestConfigImportIgnoresTokenFieldInPayload; all tests passed.
  • Exercised admin HTTP flows via new tests TestConfigImportIgnoresTokenFieldInPayload and TestAccountTestRefreshesRuntimeTokenButExportOmitsToken, which succeeded and validated import/export/token refresh behavior.
  • Verified go test ./... completed successfully across the modified packages.

Codex Task

@vercel
Copy link

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ds2api Ready Ready Preview, Comment Mar 21, 2026 7:01am

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca08bb66b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@CJackHwang CJackHwang merged commit f4db273 into dev Mar 21, 2026
3 checks passed
@CJackHwang CJackHwang deleted the codex/refactor-configuration-to-remove-token-support branch March 21, 2026 07:07
CJackHwang added a commit that referenced this pull request Mar 21, 2026
Merge pull request #122 from CJackHwang/codex/refactor-configuration-to-remove-token-support

Treat account tokens as runtime-only; remove token-only account support and always refresh tokens on admin actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant