Repository navigation
Commit 64e4c2d
Reject an invalid host in auth login and auth token (#7195)
## Changes
`databricks auth login` and `databricks auth token` reject a host that
is not an http(s) URL with a hostname,
e.g. `/`, `?o=123`, `https://` or `ftp://x.test`, with
`invalid host "<input>". Expected a URL like
https://<databricks-instance>.cloud.databricks.com`.
The check covers `--host`, the positional argument, profile hosts and
the host prompt, which shows the error
and asks again. `auth login` runs it before the keyring probe and the
profile name prompt.
Behavior changes:
- An empty host after "Enter a host URL manually" in the login profile
picker no longer starts discovery login.
- `auth login --skip-workspace --host '?a=123'` fails. On main this
started discovery login.
- Spaces around a host are trimmed, so `" https://x.test/?o=1 "` works
and keeps the workspace ID.
## Why
Follow-up to a review comment on #7179. An invalid host made login and
token resolve the host from
`DATABRICKS_HOST`, save a profile without a `host` key, connect to a
host named `https`, or fail later
with `host must start with 'https://': `.
## Tests
Unit tests cover host validation for each host source, the host prompt,
and the early rejection in browser,
device code and `--skip-workspace` login. New acceptance tests check the
error output of `auth login` and
`auth token`.
This pull request and its description were written by Isaac.
---------
Co-authored-by: Isaac <no-reply@databricks.com>1 parent 4b902e8 commit 64e4c2d
17 files changed
Lines changed: 326 additions & 47 deletions
File tree
- .nextchanges/cli
- acceptance/cmd/auth
- login/invalid-host
- token/invalid-host
- cmd/auth
- testdata
- TestPromptForHostRejectsEmptyHost
- TestPromptForHostRejectsHostEmptyAfterNormalization
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
54 | | - | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
56 | 66 | | |
| 67 | + | |
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
| |||
0 commit comments