Repository navigation
feat(cli): pre-fill the SSO verification code in the browser when the proxy allows it - #39428
Conversation
|
PR #39428 labeled |
Greptile SummaryThe PR updates standard CLI SSO login to honor the proxy’s optional prefill capability while retaining the configured CLI base URL.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/client/cli/commands/auth.py | Adds capability-gated verification-code prefill to the standard CLI SSO browser flow while preserving the legacy path when the field is absent. |
| tests/test_litellm/proxy/client/cli/test_auth_commands.py | Adds coverage for prefill behavior, configured-host preservation, legacy responses, and non-string capability values. |
| type-discipline-budget.json | Reduces several static-type violation budgets to reflect the improved TypedDict declarations. |
Reviews (3): Last reviewed commit: "chore: merge litellm_internal_staging an..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 62badd5. Configure here.
…get conflict Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
|
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8442fb2. Configure here.
TLDR
Problem this solves:
lite loginprints a verification code the user has to retype in the browserallow_cli_sso_verification_uri_complete)lite loginHow it solves it:
lite logintreatsverification_uri_completein the/sso/cli/startreply as the proxy's opt-in/sso/key/generatewithuser_codeadded, so the page comes pre-filled--base-urlthe user gave, never the proxy's absolute URLUser Flow
Before: a developer whose proxy has the pre-fill flag on still has to copy the code from the terminal into the browser
general_settings.allow_cli_sso_verification_uri_complete: trueand restarts the proxylite loginwithLITELLM_PROXY_URL=https://litellm-domainVerification code: ABCD-EFGHand opensGET https://litellm-domain/sso/key/generate?source=litellm-cli&key=cli-...in the browserABCD-EFGHout of the terminal, paste it into the box, and click ContinueLogin successful!After: the same login opens the page with the code already in the box, so they only confirm it
general_settings.allow_cli_sso_verification_uri_complete: trueand restarts the proxylite loginwithLITELLM_PROXY_URL=https://litellm-domainVerification code: ABCD-EFGH (pre-filled in the browser, check it matches)and opensGET https://litellm-domain/sso/key/generate?source=litellm-cli&key=cli-...&user_code=ABCD-EFGHin the browserABCD-EFGHalready in the boxLogin successful!With the flag off (the default), After is identical to Before: the URL carries no code and the page asks for it
Relevant issues
Linear ticket
Resolves LIT-6637
LIT-6636 (skip the code when the browser already holds an SSO session) is covered by
lite login --pkcesince v1.99.0, so it gets a docs pointer rather than a new mode: BerriAI/litellm-docs#1144Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: real Keycloak 26.3 as the OIDC IdP (realm
litellm, userdev), Postgres and Redis in docker, every proxy booted with--num_workers 2andlitellm_settings.cacheon Redis so the CLI login session is shared across both workers,EXPERIMENTAL_UI_LOGIN=True,GENERIC_*pointing at Keycloak, and this config:BROWSER=<script that logs the URL>makeslite loginwrite the URL it opens to a file instead of popping a window; that URL is then opened in a Playwright-driven Chromium, which signs in to Keycloak once and keeps that session for the rest.HOMEpoints at a scratch directory withLITELLM_CLI_DISABLE_KEYRING=1so each leg's credential lands in its owntoken.jsoninstead of the machine keychain. Same steps, same IdP, same realliteTUI in tmux in every leg; only the commit the proxy and CLI run from (and, for the last leg, the config) differsBefore (632898b, the merge base)
lite login, no flags) against the flag-on proxy booted from the merge base on port 38556GET /realms/litellm/protocol/openid-connect/auth?..., one sign-in) back tohttp://localhost:38556/sso/callback?..., which renders "Complete CLI Login" with "Enter the verification code shown in your terminal to finish this login." and an EMPTY "Verification code" box, even though the server flag is on. The user has to go back to the terminal, readUZ75-KS6S, and type it inUZ75-KS6Sand press Enter:POST http://localhost:38556/sso/cli/complete/cli-CMjl-s6aj2XyB17aLNTzOUCSFzjlxw3Wrenders "CLI Authentication Successful" and the terminal continuesAfter (62badd5; the tip 8442fb2 differs from it only by a staging merge that touches no CLI or SSO path)
user_code, and the terminal says the code is pre-filledhttp://localhost:39016/sso/callback?..., and the page now says "Confirm the verification code below to finish this login." withC62G-MCF5already in the box, matching the terminalPOST http://localhost:39016/sso/cli/complete/cli-eoKfSm1Mg3rKjEmP0V0EhiMOm0hfZQAxrenders "CLI Authentication Successful" and the terminal continuesFlag off (62badd5,
general_settingsblock removed)allow_cli_sso_verification_uri_complete). The URL and the terminal are byte-for-byte the pre-PR shape: nouser_code, no "(pre-filled ...)" hintFGF7-EUVF, press Enter,Login successful!andEXIT_CODE=0in the terminal, thenlite chat gpt-5.4-minianswerspongthrough this proxy as wellCaveats
lite login --pkceis unaffected; it never shows a codeVerdict: PASS
Type
🆕 New Feature
Caveats (if any)
Low
lite loginstarting and the browser hop, the page shows an empty box while the terminal still says pre-filled; typing the printed code completes the login as beforeFinal Attestation
Note
Low Risk
CLI-only SSO UX change with backward-compatible defaults; the verification code may appear in browser history when pre-fill is enabled.
Overview
lite loginnow honors the proxy’s optionalverification_uri_completefield from/sso/cli/start. When that value is a string, the CLI treats it as opt-in to browser pre-fill: it opens/sso/key/generatewithuser_codeon the query string (still using the user’s--base-url, not the proxy’s absolute URI) and tells the user the code is pre-filled and only needs to match.If the field is missing or not a string, behavior stays the same—no
user_codein the URL and the plain verification-code message.CliSsoStartDatagains the optional field withReadOnlytyping; tests cover both paths plus regressions on the default flow.Reviewed by Cursor Bugbot for commit 8442fb2. Bugbot is set up for automated code reviews on this repo. Configure here.