Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 684a1f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
After `gws auth login` with another account, or with the same account and new scopes, gws kept serving the access token cached for the previous credential. yup-oauth2 stores the refresh token next to each cached access token and refreshes expired entries with it, so the stale grant survived even after the cached token expired. Switching GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE hit the same cache. - `auth login` removes token_cache.json and sa_token_cache.json (and the account timezone cache) after saving the new credentials. - Cache entries are keyed by a truncated SHA-256 fingerprint of the credential (client ID + refresh token, or the service account key), so a cache written for one credential is never served to another. Entries for other credentials, including legacy unbound ones, are pruned on write. Fixes googleworkspace#780 Fixes googleworkspace#572
4459727 to
684a1f5
Compare
|
This PR has been inactive for 72 hours. Closing to keep the queue clean. |
|
This PR was closed because it has been stalled for 72 hours. Feel free to magically reopen it if you want to continue working on it! |
Description
Fixes #780. Fixes #572.
After
gws auth loginto another account, or to the same account with new scopes, gws keeps serving the access token cached for the previous credential.auth statusshows the new account while API calls still run as the old one. yup-oauth2 stores the refresh token next to each cached access token and refreshes expired entries with that stored token, so the old grant outlives the cached access token's hour. SwitchingGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILEbetween exported credentials hits the same shared cache (#572).Two changes:
auth loginclears the caches. After saving the new encrypted credentials it removestoken_cache.json,sa_token_cache.jsonand the account timezone cache, asauth logoutalready does.GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILEcase where no login happens. On write, entries for other credentials, including legacy unbound keys, are pruned so they don't accumulate. The fingerprint is a digest and reveals nothing about the secrets.Existing caches are ignored once and rewritten in the new format, so the next call after upgrading mints one fresh token.
Testing
auth login's cache clearing.cargo test: all pass excepttest_get_quota_project_reads_adcandtest_get_quota_project_priority_adc_fallback, which also fail onmainon a machine with gcloud ADC configured (they read the real well-known ADC file).cargo clippy -- -D warnings: no new lints. On a recent toolchainmainalready fails a few lints in files this PR doesn't touch.Dry Run Output:
// Not applicable: no new API command or request body.Checklist:
AGENTS.mdguidelines (no generatedgoogle-*crates).cargo fmt --allto format the code perfectly.cargo clippy -- -D warningsand resolved all warnings (none new).pnpx changeset) to document my changes.