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
{{ message }}
Repository navigation
Commit e7d21a2
Browse filesBrowse the repository at this point in the historyBrowse files
Split device code login into authorization and token exchange steps (#7217)
## Changes
A refactoring for the non-interactive device code login (#7220), with no
user-visible change.
`libs/auth/u2m` now provides the two steps of device code login instead
of the whole login. `PersistentAuth.NewDeviceCodeLogin(ctx)` checks that
the host supports device code login and fetches the OAuth endpoints
once, with the caller's context. Its `RequestDeviceAuthorization` and
`RequestDeviceAccessToken` methods make the two requests. A rejected
code matches `ErrInvalidConfirmationCode` or `ErrInvalidDeviceCode`, so
callers no longer compare the server's error description.
The confirmation code prompt and its retries move from
`DeviceCodeChallenge`, which is removed, to `auth login`, built on the
two steps. `auth login` adds the `token exchange:` prefix to the errors
it does not retry, so the login prints the same messages as before.
## Why
In the non-interactive login (#7220), one CLI invocation requests the
device authorization and a later one exchanges the device code, so the
two steps have to be callable separately.
## Tests
The `u2m` tests call the two steps instead of `DeviceCodeChallenge`.
They are edited in place, so the diff shows the changed calls and the
error messages without the `token exchange:` prefix. The retry tests
move out of `u2m` with the loop: the `device-code/nominal` and
`device-code/wrong-code` acceptance tests cover it and pass unchanged.
New `termtest` tests check the loop in `auth login`. One enters a wrong
confirmation code followed by the right one, three wrong codes, and a
wrong code followed by no input, and checks the number of token requests
for each. Another checks that a rate-limited token request and an
unknown device code each end the login after one token request, without
asking for the code again.
This pull request and its description were written by Isaac.
---------
Co-authored-by: Isaac <no-reply@databricks.com>
0 commit comments