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]

only show create key / actions for users with write access

Ishaan Jaff6096f3aa9f93
diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsx
index 0ec06348e81..205d4226dc2 100644
--- a/ui/litellm-dashboard/src/components/create_key_button.tsx
+++ b/ui/litellm-dashboard/src/components/create_key_button.tsx
@@ -39,6 +39,9 @@ import { InfoCircleOutlined } from '@ant-design/icons';
import { Tooltip } from 'antd';
import Createuser from "./create_user_button";
import debounce from 'lodash/debounce';
+import { rolesWithWriteAccess } from '../utils/roles';
+
+
const { Option } = Select;
@@ -335,9 +338,11 @@ const CreateKey: React.FC<CreateKeyProps> = ({
return (
<div>
- <Button className="mx-auto" onClick={() => setIsModalVisible(true)}>
- + Create New Key
- </Button>
+ {userRole && rolesWithWriteAccess.includes(userRole) && (
+ <Button className="mx-auto" onClick={() => setIsModalVisible(true)}>
+ + Create New Key
+ </Button>
+ )}
<Modal
// title="Create Key"
visible={isModalVisible}
diff --git a/ui/litellm-dashboard/src/components/key_info_view.tsx b/ui/litellm-dashboard/src/components/key_info_view.tsx
index cadc365ada2..9d50be6cf70 100644
--- a/ui/litellm-dashboard/src/components/key_info_view.tsx
+++ b/ui/litellm-dashboard/src/components/key_info_view.tsx
@@ -21,6 +21,7 @@ import { KeyResponse } from "./key_team_helpers/key_list";
import { Form, Input, InputNumber, message, Select } from "antd";
import { KeyEditView } from "./key_edit_view";
import { RegenerateKeyModal } from "./regenerate_key_modal";
+import { rolesWithWriteAccess } from '../utils/roles';
interface KeyInfoViewProps {
keyId: string;
@@ -128,24 +129,26 @@ export default function KeyInfoView({ keyId, onClose, keyData, accessToken, user
<Title>{keyData.key_alias || "API Key"}</Title>
<Text className="text-gray-500 font-mono">{keyData.token}</Text>
</div>
- <div className="flex gap-2">
- <Button
- icon={RefreshIcon}
- variant="secondary"
- onClick={() => setIsRegenerateModalOpen(true)}
- className="flex items-center"
- >
- Regenerate Key
- </Button>
- <Button
- icon={TrashIcon}
- variant="secondary"
- onClick={() => setIsDeleteModalOpen(true)}
- className="flex items-center"
- >
- Delete Key
- </Button>
- </div>
+ {userRole && rolesWithWriteAccess.includes(userRole) && (
+ <div className="flex gap-2">
+ <Button
+ icon={RefreshIcon}
+ variant="secondary"
+ onClick={() => setIsRegenerateModalOpen(true)}
+ className="flex items-center"
+ >
+ Regenerate Key
+ </Button>
+ <Button
+ icon={TrashIcon}
+ variant="secondary"
+ onClick={() => setIsDeleteModalOpen(true)}
+ className="flex items-center"
+ >
+ Delete Key
+ </Button>
+ </div>
+ )}
</div>
{/* Add RegenerateKeyModal */}
@@ -246,7 +249,7 @@ export default function KeyInfoView({ keyId, onClose, keyData, accessToken, user
<Card>
<div className="flex justify-between items-center mb-4">
<Title>Key Settings</Title>
- {!isEditing && (
+ {!isEditing && userRole && rolesWithWriteAccess.includes(userRole) && (
<Button variant="light" onClick={() => setIsEditing(true)}>
Edit Settings
</Button>