Skip to content

Commit 9cc14c7

Browse files
fix(keyring): persist OAuth tokens across Homebrew upgrades
Disable KeychainTrustApplication to prevent macOS Keychain from tying access control to the specific binary hash. This allows tokens to survive across Homebrew upgrades where the binary hash changes. Users may see a one-time keychain access prompt after upgrade. Fixes openclaw#86 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4f2b12e commit 9cc14c7

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

internal/secrets/store.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ func openKeyring() (keyring.Keyring, error) {
173173
}
174174

175175
cfg := keyring.Config{
176-
ServiceName: config.AppName,
177-
KeychainTrustApplication: runtime.GOOS == "darwin",
176+
ServiceName: config.AppName,
177+
// KeychainTrustApplication is intentionally false to support Homebrew upgrades.
178+
// When true, macOS Keychain ties access control to the specific binary hash.
179+
// Homebrew upgrades install a new binary with a different hash, causing the
180+
// new binary to lose access to existing keychain items. With false, users may
181+
// see a one-time keychain prompt after upgrade (click "Always Allow"), but
182+
// tokens survive across upgrades. See: https://github.com/steipete/gogcli/issues/86
183+
KeychainTrustApplication: false,
178184
AllowedBackends: backends,
179185
FileDir: keyringDir,
180186
FilePasswordFunc: fileKeyringPasswordFunc(),

internal/secrets/store_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ import (
1717
var errKeyringOpenBlocked = errors.New("keyring open blocked")
1818

1919
// keyringConfig creates a keyring.Config for testing.
20+
// KeychainTrustApplication is false to match production config (see store.go).
2021
func keyringConfig(keyringDir string) keyring.Config {
2122
return keyring.Config{
2223
ServiceName: config.AppName,
23-
KeychainTrustApplication: runtime.GOOS == "darwin",
24+
KeychainTrustApplication: false,
2425
AllowedBackends: []keyring.BackendType{keyring.FileBackend},
2526
FileDir: keyringDir,
2627
FilePasswordFunc: fileKeyringPasswordFunc(),

0 commit comments

Comments
 (0)