Skip to content

feat(proxy): app-scoped read access to Customer Management through object permissions - #52781

Merged
moe-berri merged 14 commits into
mainfrom
litellm_customer_portal_app_rbac
Nov 19, 2026
Merged

moe-berri merged 14 commits into
mainfrom
litellm_customer_portal_app_rbac

Conversation

@moe-berri

@moe-berri moe-berri commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Customer Management is proxy admin only today
  • An application owner cannot see their own app's spend
  • There is no way to give a non-admin access to specific apps

How it solves it:

  • Adds apps to object_permission, next to MCP servers and vector stores
  • A user's apps are the union of their own, their teams' and their organizations' grants
  • Grantees get read-only app and usage routes, locked to those apps
  • Only a proxy admin can change apps. Anyone else may resend the stored list unchanged, and keys never carry app grants
  • A grantee reads a customer member only when the app has a row for the member or their organization
  • Customer Management gets an Internal Access page where a proxy admin picks a team, a user or an organization and the apps it can view, and grantees see a read-only Apps page
  • The app routes authenticate at the router level, so an unauthenticated read is rejected before a database transaction opens

Intentional product change: non-admins no longer see Customer Management in the view switcher unless they hold an app grant. Before, they could open it and got an admin-only notice.

User Flow

Before

  1. A proxy admin creates an app for each team in Customer Management
  2. The owner of one app logs in as an internal user
  3. They open Customer Management and get an admin-only notice
  4. GET /management/v1/apps returns 403 for them

After

  1. A proxy admin opens Customer Management, goes to Internal Access, picks a team, a user or an organization, selects apps and saves, or calls /team/update, /user/update or /organization/update with object_permission.apps
  2. The owner logs in, and Customer Management appears in the view switcher
  3. The Apps page lists only their apps with spend and budget, with no edit controls
  4. GET /management/v1/apps returns only their apps, and another app's ID returns 403
  5. The customer usage routes return 200 with app_id set to a granted app, and 403 for another app or with no app_id

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Screenshots / Proof of Fix

Live run on a local proxy started as AGENTS.md describes (two workers, one dedicated Redis for router and coordination state, local Postgres) with the dashboard dev server pointed at it. UI and API checks ran at 104655de64, and revocation and the proxy admin regression ran after 983ddb2591 reloaded. The Internal Access page, the admin viewer sidebar and bulk user creation ran at ca7e71721e, and the user and organization tabs ran at d2eb0f2266. Before this PR the same grantee gets an admin-only notice and a 403 from GET /management/v1/apps.

A proxy admin opens Internal Access under Customer Management, picks a team, selects an app and saves. The grant is still selected after a reload, saving it kept the team's other object permission fields, and clearing it and saving removes it. The team edit form has no app field. An admin viewer with no grant sees none of the Customer Management links, and one with a grant sees only Applications. POST /management/v1/users/bulk as a proxy admin with object_permission.apps returned 200, and the created user's key read the granted app with 200 and another app with 403. On the User and Organization tabs a grant persisted after a reload and left the user's role unchanged, an organization member with no other grant saw the app only while the organization grant was present, and a user with a direct grant for one app and a team grant for another saw both. A save against a deleted team returned 404 and showed the inline error.

Internal Access user grant

A member of that team signs in, picks Customer Management in the view switcher and sees only the granted app, with no edit controls.

Grantee read-only Apps

A user with no grant has no Customer Management entry and gets the notice on /ui/apps. After the admin clears the team's grant, the former grantee is in the same state and gets 403 from the app routes.

No-grant notice

API results as the grantee: the list returns only the granted app, the other app returns 403, PATCH on the granted app returns 403, all four usage routes return 200 with the granted app_id and 403 with the other app or none, and an unknown member and a member outside the app both return 404 {"detail":"Customer member not found."}. /key/generate and /key/update with object_permission.apps return the app grant 403 and still accept other object permission fields.

