Commit 8a8ff48
authored
auth describe: show U2M token storage location and source (#5211)
## Why
Users have no way to tell where the CLI is storing their U2M
(`databricks-cli`) token. As we move toward making secure storage the
default at GA, users need to confirm whether their tokens live in the OS
keyring or in `~/.databricks/token-cache.json`, and which precedence
level produced that choice. `gh auth status` does this with a
`(keyring)` or `(/path/to/hosts.yml)` suffix; we want the same.
## Changes
Before: `databricks auth describe` showed host, user, auth type, and a
"Current configuration" block, with no information about U2M token
storage.
Now: For profiles using `auth_type = databricks-cli`, output adds:
```
Token storage: plaintext, ~/.databricks/token-cache.json (from default)
```
or
```
Token storage: secure, OS keyring (service: databricks-cli) (from DATABRICKS_AUTH_STORAGE environment variable)
```
The `(from ...)` clause matches the existing config-attribute annotation
style. Other auth types (PAT, M2M, OIDC, Azure, etc.) do not use the U2M
cache and the line is omitted entirely (no field in JSON either).
JSON output adds a `token_storage: { mode, location, source }` object
alongside `details`.
Implementation:
- `libs/auth/storage/mode.go`: `ResolveStorageModeWithSource` now
returns a typed `StorageSource` (`Default | Override | EnvVar | Config`)
instead of an opaque bool. `StorageSource.String()` produces user-facing
labels matching `config.Source.String()` style.
- `libs/auth/storage/cache.go`: only existing in-repo caller updated to
use `source.Explicit()`.
- `cmd/auth/describe.go`: new `tokenStorageInfo` struct +
`resolveTokenStorageInfo` helper. Templates conditionally render the new
line. Only resolves when `auth_type == "databricks-cli"`; resolver
errors are debug-logged and treated as "no info available" rather than
failing describe.
No probing of either backend at describe time. The describe command
already makes a live API call that validates the token works;
double-probing would add a 3-second hang on Linux without Secret Service
for no extra signal. Following up with a `--check-token` flag is a
separate change if there's appetite for it.
## Test plan
- [x] Unit tests for `StorageSource.String()` and `.Explicit()`
- [x] Updated `TestResolveStorageModeWithSource` for the new return type
- [x] New `TestResolveTokenStorageInfo` table test covering U2M+default,
U2M+env, and non-U2M
- [x] New `TestGetWorkspaceAuthStatus_U2M_PopulatesTokenStorage` and
`TestGetWorkspaceAuthStatus_NonU2M_OmitsTokenStorage`
- [x] New acceptance tests at
`acceptance/cmd/auth/describe/u2m-plaintext-default/` and
`u2m-plaintext-env/`
- [x] Existing PAT acceptance test (`default-profile/`) still passes
unchanged
- [x] Manual smoke: built CLI, ran describe with U2M+default,
U2M+secure-env, and PAT profiles. Output is correct in both text and
JSON.
- [x] `./task checks` and `./task lint-q` clean
Secure-storage acceptance tests are intentionally omitted: they would
actually query the OS keyring on macOS (potential prompt) or hit the 3s
timeout on Linux CI without Secret Service. Unit tests cover the secure
path on any platform.1 parent 1cf1f3b commit 8a8ff48
22 files changed
Lines changed: 482 additions & 58 deletions
File tree
- acceptance/cmd/auth/describe
- u2m-json-output
- u2m-plaintext-config
- u2m-plaintext-default
- u2m-plaintext-env
- cmd/auth
- libs/auth/storage
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments