From 2c338296c138f6402ec5ecc80961861f2e2ae370 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 9 Jul 2024 14:46:46 -0700 Subject: [PATCH] ui - allow setting allowed ip --- .../src/components/admins.tsx | 109 +++++++++++++++++- 1 file changed, 108 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/admins.tsx b/ui/litellm-dashboard/src/components/admins.tsx index 3b012d5b4b2..94722923bf4 100644 --- a/ui/litellm-dashboard/src/components/admins.tsx +++ b/ui/litellm-dashboard/src/components/admins.tsx @@ -73,6 +73,11 @@ const AdminPanel: React.FC = ({ const [isAddSSOModalVisible, setIsAddSSOModalVisible] = useState(false); const [isInstructionsModalVisible, setIsInstructionsModalVisible] = useState(false); + const [isAllowedIPModalVisible, setIsAllowedIPModalVisible] = useState(false); + const [isAddIPModalVisible, setIsAddIPModalVisible] = useState(false); + const [isDeleteIPModalVisible, setIsDeleteIPModalVisible] = useState(false); + const [allowedIPs, setAllowedIPs] = useState([]); + const [ipToDelete, setIPToDelete] = useState(null); const router = useRouter(); const [possibleUIRoles, setPossibleUIRoles] = useState = ({ } nonSssoUrl += "/fallback/login"; + const handleShowAllowedIPs = () => { + // In a real application, you would fetch the allowed IPs from your backend here + setAllowedIPs(['192.168.1.1', '10.0.0.1', '172.16.0.1']); + setIsAllowedIPModalVisible(true); + }; + + const handleAddIP = (values: { ip: string }) => { + setAllowedIPs([...allowedIPs, values.ip]); + setIsAddIPModalVisible(false); + message.success('IP address added successfully'); + }; + + const handleDeleteIP = (ip: string) => { + setIPToDelete(ip); + setIsDeleteIPModalVisible(true); + }; + + const confirmDeleteIP = () => { + if (ipToDelete) { + setAllowedIPs(allowedIPs.filter(ip => ip !== ipToDelete)); + setIsDeleteIPModalVisible(false); + setIPToDelete(null); + message.success('IP address deleted successfully'); + } + }; + + const handleAddSSOOk = () => { setIsAddSSOModalVisible(false); form.resetFields(); @@ -533,9 +565,19 @@ const AdminPanel: React.FC = ({ + + ✨ Security Settings Add SSO + + + + Allowed IP Addresses + + + +
- + = ({ Done
+ setIsAllowedIPModalVisible(false)} + footer={[ + , + + ]} + > + + + + IP Address + Action + + + + {allowedIPs.map((ip, index) => ( + + {ip} + + + + + ))} + +
+
+ + setIsAddIPModalVisible(false)} + footer={null} + > +
+ + + + + + Add IP Address + + +
+
+ + setIsDeleteIPModalVisible(false)} + > +

Are you sure you want to delete the IP address: {ipToDelete}?

+
If you need to login without sso, you can access{" "}