Skip to content

fix: harden install and credential cleanup#14

Merged
scmmishra merged 5 commits into
mainfrom
chore/general-imrpovements
May 15, 2026
Merged

fix: harden install and credential cleanup#14
scmmishra merged 5 commits into
mainfrom
chore/general-imrpovements

Conversation

@scmmishra
Copy link
Copy Markdown
Member

@scmmishra scmmishra commented May 15, 2026

This PR has the following changes

  • fail installer when release checksums cannot be verified
  • store API keys under a stable keyring entry and migrate old scoped entries on first read
  • make logout clear all chatwoot-cli keyring entries, even without config
  • sanitise output from login success
  • hide hmac_identifier in verbose output
  • remove the obsolete smoke test script

Tests

  • go test ./...
  • sh -n install.sh

scmmishra added 3 commits May 14, 2026 22:04
Store API keys under a stable keyring entry instead of deriving the entry name from base URL and account ID. The old scheme could leave credentials behind if config.yaml was edited manually before logout.

On first read, migrate an existing URL/account-scoped key to the stable api-key entry and delete the legacy entry. Keep a TODO to remove the migration in v1 after users have had a release cycle to move forward.

Logout now clears the whole chatwoot-cli keyring service even when config.yaml is missing, so stale entries are removed independently of the current config state.
Copy link
Copy Markdown

@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: 4cc2d68eba

ℹ️ 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".

Comment thread internal/config/credentials.go Outdated
scmmishra added 2 commits May 15, 2026 11:21
Sanitize server-provided strings before writing auth login output, raw API responses, verbose non-JSON bodies, and API error bodies to the terminal.

Expand verbose JSON redaction to cover hmac_identifier and common secret-like field names such as *_token, *_secret, *_key, and hmac_* values.

Tests cover terminal escape stripping for the affected output paths and redaction of HMAC/secret-like response fields.
Store stable keyring credentials as scoped JSON containing the normalized base URL, account ID, and API key instead of a raw token.

ResolveAPIKey now rejects saved credentials when the current config points at a different instance or account, preventing a token from being sent to the wrong host after config.yaml is edited or restored.

Legacy scoped entries are migrated into the new scoped JSON format and then deleted.
@github-actions
Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/chatwoot/cli/internal/cmd 32.91% (+2.69%) 👍
github.com/chatwoot/cli/internal/config 73.56% (+7.89%) 👍
github.com/chatwoot/cli/internal/output 78.16% (ø)
github.com/chatwoot/cli/internal/sdk 52.81% (+1.68%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/chatwoot/cli/internal/cmd/api.go 75.41% (+5.41%) 61 (+1) 46 (+4) 15 (-3) 👍
github.com/chatwoot/cli/internal/cmd/auth.go 32.53% (+13.25%) 83 27 (+11) 56 (-11) 🎉
github.com/chatwoot/cli/internal/config/credentials.go 81.25% (+13.39%) 48 (+20) 39 (+20) 9 🎉
github.com/chatwoot/cli/internal/output/output.go 78.16% (ø) 87 68 19
github.com/chatwoot/cli/internal/sdk/client.go 59.38% (+3.47%) 128 (+1) 76 (+5) 52 (-4) 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/chatwoot/cli/internal/cmd/api_test.go
  • github.com/chatwoot/cli/internal/cmd/auth_test.go
  • github.com/chatwoot/cli/internal/config/credentials_test.go
  • github.com/chatwoot/cli/internal/sdk/client_test.go

@scmmishra scmmishra merged commit 53da451 into main May 15, 2026
10 checks passed
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