The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
key info page internal viewer fix
yuneng-jiang3fcfe8322cec
diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsxindex 219c3cc515d..008b4cbe6ca 100644--- a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx@@ -1,8 +1,8 @@-import { render, waitFor, screen } from "@testing-library/react";-import { describe, expect, it, vi, beforeEach } from "vitest";+import useTeams from "@/app/(dashboard)/hooks/useTeams";+import { render, screen, waitFor } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";import { KeyResponse, Team } from "../key_team_helpers/key_list";import KeyInfoView from "./key_info_view";-import useTeams from "@/app/(dashboard)/hooks/useTeams";vi.mock("@/app/(dashboard)/hooks/useTeams", () => ({default: vi.fn(),@@ -255,4 +255,32 @@ describe("KeyInfoView", () => {expect(screen.queryByText("Delete Key")).not.toBeInTheDocument();});});++ it("should not allow Internal Viewer to modify key even if they own it", async () => {+ vi.mocked(useTeams).mockReturnValue({+ teams: [],+ setTeams: vi.fn(),+ });++ const ownerUserId = "internal-viewer-user-id";+ const keyData = { ...MOCK_KEY_DATA, user_id: ownerUserId };+ render(+ <KeyInfoView+ keyData={keyData}+ onClose={() => {}}+ keyId={"test-key-id"}+ onKeyDataUpdate={() => {}}+ accessToken={"test-token"}+ userID={ownerUserId}+ userRole={"Internal Viewer"}+ premiumUser={true}+ teams={[]}+ />,+ );++ await waitFor(() => {+ expect(screen.queryByText("Regenerate Key")).not.toBeInTheDocument();+ expect(screen.queryByText("Delete Key")).not.toBeInTheDocument();+ });+ });});diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsxindex 8b7f9e77879..d3028802ad5 100644--- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx@@ -302,6 +302,7 @@ export default function KeyInfoView({});return `${dateStr} at ${timeStr}`;};+ console.log("userRole", userRole);const canModifyKey =isProxyAdminRole(userRole || "") ||@@ -310,7 +311,7 @@ export default function KeyInfoView({teamsData?.filter((team) => team.team_id === currentKeyData.team_id)[0],userID || "",)) ||- userID === currentKeyData.user_id;+ (userID === currentKeyData.user_id && userRole !== "Internal Viewer");return (<div className="w-full h-screen p-4">