You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auth: rename legacy storage mode to plaintext, make it the default (#5088)
## Why
The CLI's storage-mode resolver had three values: `legacy` (default,
file cache + host-key dual-write), `secure` (OS keyring), and
`plaintext` (file cache, no dual-write, intended placeholder for a
future no-mirror mode).
The `plaintext` path duplicated `legacy` minus the host-key entry that
older Go SDKs (v0.61-v0.103) still rely on, so its "no dual-write"
property bought users nothing. Two modes is the right surface:
`plaintext` for the file cache and `secure` for the OS keyring.
While in there, also fixes the host-key dual-write code path so it
actually goes through the SDK on every cache write (including refresh),
the way `DualWritingTokenCache`'s docstring already claimed.
## Changes
**Mode rename**
- `plaintext` takes today's `legacy` semantics (file cache + host-key
dual-write) and becomes the resolver default.
- `secure` is unchanged.
- `legacy` is removed from the user-visible surface.
`DATABRICKS_AUTH_STORAGE=legacy` is now rejected with the standard
"unknown storage mode" error listing `plaintext` and `secure`. The
keyword was undocumented and users on the default were unaffected.
**Wrap-once refactor**
- New `storage.WrapForOAuthArgument(cache, mode, arg)` returns
`NewDualWritingTokenCache(...)` for plaintext, the cache unchanged
otherwise. Applied at the three login `NewPersistentAuth` call sites
(login main flow, `discoveryLogin`, `runInlineLogin`).
- Deletes `dualWriteLegacyHostKey`/`mirrorTokenUnderHostKey` and the
post-Challenge call sites. The mirror now happens inside the SDK's own
Store call via the wrapper, removing one redundant Lookup and one
redundant primary-key Store per login.
- `DualWritingTokenCache.Store` now treats the host-key mirror as
best-effort: a failure on the second Store is silently dropped.
Previously the wrapper returned the error, but it was always called by a
helper that swallowed it; pulling the wrapper into the SDK Store path
made that error fatal, which would block primary login over a
non-essential backward-compat shim.
**Acceptance fixtures**
- `legacy-env-default/` -> `plaintext-env-default/`. Scripts that set
`DATABRICKS_AUTH_STORAGE=legacy` now set `=plaintext`. Error-message
outputs regenerated.
## Test plan
- [x] `make checks` clean
- [x] `make test` passes (5305 unit, 2514 acceptance)
- [x] `make lint` 0 issues
- [x] Storage-mode acceptance: invalid env, invalid config,
env-overrides-config, plaintext-env-default with the new error-message
format.
- [x] `TestWrapForOAuthArgument`: end-to-end Store across plaintext /
secure / unknown — primary key always written, host-key mirror only in
plaintext.
- [x] `TestDualWritingCacheStoreHostKeyFailureIsBestEffort`: host-key
write error does not propagate; primary write persists.
0 commit comments