Repository navigation
Commit bd296af
feat(llm-gateway): sign in with the OAuth device authorization grant (#145)
* feat(llm-gateway): sign in with the OAuth device authorization grant
Headless daemons have no browser to complete the loopback redirect used
for LLM gateway OIDC sign-in. Add an opt-in `deviceAuthorization` flag to
`llmGateway.authentication` (type `oidc`). When set, the daemon signs in
with RFC 8628: it logs a verification URL and user code, polls the token
endpoint in the background, and stores the tokens once the user approves
from any device.
- `agentdesktop-headless login` / `POST /v1/llm-gateway/login` start or
resume a sign-in and print the URL and code.
- The credential endpoint never blocks in device mode: it returns 401
with the login command and any pending code when no valid or
refreshable token exists. Refresh works as before.
- Subscription auth requires a browser and is rejected in combination.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(llm-gateway): address device authorization review feedback
- Start the device sign-in from managed policy. The startup path only sees the
local config file, so a `deviceAuthorization: true` delivered by the controller
never started a grant and credentials returned a 401 with no pending URL until
someone ran `login`. The cached controller configuration at startup and every
controller update now call `start_device_login_if_configured`, which is
idempotent because `device_login` returns the pending grant.
- Stop holding the global login lock across the identity provider round-trip. A
per-account lock serialises starting a grant instead, so concurrent `login`
calls still share one grant, and the provider request is bounded by a timeout
so a stalled provider cannot wedge every `login` behind it.
- Validate the device-authorization response (codes, verification URLs, nonzero
lifetime) and cap the lifetime and poll interval, so a malformed response
cannot publish an unusable status or overflow `Instant + Duration` in the poll
task.
- Never sleep past the expiry deadline while polling.
Co-Authored-By: Claude Code <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 7171618 commit bd296af
11 files changed
Lines changed: 872 additions & 40 deletions
File tree
- crates
- agent/src
- client/src
- core/src
- schema
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| 277 | + | |
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
| |||
297 | 299 | | |
298 | 300 | | |
299 | 301 | | |
| 302 | + | |
300 | 303 | | |
301 | 304 | | |
302 | 305 | | |
| |||
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
313 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
314 | 324 | | |
315 | 325 | | |
316 | 326 | | |
| |||
325 | 335 | | |
326 | 336 | | |
327 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
328 | 370 | | |
329 | 371 | | |
330 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
78 | 95 | | |
79 | 96 | | |
80 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
| |||
755 | 761 | | |
756 | 762 | | |
757 | 763 | | |
| 764 | + | |
758 | 765 | | |
759 | 766 | | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
760 | 781 | | |
761 | 782 | | |
762 | 783 | | |
| |||
777 | 798 | | |
778 | 799 | | |
779 | 800 | | |
| 801 | + | |
780 | 802 | | |
781 | 803 | | |
782 | 804 | | |
| |||
0 commit comments