litellm/ui
Jason Cook 98741dff72 feat(chatgpt, github_copilot): OAuth sign-in + token refresh in proxy UI
Add "Sign in with ChatGPT" and "Sign in with GitHub Copilot" device-code
OAuth flows to the Add Credential modal. Tokens persist as encrypted JSON
in LiteLLM_CredentialsTable and are picked up at request time when a
model's api_key is set to "oauth:<credential_name>"; a DBAuthenticator
subclass reads from the in-memory credential cache (sync) and writes
refreshed tokens back via a fire-and-forget worker thread.

Per-row Refresh button rotates tokens on demand — ChatGPT via the IdP's
refresh_token grant, Copilot by re-deriving the short-lived API key from
the stored GitHub access token.

Also ships a litellm-chatgpt-login CLI with an optional PKCE+loopback
flow alongside the existing device-code path for local sign-in outside
the UI.

Provider-specific surface lives in new files under
litellm/llms/{chatgpt,github_copilot}/db_authenticator.py and
litellm/proxy/{chatgpt,copilot}_oauth_endpoints/. Shared-file delta is
~275 lines across 10 pre-existing files, the bulk being a pure append
at the end of networking.tsx.

Dispatch convention + operational caveats documented in the new
"ChatGPT / Copilot OAuth Credentials" section of CLAUDE.md.

Security:
 - /chatgpt/oauth/* and /copilot/oauth/* endpoints require PROXY_ADMIN
   (view-only admins excluded from write paths)
 - session_id query params are Query(...) annotated
 - session-cap check + slot reservation are atomic; reserved slot is
   cleaned up on device-code failure
 - PKCE loopback callback html.escape()s the IdP's error_description
   before rendering

Tests: 165 cases covering DBAuthenticator read/write, config dispatch,
endpoint admin-only, 429 cap, slot cleanup, background-worker success /
auth-failure / DB-persist-failure paths, PKCE helpers + XSS regression,
CLI broad-exception + KeyboardInterrupt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-16 20:30:10 -04:00
..
litellm-dashboard feat(chatgpt, github_copilot): OAuth sign-in + token refresh in proxy UI 2026-04-16 20:30:10 -04:00