From 2a5e62481bb0f75b7e83877fe01c050276df9694 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 10 Apr 2024 08:49:40 -0700 Subject: [PATCH 1/5] ui - setup sso --- .../src/components/admins.tsx | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/ui/litellm-dashboard/src/components/admins.tsx b/ui/litellm-dashboard/src/components/admins.tsx index b8995eb1d5..d95a8d5077 100644 --- a/ui/litellm-dashboard/src/components/admins.tsx +++ b/ui/litellm-dashboard/src/components/admins.tsx @@ -376,6 +376,56 @@ const AdminPanel: React.FC = ({ + + Add SSO + +
+ <> + + + + + + + + + + + + + +
+ Update role +
+
+ +
+ +
); }; From 84c486cacb2752e493f073abb9ee2638bb1cf848 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 10 Apr 2024 11:44:08 -0700 Subject: [PATCH 2/5] v0 setup sso on litellm admin ui --- ui/litellm-dashboard/src/components/admins.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/admins.tsx b/ui/litellm-dashboard/src/components/admins.tsx index d95a8d5077..459b9f3b75 100644 --- a/ui/litellm-dashboard/src/components/admins.tsx +++ b/ui/litellm-dashboard/src/components/admins.tsx @@ -40,6 +40,7 @@ import { Member, userGetAllUsersCall, User, + setCallbacksCall, } from "./networking"; const AdminPanel: React.FC = ({ @@ -284,6 +285,20 @@ const AdminPanel: React.FC = ({ console.error("Error creating the key:", error); } }; + + const handleSSOUpdate = async (formValues: Record) => { + if (accessToken == null) { + return; + } + let payload = { + environment_variables: { + PROXY_BASE_URL: formValues.proxy_base_url, + GOOGLE_CLIENT_ID: formValues.google_client_id, + GOOGLE_CLIENT_SECRET: formValues.google_client_secret, + }, + }; + setCallbacksCall(accessToken, payload); + } console.log(`admins: ${admins?.length}`); return (
@@ -381,7 +396,7 @@ const AdminPanel: React.FC = ({
Date: Wed, 10 Apr 2024 11:44:27 -0700 Subject: [PATCH 3/5] feat - set env vars on proxy --- litellm/proxy/proxy_server.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 691bb1adf3..6416044d8c 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2493,13 +2493,12 @@ class ProxyConfig: if success_callback not in litellm.success_callback: litellm.success_callback.append(success_callback) _added_callback = True - if _added_callback: - # we need to set env variables too - environment_variables = config_data.get("environment_variables", None) - for k, v in environment_variables.items(): - decoded_b64 = base64.b64decode(v) - value = decrypt_value(value=decoded_b64, master_key=master_key) - os.environ[k] = value + # we need to set env variables too + environment_variables = config_data.get("environment_variables", None) + for k, v in environment_variables.items(): + decoded_b64 = base64.b64decode(v) + value = decrypt_value(value=decoded_b64, master_key=master_key) + os.environ[k] = value except Exception as e: verbose_proxy_logger.error( "{}\nTraceback:{}".format(str(e), traceback.format_exc()) From 09ef6f827ca56dcaa74085931bd5d9532ecf93eb Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 10 Apr 2024 11:49:27 -0700 Subject: [PATCH 4/5] v0 - add sso --- ui/litellm-dashboard/src/components/admins.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/admins.tsx b/ui/litellm-dashboard/src/components/admins.tsx index 459b9f3b75..90319d232b 100644 --- a/ui/litellm-dashboard/src/components/admins.tsx +++ b/ui/litellm-dashboard/src/components/admins.tsx @@ -434,7 +434,7 @@ const AdminPanel: React.FC = ({
- Update role + Save
From cfb250903dac0dfa49c5851d301339ef2a59e3ac Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 10 Apr 2024 12:07:21 -0700 Subject: [PATCH 5/5] ui - setup sso on admin ui --- .../src/components/admins.tsx | 147 ++++++++++++------ 1 file changed, 101 insertions(+), 46 deletions(-) diff --git a/ui/litellm-dashboard/src/components/admins.tsx b/ui/litellm-dashboard/src/components/admins.tsx index 90319d232b..926df9b87c 100644 --- a/ui/litellm-dashboard/src/components/admins.tsx +++ b/ui/litellm-dashboard/src/components/admins.tsx @@ -57,6 +57,33 @@ const AdminPanel: React.FC = ({ const [isAddMemberModalVisible, setIsAddMemberModalVisible] = useState(false); const [isAddAdminModalVisible, setIsAddAdminModalVisible] = useState(false); const [isUpdateMemberModalVisible, setIsUpdateModalModalVisible] = useState(false); + const [isAddSSOModalVisible, setIsAddSSOModalVisible] = useState(false); + const [isInstructionsModalVisible, setIsInstructionsModalVisible] = useState(false); + +const handleAddSSOOk = () => { + setIsAddSSOModalVisible(false); + form.resetFields(); +}; + +const handleAddSSOCancel = () => { + setIsAddSSOModalVisible(false); + form.resetFields(); +}; + +const handleShowInstructions = (formValues: Record) => { + setIsAddSSOModalVisible(false); + setIsInstructionsModalVisible(true); + // Optionally, you can call handleSSOUpdate here with the formValues + // handleSSOUpdate(formValues); +}; + +const handleInstructionsOk = () => { + setIsInstructionsModalVisible(false); +}; + +const handleInstructionsCancel = () => { + setIsInstructionsModalVisible(false); +}; const roles = ["proxy_admin", "proxy_admin_viewer"] @@ -392,55 +419,83 @@ const AdminPanel: React.FC = ({ - Add SSO - -
- <> - - - - + Add SSO +
+ + - - - + + <> + + + - - - - -
- Save + + + + + + + + +
+ Save +
+ + + + +

Follow these steps to complete the SSO setup:

+ + 1. DO NOT Exit this TAB + + + 2. Open a new tab, visit your proxy base url + + + 3. Confirm your SSO is configured correctly and you can login on the new Tab + + + 4. If Step 3 is successful, you can close this tab + +
+ Done
- - - - - +
+
+
); };