Skip to content

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]

fix(ui): gate the keyless connect redirect on internal-user roles

Tin Chi Lo8929e09f4927
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx
index 6fb64333089..affcca401f2 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx
@@ -67,14 +67,15 @@ describe("dashboard landing keyless redirect", () => {
mockMigratedHref.mockClear();
});
- it("sends a keyless non-admin to the connect page after login", () => {
+ it.each(["Internal User", "Internal Viewer"])("sends a keyless %s to the connect page after login", (role) => {
+ state.userRole = role;
render(<CreateKeyPage />);
expect(mockReplace).toHaveBeenCalledWith("/mocked-ui/connect");
expect(screen.queryByTestId("api-keys-dashboard")).not.toBeInTheDocument();
});
- it("leaves an admin with no keys on the dashboard", () => {
- state.userRole = "Admin";
+ it.each(["Admin", "Admin Viewer", "Org Admin"])("leaves a keyless %s on the dashboard", (role) => {
+ state.userRole = role;
render(<CreateKeyPage />);
expect(mockReplace).not.toHaveBeenCalled();
expect(screen.getByTestId("api-keys-dashboard")).toBeInTheDocument();
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/page.tsx b/ui/litellm-dashboard/src/app/(dashboard)/page.tsx
index 883aff8b36b..682ba0bbcb2 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/page.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/page.tsx
@@ -4,7 +4,7 @@ import ApiKeysDashboard from "@/app/(dashboard)/api-keys/ApiKeysDashboard";
import LoadingScreen from "@/components/common_components/LoadingScreen";
import { proxyBaseUrl } from "@/components/networking";
import { useKeys } from "@/app/(dashboard)/hooks/keys/useKeys";
-import { isAdminRole } from "@/utils/roles";
+import { internalUserRoles } from "@/utils/roles";
import { useAuth } from "@/contexts/AuthContext";
import {
buildLoginUrlWithReturn,
@@ -93,7 +93,7 @@ function CreateKeyPageContent() {
const isPostLoginLanding = searchParams.get("login") === "success";
const isSignedIn = !authLoading && Boolean(token);
- const shouldCheckForKeys = isPostLoginLanding && isSignedIn && !isAdminRole(userRole);
+ const shouldCheckForKeys = isPostLoginLanding && isSignedIn && internalUserRoles.includes(userRole);
const { data: keysData, isLoading: keysLoading } = useKeys(1, 1, { userID }, shouldCheckForKeys);
const isKeylessLanding = shouldCheckForKeys && !keysLoading && keysData?.keys?.length === 0;
const isResolvingKeylessLanding = (shouldCheckForKeys && keysLoading) || isKeylessLanding;