forked from phoenix/litellm-mirror
build(admin.py): add base64 encoding to save proxy_url + allowed_email_subdomain
This commit is contained in:
parent
adfcbd9038
commit
8c6d11ea07
1 changed files with 13 additions and 1 deletions
14
ui/admin.py
14
ui/admin.py
|
@ -2,15 +2,26 @@
|
|||
Admin sets proxy url + allowed email subdomain
|
||||
"""
|
||||
import streamlit as st
|
||||
import base64
|
||||
|
||||
# Replace your_base_url with the actual URL where the proxy auth app is hosted
|
||||
your_base_url = 'http://localhost:8501' # Example base URL
|
||||
|
||||
# Create a configuration placeholder
|
||||
st.session_state.setdefault('proxy_url', 'http://example.com')
|
||||
st.session_state.setdefault('allowed_email_subdomain', 'example.com')
|
||||
st.session_state.setdefault('user_auth_url', 'NOT_GIVEN')
|
||||
|
||||
# Function to encode the configuration
|
||||
def encode_config(proxy_url, allowed_email_subdomain):
|
||||
combined_string = f"proxy_url={proxy_url}&accepted_email_subdomain={allowed_email_subdomain}"
|
||||
return base64.b64encode(combined_string.encode('utf-8')).decode('utf-8')
|
||||
|
||||
# Simple function to update config values
|
||||
def update_config():
|
||||
st.session_state['proxy_url'] = proxy_url
|
||||
st.session_state['allowed_email_subdomain'] = allowed_email_subdomain
|
||||
st.session_state['user_auth_url'] = f"{your_base_url}/{encode_config(proxy_url=proxy_url, allowed_email_subdomain=allowed_email_subdomain)}"
|
||||
|
||||
# Display the form for the admin to set the proxy URL and allowed email subdomain
|
||||
st.header("Admin Configuration")
|
||||
|
@ -25,4 +36,5 @@ with st.form("config_form", clear_on_submit=False):
|
|||
|
||||
# Display the current configuration
|
||||
st.write(f"Current Proxy URL: {st.session_state['proxy_url']}")
|
||||
st.write(f"Current Allowed Email Subdomain: {st.session_state['allowed_email_subdomain']}")
|
||||
st.write(f"Current Allowed Email Subdomain: {st.session_state['allowed_email_subdomain']}")
|
||||
st.write(f"Current User Auth URL: {st.session_state['user_auth_url']}")
|
Loading…
Add table
Add a link
Reference in a new issue