litellm/ui/litellm-dashboard/src/utils
Tin Chi Lo 516953b073 feat(ui): let team admins create auto-routers; authorize models by team, not created_by
The Auto-Routers tab was proxy-admin only, while Add Model on the same page already
admits team admins. The asymmetry was not a policy decision; the auto-router create form
simply never mounted a team selector, so a team admin's submit was unscoped and POST
/model/new rejects an unscoped create from any non-proxy-admin. Mounting the shared
TeamDropdown closes it, and the tab now takes the same audience as its sibling.

Fixing that surfaced a second, larger problem. The dashboard decided who may edit or
delete a deployment with `(userRole === "Admin" || created_by === userID) && db_model`,
but `created_by` is written at creation and never read by any backend auth check. The API
authorizes on team-admin membership of model_info.team_id, so the dashboard was wrong in
both directions: it hid controls from team admins the API accepts, and offered them to
former team admins the API rejects. Verified against a live proxy; a model created by the
proxy admin was PATCHed and DELETEd 200 by a team admin who did not create it, while the
same key got 403 on another team's row and on an unscoped row.

Both questions now have one owner in utils/modelPermissions.ts, deliberately shaped as a
mirror of ModelManagementAuthChecks. Creation returns a tagged union rather than a pair of
booleans, so "may not create" and "may create unscoped" cannot be confused, and the five
places that had each invented their own spelling (the models page, the auto-routers tab
and panel, the auto-router form, and both branches of AddModelForm) call it instead.

Row affordances are now per row rather than per tab, because opening the tab to team
admins puts routers they cannot act on in the same list.

Note for reviewers: collapsing AddModelForm onto the shared owner changes behaviour for
org_admin and Admin Viewer who also admin a team. They previously got the optional team
selector, because all_admin_roles counts them as admins, and could submit an unscoped
create that the API always 403s; they now get the required selector.

Also corrects stale copy left by the auto-router move. The exclude_auto_routers API
description named a dashboard page, which went stale inside a single PR; it now describes
the concept so it cannot drift with the UI again.

The eslint-suppressions prune includes one entry for caching/_components/cache_dashboard.tsx,
which this branch does not touch. Its baseline was already stale; the gate measures the whole
tree, so it could not be left behind.
2026-07-30 00:18:45 -07:00
..
budgetUtils.ts Show absolute date in Budget Reset column 2026-04-23 15:57:22 -07:00
cookieUtils.test.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
cookieUtils.ts fix(ui): break logout redirect loop across origins (#29360) 2026-05-30 19:02:29 -07:00
dataUtils.test.ts Usage Entity labels 2025-12-12 12:13:51 -08:00
dataUtils.ts Usage Entity labels 2025-12-12 12:13:51 -08:00
debounceConstants.ts refactor(ui): standardize debounce waits behind shared DEBOUNCE_WAIT_MS constant (#33040) 2026-07-13 12:19:57 -07:00
entityLinks.ts feat(ui): link organization teams to their team detail pages (#35120) 2026-07-29 17:20:59 -07:00
errorPatterns.ts added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
errorUtils.test.ts Add unit tests for 5 previously untested UI dashboard files 2026-03-16 12:53:20 -07:00
errorUtils.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
jwtUtils.test.ts useAuthorized refactor 2026-02-04 16:37:45 -08:00
jwtUtils.ts useAuthorized refactor 2026-02-04 16:37:45 -08:00
keyExpiryUtils.test.ts fix(ui): require new expiration when regenerating an expired key (#29838) 2026-06-06 09:18:19 -07:00
keyExpiryUtils.ts fix(ui): require new expiration when regenerating an expired key (#29838) 2026-06-06 09:18:19 -07:00
keyUpdateUtils.test.ts Key Max Budget Removal Error Fix 2025-10-17 12:04:58 -07:00
keyUpdateUtils.ts Key Max Budget Removal Error Fix 2025-10-17 12:04:58 -07:00
licenseUtils.test.ts feat(ui): show exact license expiration date in usage cards 2026-07-15 16:52:21 -07:00
licenseUtils.ts feat(ui): show exact license expiration date in usage cards 2026-07-15 16:52:21 -07:00
localStorageUtils.test.ts feat: hide new badges 2025-12-31 10:42:34 -08:00
localStorageUtils.ts feat: hide new badges 2025-12-31 10:42:34 -08:00
maskedSecretUtils.ts fix(ui): stop credential edit from persisting the masked api key (#33797) 2026-07-17 18:25:24 -07:00
mcpHeaderUtils.test.ts feat(mcp): Add tool call and tool list support via UI for Oauth mcps (#28454) 2026-05-22 09:04:04 -07:00
mcpHeaderUtils.ts fix(mcp): load MCP tool configuration tools via the OBO/passthrough-aware GET path (#29960) 2026-06-08 19:58:51 -07:00
mcpTokenStore.test.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
mcpTokenStore.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
mcpToolCrudClassification.test.ts Add unit tests for 5 previously untested UI dashboard files 2026-03-16 12:53:20 -07:00
mcpToolCrudClassification.ts feat(ui): group MCP tools by CRUD risk category in allowlist panels (#23403) 2026-03-11 21:15:25 -07:00
migratedPages.test.ts feat(ui): migrate api-keys landing to App Router path route (#30699) 2026-06-18 17:38:07 -07:00
migratedPages.ts feat(spend): track prompt compression saved tokens in daily spend aggregates (#33810) 2026-07-18 17:47:54 -07:00
modelPermissions.test.ts feat(ui): let team admins create auto-routers; authorize models by team, not created_by 2026-07-30 00:18:45 -07:00
modelPermissions.ts feat(ui): let team admins create auto-routers; authorize models by team, not created_by 2026-07-30 00:18:45 -07:00
pkce.ts Extract shared PKCE helpers into src/utils/pkce.ts 2026-04-16 10:35:52 -07:00
proxyUtils.test.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
proxyUtils.ts added and ran prettier autoformatter 2025-10-04 18:19:48 -07:00
returnUrlUtils.test.ts fix(ui): navigate to /ui/login/ with trailing slash via hard navigation (#33561) 2026-07-16 12:18:55 -07:00
returnUrlUtils.ts fix(ui): navigate to /ui/login/ with trailing slash via hard navigation (#33561) 2026-07-16 12:18:55 -07:00
roles.test.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
roles.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
secureStorage.ts style(ui): run prettier --write across the dashboard (#29622) 2026-06-04 11:37:54 -07:00
tabRoutes.test.ts refactor(ui): extract shared tab-routing helpers and adopt them in Models + Endpoints (#34435) 2026-07-23 16:36:25 -07:00
tabRoutes.ts refactor(ui): extract shared tab-routing helpers and adopt them in Models + Endpoints (#34435) 2026-07-23 16:36:25 -07:00
teamUtils.test.ts Deprecate useTeam in favor of react query 2025-12-23 20:15:42 -08:00
teamUtils.ts Deprecate useTeam in favor of react query 2025-12-23 20:15:42 -08:00
textUtils.test.ts Adding unit testing coverage 2026-01-03 17:25:46 -08:00
textUtils.ts [Feature] UI - Add LiteLLM Params to Edit Model (#16496) 2025-11-11 18:52:11 -08:00