fix(auth): Harden Cloud OAuth credential recovery#184
Merged
Conversation
| func TestLoadHostTokenExplicitBasicTreatsJSONAsPlainToken(t *testing.T) { | ||
| store := setupFileKeyring(t) | ||
|
|
||
| token := `{"access_token":"literal-api-token","refresh_token":"not-oauth","expires_at":"2099-01-01T00:00:00Z"}` |
3919514 to
b17936a
Compare
Make explicit auth methods authoritative when loading stored Cloud credentials. This prevents legacy OAuth blob sniffing from overriding API-token logins and validates OAuth blobs before treating them as refreshable credentials. Surface expired OAuth state earlier through auth status and Cloud client construction, and avoid recovery guidance that would delete contexts. Add a per-host refresh lock so concurrent invocations do not race on rotating OAuth refresh tokens. Co-Authored-By: OpenAI Codex <noreply@openai.com>
b17936a to
2deadbe
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Harden Bitbucket Cloud credential handling around the OAuth/API-token split that caused expired OAuth credentials to look like API-token state.
Cloud API-token logins now persist
auth_method: basic, and explicit configured auth methods are authoritative when loading keychain credentials. OAuth blob inference is limited to legacy missing-auth-method configs and now validates that stored JSON includesaccess_token,refresh_token, andexpires_atbefore treating it as OAuth.The Cloud client now carries runtime-only OAuth expiry metadata from the loaded token, fails fast when OAuth is already expired and consumer env vars are missing, and uses a per-host file lock around refresh and keychain write-back to avoid races with rotating refresh tokens.
bkt auth statusnow surfaces inferred OAuth, expired OAuth, unavailable refresh state, and treatsBKT_TOKENas effective basic auth by default.Recovery guidance now tells users to rerun
bkt auth login https://bitbucket.org --kind cloud --web-tokento replace stored OAuth credentials with a scoped API token, without recommendingauth logoutand deleting contexts. The login help also stops presenting OAuth as the recommended default for ordinary Cloud auth.