API transcript (`api` runs fetch in the signed-in browser tab against the proxy, long responses cut)
PR 52781 live API transcript
Browser dashboard http://localhost:3000, proxy port 4000, two workers, Redis 6389.
API calls execute fetch in the currently authenticated Chrome tab through /tmp/qa52781-api.py.
No API responses were mocked. Credentials in responses are redacted.
Alpha = 052345c4-7cbe-47b1-a7a0-f866be7656e3
Beta = 3b5f92c3-b5e2-490b-87ca-8ff7154b0061
Commands are expanded from the exact recorded method/path/body arguments.
Primary three responses transcribed from shell output 1aca98. Others copied from captured stdout.


### Internal-user grantee before revocation

$ api GET /management/v1/apps
{"status":200,"response":[{"app_id":"052345c4-7cbe-47b1-a7a0-f866be7656e3","resource_type":"team","resource_id":"qa52781-alpha","alias":"QA Alpha App Team","spend":0,"budget_usage":[{"source":"window","budget_duration":"1mo","max_budget":100,"spend":0,"window_
$ api GET /management/v1/apps/3b5f92c3-b5e2-490b-87ca-8ff7154b0061
{"status":403,"response":{"detail":"Forbidden."}}
$ api PATCH /management/v1/apps/052345c4-7cbe-47b1-a7a0-f866be7656e3 '{"allow_new_customers":false}'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}

### Internal-user grantee usage and privacy matrix

$ api GET '/management/v1/customer_organizations/daily/activity/aggregated?start_date=2026-11-01&end_date=2026-11-19&customer_org_ids=qa52781-customer&app_id=052345c4-7cbe-47b1-a7a0-f866be7656e3'
{"status":200,"response":{"results":[],"metadata":{"total_spend":0,"total_flat_cost":0,"total_ptu_hours":0,"total_prompt_tokens":0,"total_completion_tokens":0,"total_tokens":0,"total_api_requests":0,"total_successful_requests":0,"total_failed_requests":0,"tota
$ api GET '/management/v1/customer_organizations/daily/activity/aggregated?start_date=2026-11-01&end_date=2026-11-19&customer_org_ids=qa52781-customer&app_id=3b5f92c3-b5e2-490b-87ca-8ff7154b0061'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_organizations/daily/activity/aggregated?start_date=2026-11-01&end_date=2026-11-19&customer_org_ids=qa52781-customer'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_organizations/daily/activity?start_date=2026-11-01&end_date=2026-11-19&app_id=052345c4-7cbe-47b1-a7a0-f866be7656e3'
{"status":200,"response":{"results":[],"metadata":{"total_spend":0,"total_flat_cost":0,"total_ptu_hours":0,"total_prompt_tokens":0,"total_completion_tokens":0,"total_tokens":0,"total_api_requests":0,"total_successful_requests":0,"total_failed_requests":0,"tota
$ api GET '/management/v1/customer_organizations/daily/activity?start_date=2026-11-01&end_date=2026-11-19&app_id=3b5f92c3-b5e2-490b-87ca-8ff7154b0061'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_organizations/daily/activity?start_date=2026-11-01&end_date=2026-11-19'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_teams/daily/activity?start_date=2026-11-01&end_date=2026-11-19&app_id=052345c4-7cbe-47b1-a7a0-f866be7656e3'
{"status":200,"response":{"results":[],"metadata":{"total_spend":0,"total_flat_cost":0,"total_ptu_hours":0,"total_prompt_tokens":0,"total_completion_tokens":0,"total_tokens":0,"total_api_requests":0,"total_successful_requests":0,"total_failed_requests":0,"tota
$ api GET '/management/v1/customer_teams/daily/activity?start_date=2026-11-01&end_date=2026-11-19&app_id=3b5f92c3-b5e2-490b-87ca-8ff7154b0061'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_teams/daily/activity?start_date=2026-11-01&end_date=2026-11-19'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_members/daily/activity?start_date=2026-11-01&end_date=2026-11-19&app_id=052345c4-7cbe-47b1-a7a0-f866be7656e3'
{"status":200,"response":{"results":[],"metadata":{"total_spend":0,"total_flat_cost":0,"total_ptu_hours":0,"total_prompt_tokens":0,"total_completion_tokens":0,"total_tokens":0,"total_api_requests":0,"total_successful_requests":0,"total_failed_requests":0,"tota
$ api GET '/management/v1/customer_members/daily/activity?start_date=2026-11-01&end_date=2026-11-19&app_id=3b5f92c3-b5e2-490b-87ca-8ff7154b0061'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET '/management/v1/customer_members/daily/activity?start_date=2026-11-01&end_date=2026-11-19'
{"status":403,"response":{"type":"urn:litellm:error:customer-hierarchy-forbidden","title":"Forbidden","status":403,"detail":"Only proxy admins can manage customer hierarchies."}}
$ api GET /management/v1/apps/052345c4-7cbe-47b1-a7a0-f866be7656e3/customer_members/qa52781-unknown
{"status":404,"response":{"detail":"Customer member not found."}}
$ api GET /management/v1/apps/052345c4-7cbe-47b1-a7a0-f866be7656e3/customer_members/qa52781-outsider
{"status":404,"response":{"detail":"Customer member not found."}}

### Team administrator, default edit setting disabled

$ api POST /team/update '{"team_id":"qa52781-alpha","object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3","3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":403,"response":{"error":{"message":"Team admins on this proxy cannot edit team settings. Ask a proxy admin to enable fields under Settings > UI > Team admin editable fields.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /team/update '{"team_id":"qa52781-alpha","team_alias":"QA Alpha App Team","metadata":{"qa_unchanged_apps":true},"object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3"]}}'
{"status":403,"response":{"error":{"message":"Team admins on this proxy cannot edit team settings. Ask a proxy admin to enable fields under Settings > UI > Team admin editable fields.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /key/generate '{"user_id":"qa52781-teamadmin","team_id":"qa52781-alpha","key_alias":"qa-app-permissions","object_permission":{"vector_stores":[]}}'
{"status":200,"response":{"key_alias":"qa-app-permissions","duration":null,"models":[],"spend":0,"max_budget":null,"user_id":"qa52781-teamadmin","team_id":"qa52781-alpha","agent_id":null,"max_parallel_requests":null,"metadata":{},"tpm_limit":null,"rpm_limit":n
$ api POST /key/update '{"key":"$OWN_KEY","object_permission":{"apps":["3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":403,"response":{"error":{"message":"{'error': 'Only a proxy admin can change access to customer management apps.'}","type":"auth_error","param":null,"code":"403"}}}
$ api POST /key/update '{"key":"$OWN_KEY","object_permission":{"vector_stores":[]}}'
{"status":200,"response":{"key":"[redacted]","key_id":"14ae4aca-a14d-4140-90b2-5dc708353da0","token":"[redacted]","key_name":"sk-...a6rA","key_alias":"qa-app-permissions","soft_budget_cooldown":false,"spend":0,"total_spend":0,"expires":null,"models":[],"aliase
$ api POST /key/generate '{"user_id":"qa52781-teamadmin","team_id":"qa52781-alpha","object_permission":{"apps":["3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":403,"response":{"error":{"message":"{'error': 'Only a proxy admin can change access to customer management apps.'}","type":"auth_error","param":null,"code":"403"}}}

### Team administrator, editable fields metadata only

$ api POST /team/update '{"team_id":"qa52781-alpha","object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3","3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":403,"response":{"error":{"message":"Team admins on this proxy do not have permission to update 'object_permission'. Ask a proxy admin to add it under Settings > UI > Team admin editable fields.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /team/update '{"team_id":"qa52781-alpha","metadata":{"qa_unchanged_apps":true},"object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3"]}}'
{"status":403,"response":{"error":{"message":"Team metadata key 'allowed_passthrough_routes' is a proxy setting that team admins cannot add, change or remove in team settings. Ask a proxy admin to change it.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /team/update '{"team_id":"qa52781-alpha","metadata":{"qa_unchanged_apps":true}}'
{"status":403,"response":{"error":{"message":"Team metadata key 'allowed_passthrough_routes' is a proxy setting that team admins cannot add, change or remove in team settings. Ask a proxy admin to change it.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /user/update '{"user_id":"qa52781-teamadmin","object_permission":{"apps":["3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":401,"response":{"error":{"message":"Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/user/update. Your role=internal_user. Your user_id=qa5278*********in","type":"auth_error","param"
$ api POST /team/update '{"team_id":"qa52781-alpha","metadata":{"guardrails":[],"model_rpm_limit":{},"model_tpm_limit":{},"disable_global_guardrails":false,"allowed_passthrough_routes":[],"opted_out_global_guardrails":[],"soft_budget_alerting_emails":[],"qa_un
{"status":403,"response":{"error":{"message":"Team admins on this proxy do not have permission to update 'object_permission'. Ask a proxy admin to add it under Settings > UI > Team admin editable fields.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /team/update '{"team_id":"qa52781-alpha","metadata":{"guardrails":[],"model_rpm_limit":{},"model_tpm_limit":{},"disable_global_guardrails":false,"allowed_passthrough_routes":[],"opted_out_global_guardrails":[],"soft_budget_alerting_emails":[],"qa_un
{"status":200,"response":{"team_id":"qa52781-alpha","data":{"team_id":"qa52781-alpha","team_alias":"QA Alpha App Team","organization_id":null,"object_permission_id":"aa241244-20b5-4a01-aade-761e7b401d2c","admins":[],"members":[],"members_with_roles":[{"role":"

### Team administrator, editable fields metadata and object_permission

$ api POST /team/update '{"team_id":"qa52781-alpha","metadata":{"guardrails":[],"model_rpm_limit":{},"model_tpm_limit":{},"disable_global_guardrails":false,"allowed_passthrough_routes":[],"opted_out_global_guardrails":[],"soft_budget_alerting_emails":[],"qa_un
{"status":403,"response":{"error":{"message":"Team admins on this proxy do not have permission to update 'object_permission'. Ask a proxy admin to add it under Settings > UI > Team admin editable fields.","type":"auth_error","param":null,"code":"403"}}}
$ api POST /team/update '{"team_id":"qa52781-alpha","object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3","3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":403,"response":{"error":{"message":"Team admins on this proxy do not have permission to update 'object_permission'. Ask a proxy admin to add it under Settings > UI > Team admin editable fields.","type":"auth_error","param":null,"code":"403"}}}
06:15:25 - LiteLLM Proxy:WARNING: team_admin_field_permissions.py:185 - team_admin_editable_team_fields ignores unsupported field(s) ['object_permission']; supported: ['create_member_keys', 'max_budget', 'member_key_budgets', 'metadata', 'projects', 'raise_max
06:15:25 - LiteLLM Proxy:WARNING: team_admin_field_permissions.py:185 - team_admin_editable_team_fields ignores unsupported field(s) ['object_permission']; supported: ['create_member_keys', 'max_budget', 'member_key_budgets', 'metadata', 'projects', 'raise_max

### Organization administrator membership, v2 route

$ api PATCH /v2/organization/qa52781-org '{"object_permission":null}'
{"status":401,"response":{"error":{"message":"Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/v2/organization/qa52781-org. Your role=internal_user. Your user_id=qa5278********in","type":"auth
$ api PATCH /v2/organization/qa52781-org '{"object_permission":{"apps":["3b5f92c3-b5e2-490b-87ca-8ff7154b0061"]}}'
{"status":401,"response":{"error":{"message":"Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/v2/organization/qa52781-org. Your role=internal_user. Your user_id=qa5278********in","type":"auth
$ api PATCH /v2/organization/qa52781-org '{"organization_alias":"QA Granted Organization","object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3"]}}'
{"status":401,"response":{"error":{"message":"Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/v2/organization/qa52781-org. Your role=internal_user. Your user_id=qa5278********in","type":"auth

### Organization administrator membership, legacy route

$ api PATCH /organization/update '{"organization_id":"qa52781-org","object_permission":null}'
{"status":401,"response":{"error":{"message":"Authentication Error, Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/organization/update. Your role=internal_user. Your user_id=qa5278********in","type":"auth_error",

### Proxy administrator

$ api POST /user/update '{"user_id":"qa52781-orgadmin","user_role":"org_admin"}'
{"status":422,"response":{"detail":[{"type":"literal_error","loc":["body","user_role"],"msg":"Input should be <LitellmUserRoles.PROXY_ADMIN: 'proxy_admin'>, <LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY: 'proxy_admin_viewer'>, <LitellmUserRoles.INTERNAL_USER: 'inter
$ api GET /management/v1/apps/052345c4-7cbe-47b1-a7a0-f866be7656e3/customer_members/qa52781-outsider
{"status":200,"response":{"app_id":"052345c4-7cbe-47b1-a7a0-f866be7656e3","customer_member_id":"qa52781-outsider","spend":0,"budget_usage":[],"spend_reset_window":null,"budget_override_id":null,"effective_budget":null,"budget_source":"none"}}
$ api POST /key/generate '{"user_id":"default_user_id","object_permission":{"apps":["052345c4-7cbe-47b1-a7a0-f866be7656e3"]}}'
{"status":403,"response":{"error":{"message":"{'error': 'Only a proxy admin can change access to customer management apps.'}","type":"auth_error","param":null,"code":"403"}}}

### Former grantee after admin UI revocation

$ api GET /management/v1/apps
{"status":403,"response":{"detail":"Forbidden."}}
$ api GET /management/v1/apps/3b5f92c3-b5e2-490b-87ca-8ff7154b0061
{"status":403,"response":{"detail":"Forbidden."}}
$ api GET /management/v1/apps/052345c4-7cbe-47b1-a7a0-f866be7656e3
{"status":403,"response":{"detail":"Forbidden."}}

Not reached live: a team admin and an organization admin are stopped by existing outer gates before the app grant check (team_admin_editable_team_fields does not support object_permission, and the organization update routes returned 401 for a non proxy admin), so the unchanged-versus-changed grant comparison and the null clear are covered by unit tests only. The retry state for a failed grant read is also unit tested only. Usage responses had no spend rows, so the live run proves status codes and not row isolation.

Mutations run against tests/unit/proxy/management_endpoints/management_v1/test_apps.py and test_customer_usage.py, each reverted afterwards. Dropping team grants from granted_app_ids fails 4 tests. Removing the per-app check in readable fails 3. Letting a grantee read usage with no app_id fails 20.

How to rerun (proxy command, config, dashboard and client helper)

Proxy, from the repo root at the commit under test, with DATABASE_URL pointing at a local Postgres and a Redis on port 6389.

LITELLM_MASTER_KEY=<key> UI_USERNAME=admin UI_PASSWORD=<password> PROXY_BASE_URL=http://localhost:3000 \
  .venv/bin/python litellm/proxy/proxy_cli.py --config /tmp/52781-config.yaml --num_workers 2 --detailed_debug --reload --use_v2_migration_resolver

/tmp/52781-config.yaml with secrets removed.

general_settings:
  team_admin_editable_team_fields:
  - metadata
  - object_permission
  coordination_redis:
    host: 127.0.0.1
    port: 6389
litellm_settings:
  callbacks:
  - code_interpreter_interception
  code_interpreter_interception_params:
    enabled: true
    sandbox_tool_name: e2b_sandbox
  drop_params: true
model_list:
- litellm_params:
    model: anthropic/claude-haiku-4-5
  model_name: anthropic-haiku-4-5
- litellm_params:
    model: anthropic/claude-sonnet-4-5
  model_name: anthropic-sonnet-4-5
- litellm_params:
    model: anthropic/claude-opus-4-5
  model_name: anthropic-opus-4-5
- litellm_params:
    model: anthropic/claude-sonnet-4-6
  model_name: anthropic-sonnet-4-6
- litellm_params:
    model: anthropic/claude-opus-4-6
  model_name: anthropic-opus-4-6
- litellm_params:
    model: anthropic/claude-opus-4-7
  model_name: anthropic-opus-4-7
- litellm_params:
    model: anthropic/claude-opus-4-8
  model_name: anthropic-opus-4-8
- litellm_params:
    model: anthropic/claude-sonnet-5
  model_name: anthropic-sonnet-5
- litellm_params:

Dashboard, from litellm/ui/litellm-dashboard.

NEXT_PUBLIC_USE_REWRITES=true LENS_DEV_PROXY_URL=http://127.0.0.1:4000 npm run dev

Client helper used for every API line in the transcripts. It runs fetch inside the signed-in browser tab.

import json
import sys
import urllib.request
import websocket

tabs = json.load(urllib.request.urlopen("http://127.0.0.1:29229/json"))
tab = next(t for t in tabs if t["type"] == "page" and "localhost:3000" in t["url"])
ws = websocket.create_connection(tab["webSocketDebuggerUrl"], suppress_origin=True)
method, path = sys.argv[1:3]
body = json.loads(sys.argv[3]) if len(sys.argv) > 3 else None
expression = """
(async () => {
  const token = decodeURIComponent(document.cookie.split('; ').find(x => x.startsWith('token=')).slice(6));
  const key = AUTH_KEY;
  const response = await fetch(PATH, {
    method: METHOD,
    headers: {Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', Accept: 'application/json'},
    body: BODY === null ? undefined : JSON.stringify(BODY)
  });
  const data = await response.json();
  if (PATH === '/key/generate' && response.ok) window.qaOwnKey = data.key;
  if (PATH === '/management/v1/users/bulk' && response.ok) window.qaBulkKey = data.data?.find(row => row.key)?.key;
  return JSON.stringify({status: response.status, response: data}, (k,v) => ['key','token','password'].includes(k) ? '[redacted]' : v);
})()
""".replace("PATH", json.dumps(path)).replace("METHOD", json.dumps(method)).replace("BODY", json.dumps(body))
expression = expression.replace("AUTH_KEY", "window.qaBulkKey" if len(sys.argv) > 4 and sys.argv[4] == "bulk" else "JSON.parse(atob(token.split('.')[1])).key")
if body and body.get("key") == "$OWN_KEY":
    expression = expression.replace('"$OWN_KEY"', "window.qaOwnKey")
ws.send(json.dumps({"id": 1, "method": "Runtime.evaluate", "params": {"expression": expression, "awaitPromise": True, "returnByValue": True}}))
while True:
    result = json.loads(ws.recv())
    if result.get("id") == 1:
        if "exceptionDetails" in result.get("result", {}):
            raise RuntimeError(result["result"]["exceptionDetails"])
        print(json.dumps({"method": method, "path": path, "body": body}))
        print(result["result"]["result"]["value"])
        break

The before behavior was not rerun live at the merge base 89e0f3b771. There the app and usage routes are proxy admin only in code, and object_permission has no apps field.

Type

🆕 New Feature

Caveats (if any)

Medium

  • The gateway is hidden in the dashboard only. A grantee's role still allows the gateway APIs it allowed before.
  • A grantee must pass app_id on the usage routes. There is no "all my apps" rollup yet.

Low

  • An admin viewer needs a grant like any other user. Without one they see no Customer Management links.
  • Live QA could not reach the per-row app grant denial in bulk user creation as a non-admin, because the route returns 401 for internal users and team admins before row handling. A unit test covers it.
  • The customer hierarchy routes (customer organizations, teams and members outside an app) stay proxy admin only.
  • uv sync on a machine with DATABASE_URL set needs SQLX_OFFLINE=true to build the Rust extension. This PR does not change that.
Details

Link to Devin session: https://app.devin.ai/sessions/aa7be44c847d4b629234d42cc84a4eb0
Open in Devin Desktop: https://app.devin.ai/desktop/session/aa7be44c847d4b629234d42cc84a4eb0?variant=devin
Requested by: @moe-berri

Migration 20261119000000_object_permission_apps adds one TEXT[] column with an empty default and rewrites no rows.


Note

High Risk
Introduces authorization on object permissions and management v1 routes; misconfiguration could expose app or usage data or block legitimate admin viewers without grants.

Overview
Adds an apps grant on object_permission (schema migration + types), so Customer Management visibility is no longer all-or-nothing for proxy admins.

Backend: New granted_app_ids / AppAccess resolve the union of apps from a user's own, team, and organization object permissions. /management/v1/apps and customer usage routes are scoped to those apps for non-admins (reads allowed; mutating app/customer routes stay admin-only). can_grant_apps gates who may set or clear object_permission.apps on user/team/org create and update flows; non-admins get 403 if they change app grants or unlink a permission that had apps.

Dashboard: Proxy admins get Internal Access (/customers/access) to assign apps to teams, users, or organizations. Grantees see a read-only Apps list, Customer Management in the view switcher only when they have grants, and nav hides admin Customer Management links for admin viewers without grants.

Reviewed by Cursor Bugbot for commit d2eb0f2. Bugbot is set up for automated code reviews on this repo. Configure here.

moe-berri and others added 5 commits November 19, 2026 05:21
…_permission.apps

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…admins

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… apps

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@moe-berri
moe-berri requested a review from a team November 19, 2026 05:44
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@veria-ai

veria-ai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 4 · PR risk: 0/10

Reviews

@moe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@moe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] The PR expands Customer Management reads from proxy admins to users with app-specific grants.

The code changes appear ready, but the earlier requirement for rerunnable live proof must be completed before merging.

Findings

  1. P2 Live grant proof is missing. ▶

Summary

Adds app-scoped, read-only Customer Management access through grants on users, teams and organizations.

  • Proxy admins can grant Customer Management apps through object permissions.
  • App and customer-member reads are limited to the caller’s granted apps.
  • Customer usage reads require a granted app for non-admin callers.
  • Proxy admins can choose apps for a team, user, or organization in Internal Access.
  • Grantees see their apps in a read-only Customer Management view.

No new actionable issues were found in the latest changes.

Reviews (4) · Last reviewed commit: "feat(ui): grant apps to users and organi..." · Reviewed by Greptile

Comment thread litellm/types/object_permission.py Resolved
Comment on lines +22 to +23
const apps = useQuery({ queryKey: ["apps", "access-selector"], queryFn: () => loadApps(), enabled: !disabled });
const options = (apps.data ?? []).map((app) => ({ label: `${app.alias} (${app.app_id})`, value: app.app_id }));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Live grant proof is missing. AGENTS.md requires live proof for new access checks and saved data, plus screenshots for UI flows. The description explicitly says neither exists. Add rerunnable before/after proof at 617445620ede5142a4112b10e284f380c5b86e3a, covering grant, scoped reads, denied writes, revocation and the dashboard.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, live proof is not there yet. A recorded run on a real proxy at the current tip is next and goes in the description.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

moe-berri and others added 4 commits November 19, 2026 06:01
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@moe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai @veria-ai

@moe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread litellm/proxy/_types.py Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

moe-berri and others added 3 commits November 19, 2026 07:11
…er write stored app grants back for non-admins

Non-admin object permission edits no longer include apps in the upsert record, so a stale read cannot restore a revoked grant. The sidebar hides admin-only Customer Management pages from admin viewers.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…er Management

The team form no longer carries the apps picker. A proxy admin picks a team on the new page and chooses the applications its members can view.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

@greptileai

1 similar comment
@moe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@moe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Internal Access now picks a team, a user or an organization. A failed save shows an error next to the button.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

@greptileai

@moe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai @veria-ai

@moe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 d2eb0f2. Configure here.

The app router authenticates at the router level again, so an unauthenticated read is rejected before a database transaction opens.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@moe-berri
moe-berri merged commit 05ffde5 into main Nov 19, 2026
69 of 71 checks passed
@moe-berri
moe-berri deleted the litellm_customer_portal_app_rbac branch November 19, 2026 18:43
yuneng-berri added a commit that referenced this pull request Nov 19, 2026
…er file (#52921)

With provider_endpoints_support.json regenerated, code-quality on main
stops at the next two checks:

- check_workflow_job_name_collisions: test-merge-smoke.yml and
  test-unit.yml both publish a `rust-bridge` check run. The smoke job is
  now named smoke-rust-bridge; nothing reads that check by name.
- check_unbounded_in_lists: the app_ids "in" filter #52781 added to
  AppStore.list had no written bound. It pages with skip/take, so it is
  marked bounded-ok (the apps granted to one caller) instead of chunked.
yuneng-berri added a commit that referenced this pull request Nov 19, 2026
…ble (#52909)

20261119000000_app_association_base_budgets added columns and foreign
keys without IF NOT EXISTS or DO $$ guards, which the migration DDL
tests reject. No release carries it yet, so it is edited in place.

Also pins the new object_permission.apps field in the customer endpoint
response bodies, which #52781 added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants