fix: persist oauth host without keychain prompts - #68
Merged
Conversation
chris-freeman-glean
force-pushed
the
cfreeman/auth-host-persistence
branch
from
April 2, 2026 17:24
d8fd47b to
71efaad
Compare
chris-freeman-glean
force-pushed
the
cfreeman/auth-host-persistence
branch
from
April 2, 2026 17:29
71efaad to
297a7bf
Compare
chris-freeman-glean
marked this pull request as ready for review
April 2, 2026 17:38
david-hamilton-glean
approved these changes
Apr 2, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.glean/config.jsonduring OAuth login so credentials remain usable afterGLEAN_HOSTis unsetSaveHostToFile()that writes only the host to the config file without touching the system keyring, avoiding macOS Keychain prompts for a non-secret valueLogout()to properly clean up all auth artifacts — OAuth tokens, client registration, keyring entries, and config file — instead of just deleting the config fileProblem
After a successful
glean auth login, the CLI could end up in a broken state: the OAuth access token was stored (in~/.local/state/glean-cli/), but the resolved host was never persisted to~/.glean/config.json.If the host originally came from the
GLEAN_HOSTenvironment variable, opening a new shell without it meant the CLI couldn't find the host → couldn't look up the tokens → reported "not authenticated" even though valid tokens were on disk.Changes
internal/auth/auth.gopersistLoginState()saves both host and tokens atomically after login.Logout()now callsDeleteTokens→DeleteClient→ClearConfiginstead of rawos.Remove.resolveHost()usesSaveHostToFileto avoid unnecessary keyring writes.internal/auth/storage.goDeleteClient()for cleaning up stored OAuth client registrations on logout.internal/config/config.goSaveHostToFile()— file-only host persistence that skips the keyring entirely.internal/auth/auth_persistence_test.gointernal/auth/storage_test.goDeleteClient.internal/config/config_test.goSaveHostToFileconfirming keyring is not touched.Test plan
mise run test:allpasses./gleanand manually reproduced the old token-without-host failure in an isolated HOME, then verified persisted host state fixes itglean auth logoutclears all auth state (tokens, client, config, keyring)