Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/a2a_endpoints.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/a2a_routing.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/agent_registry.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/endpoints.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/model_list_helpers.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/__init__.py +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/__pycache__/agent_permission_handler.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/agent_permission_handler.py +451 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/admin_ui_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/banner.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/cache_coordinator.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/cache_pydantic_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/callback_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/custom_openapi_spec.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/debug_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/encrypt_decrypt_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/expired_ui_session_key_cleanup_manager.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/get_routes.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/http_parsing_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/key_rotation_manager.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/load_config_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/openai_endpoint_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/openapi_schema_compat.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/path_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/performance_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/proxy_state.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/rbac_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/realtime_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/reset_budget_job.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/resource_ownership.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/static_asset_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/swagger_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/timezone_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/user_api_key_cache.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/__pycache__/cli_sso_success.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/__pycache__/jwt_display_template.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/__pycache__/ui_login.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/cli_sso_success.py +207 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/jwt_display_template.py +284 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/ui_login.py +269 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/credential_endpoints/__pycache__/endpoints.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aim/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aim/__pycache__/aim.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/akto/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/akto/__pycache__/akto.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aporia_ai/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aporia_ai/__pycache__/aporia_ai.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/crowdstrike_aidr/__pycache__/__init__.cpython-310.pyc +0 -0
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/a2a_endpoints.cpython-310.pyc
ADDED
|
Binary file (11.4 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/a2a_routing.cpython-310.pyc
ADDED
|
Binary file (2.25 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/agent_registry.cpython-310.pyc
ADDED
|
Binary file (9.94 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/endpoints.cpython-310.pyc
ADDED
|
Binary file (21.1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/model_list_helpers.cpython-310.pyc
ADDED
|
Binary file (2.6 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/__pycache__/utils.cpython-310.pyc
ADDED
|
Binary file (1.2 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/__init__.py
ADDED
|
File without changes
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (208 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/__pycache__/agent_permission_handler.cpython-310.pyc
ADDED
|
Binary file (10.4 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/agent_endpoints/auth/agent_permission_handler.py
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Agent Permission Handler for LiteLLM Proxy.
|
| 3 |
+
|
| 4 |
+
Handles agent permission checking for keys and teams using object_permission_id.
|
| 5 |
+
Follows the same pattern as MCP permission handling.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from typing import List, Optional, Set
|
| 9 |
+
|
| 10 |
+
from litellm._logging import verbose_logger
|
| 11 |
+
from litellm.proxy._types import (
|
| 12 |
+
LiteLLM_ObjectPermissionTable,
|
| 13 |
+
LiteLLM_TeamTable,
|
| 14 |
+
UI_TEAM_ID,
|
| 15 |
+
UserAPIKeyAuth,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class AgentRequestHandler:
|
| 20 |
+
"""
|
| 21 |
+
Class to handle agent permission checking, including:
|
| 22 |
+
1. Key-level agent permissions
|
| 23 |
+
2. Team-level agent permissions
|
| 24 |
+
3. Agent access group resolution
|
| 25 |
+
|
| 26 |
+
Follows the same inheritance logic as MCP:
|
| 27 |
+
- If team has restrictions and key has restrictions: use intersection
|
| 28 |
+
- If team has restrictions and key has none: inherit from team
|
| 29 |
+
- If team has no restrictions: use key restrictions
|
| 30 |
+
- If no restrictions: allow all agents
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
@staticmethod
|
| 34 |
+
async def get_allowed_agents(
|
| 35 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 36 |
+
) -> List[str]:
|
| 37 |
+
"""
|
| 38 |
+
Get list of allowed agent IDs for the given user/key based on permissions.
|
| 39 |
+
|
| 40 |
+
Returns:
|
| 41 |
+
List[str]: List of allowed agent IDs. Empty list means no restrictions (allow all).
|
| 42 |
+
"""
|
| 43 |
+
try:
|
| 44 |
+
allowed_agents: List[str] = []
|
| 45 |
+
allowed_agents_for_key = (
|
| 46 |
+
await AgentRequestHandler._get_allowed_agents_for_key(user_api_key_auth)
|
| 47 |
+
)
|
| 48 |
+
allowed_agents_for_team = (
|
| 49 |
+
await AgentRequestHandler._get_allowed_agents_for_team(
|
| 50 |
+
user_api_key_auth
|
| 51 |
+
)
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
# If team has agent restrictions, handle inheritance and intersection logic
|
| 55 |
+
if len(allowed_agents_for_team) > 0:
|
| 56 |
+
if len(allowed_agents_for_key) > 0:
|
| 57 |
+
# Key has its own agent permissions - use intersection with team permissions
|
| 58 |
+
for agent_id in allowed_agents_for_key:
|
| 59 |
+
if agent_id in allowed_agents_for_team:
|
| 60 |
+
allowed_agents.append(agent_id)
|
| 61 |
+
else:
|
| 62 |
+
# Key has no agent permissions - inherit from team
|
| 63 |
+
allowed_agents = allowed_agents_for_team
|
| 64 |
+
else:
|
| 65 |
+
allowed_agents = allowed_agents_for_key
|
| 66 |
+
|
| 67 |
+
return list(set(allowed_agents))
|
| 68 |
+
except Exception as e:
|
| 69 |
+
verbose_logger.warning(f"Failed to get allowed agents: {str(e)}")
|
| 70 |
+
return []
|
| 71 |
+
|
| 72 |
+
@staticmethod
|
| 73 |
+
async def is_agent_allowed(
|
| 74 |
+
agent_id: str,
|
| 75 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 76 |
+
) -> bool:
|
| 77 |
+
"""
|
| 78 |
+
Check if a specific agent is allowed for the given user/key.
|
| 79 |
+
|
| 80 |
+
Args:
|
| 81 |
+
agent_id: The agent ID to check
|
| 82 |
+
user_api_key_auth: User authentication info
|
| 83 |
+
|
| 84 |
+
Returns:
|
| 85 |
+
bool: True if agent is allowed, False otherwise
|
| 86 |
+
"""
|
| 87 |
+
allowed_agents = await AgentRequestHandler.get_allowed_agents(user_api_key_auth)
|
| 88 |
+
|
| 89 |
+
# Empty list means no restrictions - allow all
|
| 90 |
+
if len(allowed_agents) == 0:
|
| 91 |
+
return True
|
| 92 |
+
|
| 93 |
+
return agent_id in allowed_agents
|
| 94 |
+
|
| 95 |
+
@staticmethod
|
| 96 |
+
def _get_key_object_permission(
|
| 97 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 98 |
+
) -> Optional[LiteLLM_ObjectPermissionTable]:
|
| 99 |
+
"""
|
| 100 |
+
Get key object_permission - already loaded by get_key_object() in main auth flow.
|
| 101 |
+
|
| 102 |
+
Note: object_permission is automatically populated when the key is fetched via
|
| 103 |
+
get_key_object() in litellm/proxy/auth/auth_checks.py
|
| 104 |
+
"""
|
| 105 |
+
if not user_api_key_auth:
|
| 106 |
+
return None
|
| 107 |
+
|
| 108 |
+
return user_api_key_auth.object_permission
|
| 109 |
+
|
| 110 |
+
@staticmethod
|
| 111 |
+
async def _get_team_object_permission(
|
| 112 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 113 |
+
) -> Optional[LiteLLM_ObjectPermissionTable]:
|
| 114 |
+
"""
|
| 115 |
+
Get team object_permission - automatically loaded by get_team_object() in main auth flow.
|
| 116 |
+
|
| 117 |
+
Note: object_permission is automatically populated when the team is fetched via
|
| 118 |
+
get_team_object() in litellm/proxy/auth/auth_checks.py
|
| 119 |
+
"""
|
| 120 |
+
from litellm.proxy.auth.auth_checks import get_team_object
|
| 121 |
+
from litellm.proxy.proxy_server import (
|
| 122 |
+
prisma_client,
|
| 123 |
+
proxy_logging_obj,
|
| 124 |
+
user_api_key_cache,
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
if not user_api_key_auth or not user_api_key_auth.team_id or not prisma_client:
|
| 128 |
+
return None
|
| 129 |
+
|
| 130 |
+
# Get the team object (which has object_permission already loaded)
|
| 131 |
+
team_obj: Optional[LiteLLM_TeamTable] = await get_team_object(
|
| 132 |
+
team_id=user_api_key_auth.team_id,
|
| 133 |
+
prisma_client=prisma_client,
|
| 134 |
+
user_api_key_cache=user_api_key_cache,
|
| 135 |
+
parent_otel_span=user_api_key_auth.parent_otel_span,
|
| 136 |
+
proxy_logging_obj=proxy_logging_obj,
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
if not team_obj:
|
| 140 |
+
return None
|
| 141 |
+
|
| 142 |
+
return team_obj.object_permission
|
| 143 |
+
|
| 144 |
+
@staticmethod
|
| 145 |
+
async def _get_allowed_agents_for_key(
|
| 146 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 147 |
+
) -> List[str]:
|
| 148 |
+
"""
|
| 149 |
+
Get allowed agents for a key.
|
| 150 |
+
|
| 151 |
+
1. First checks native key-level agent permissions (object_permission)
|
| 152 |
+
2. Also includes agents from key's access_group_ids (unified access groups)
|
| 153 |
+
|
| 154 |
+
Note: object_permission is already loaded by get_key_object() in main auth flow.
|
| 155 |
+
"""
|
| 156 |
+
if user_api_key_auth is None:
|
| 157 |
+
return []
|
| 158 |
+
|
| 159 |
+
try:
|
| 160 |
+
all_agents: List[str] = []
|
| 161 |
+
|
| 162 |
+
# 1. Get agents from object_permission (native permissions)
|
| 163 |
+
key_object_permission = AgentRequestHandler._get_key_object_permission(
|
| 164 |
+
user_api_key_auth
|
| 165 |
+
)
|
| 166 |
+
if key_object_permission is not None:
|
| 167 |
+
# Get direct agents
|
| 168 |
+
direct_agents = key_object_permission.agents or []
|
| 169 |
+
|
| 170 |
+
# Get agents from access groups
|
| 171 |
+
access_group_agents = (
|
| 172 |
+
await AgentRequestHandler._get_agents_from_access_groups(
|
| 173 |
+
key_object_permission.agent_access_groups or []
|
| 174 |
+
)
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
all_agents = direct_agents + access_group_agents
|
| 178 |
+
|
| 179 |
+
# 2. Fallback: get agent IDs from key's access_group_ids (unified access groups)
|
| 180 |
+
key_access_group_ids = user_api_key_auth.access_group_ids or []
|
| 181 |
+
if key_access_group_ids:
|
| 182 |
+
from litellm.proxy.auth.auth_checks import (
|
| 183 |
+
_get_agent_ids_from_access_groups,
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
unified_agents = await _get_agent_ids_from_access_groups(
|
| 187 |
+
access_group_ids=key_access_group_ids,
|
| 188 |
+
)
|
| 189 |
+
all_agents.extend(unified_agents)
|
| 190 |
+
|
| 191 |
+
return list(set(all_agents))
|
| 192 |
+
except Exception as e:
|
| 193 |
+
verbose_logger.warning(f"Failed to get allowed agents for key: {str(e)}")
|
| 194 |
+
return []
|
| 195 |
+
|
| 196 |
+
@staticmethod
|
| 197 |
+
async def _get_allowed_agents_for_team(
|
| 198 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 199 |
+
) -> List[str]:
|
| 200 |
+
"""
|
| 201 |
+
Get allowed agents for a team.
|
| 202 |
+
|
| 203 |
+
1. First checks native team-level agent permissions (object_permission)
|
| 204 |
+
2. Also includes agents from team's access_group_ids (unified access groups)
|
| 205 |
+
|
| 206 |
+
Fetches the team object once and reuses it for both permission sources.
|
| 207 |
+
"""
|
| 208 |
+
if user_api_key_auth is None:
|
| 209 |
+
return []
|
| 210 |
+
|
| 211 |
+
if user_api_key_auth.team_id is None:
|
| 212 |
+
return []
|
| 213 |
+
|
| 214 |
+
try:
|
| 215 |
+
from litellm.proxy.auth.auth_checks import get_team_object
|
| 216 |
+
from litellm.proxy.proxy_server import (
|
| 217 |
+
prisma_client,
|
| 218 |
+
proxy_logging_obj,
|
| 219 |
+
user_api_key_cache,
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
if not prisma_client:
|
| 223 |
+
return []
|
| 224 |
+
|
| 225 |
+
# Fetch the team object once for both permission sources
|
| 226 |
+
team_obj = await get_team_object(
|
| 227 |
+
team_id=user_api_key_auth.team_id,
|
| 228 |
+
prisma_client=prisma_client,
|
| 229 |
+
user_api_key_cache=user_api_key_cache,
|
| 230 |
+
parent_otel_span=user_api_key_auth.parent_otel_span,
|
| 231 |
+
proxy_logging_obj=proxy_logging_obj,
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
if team_obj is None:
|
| 235 |
+
return []
|
| 236 |
+
|
| 237 |
+
all_agents: List[str] = []
|
| 238 |
+
|
| 239 |
+
# 1. Get agents from object_permission (native permissions)
|
| 240 |
+
object_permissions = team_obj.object_permission
|
| 241 |
+
if object_permissions is not None:
|
| 242 |
+
# Get direct agents
|
| 243 |
+
direct_agents = object_permissions.agents or []
|
| 244 |
+
|
| 245 |
+
# Get agents from access groups
|
| 246 |
+
access_group_agents = (
|
| 247 |
+
await AgentRequestHandler._get_agents_from_access_groups(
|
| 248 |
+
object_permissions.agent_access_groups or []
|
| 249 |
+
)
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
all_agents = direct_agents + access_group_agents
|
| 253 |
+
|
| 254 |
+
# 2. Also include agents from team's access_group_ids (unified access groups)
|
| 255 |
+
team_access_group_ids = team_obj.access_group_ids or []
|
| 256 |
+
if team_access_group_ids:
|
| 257 |
+
from litellm.proxy.auth.auth_checks import (
|
| 258 |
+
_get_agent_ids_from_access_groups,
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
unified_agents = await _get_agent_ids_from_access_groups(
|
| 262 |
+
access_group_ids=team_access_group_ids,
|
| 263 |
+
)
|
| 264 |
+
all_agents.extend(unified_agents)
|
| 265 |
+
|
| 266 |
+
return list(set(all_agents))
|
| 267 |
+
except Exception as e:
|
| 268 |
+
# litellm-dashboard is the default UI team and will never have agents;
|
| 269 |
+
# skip noisy warnings for it.
|
| 270 |
+
if user_api_key_auth.team_id != UI_TEAM_ID:
|
| 271 |
+
verbose_logger.warning(
|
| 272 |
+
f"Failed to get allowed agents for team: {str(e)}"
|
| 273 |
+
)
|
| 274 |
+
return []
|
| 275 |
+
|
| 276 |
+
@staticmethod
|
| 277 |
+
def _get_config_agent_ids_for_access_groups(
|
| 278 |
+
config_agents: List, access_groups: List[str]
|
| 279 |
+
) -> Set[str]:
|
| 280 |
+
"""
|
| 281 |
+
Helper to get agent_ids from config-loaded agents that match any of the given access groups.
|
| 282 |
+
"""
|
| 283 |
+
server_ids: Set[str] = set()
|
| 284 |
+
for agent in config_agents:
|
| 285 |
+
agent_access_groups = getattr(agent, "agent_access_groups", None)
|
| 286 |
+
if agent_access_groups:
|
| 287 |
+
if any(group in agent_access_groups for group in access_groups):
|
| 288 |
+
server_ids.add(agent.agent_id)
|
| 289 |
+
return server_ids
|
| 290 |
+
|
| 291 |
+
@staticmethod
|
| 292 |
+
async def _get_db_agent_ids_for_access_groups(
|
| 293 |
+
prisma_client, access_groups: List[str]
|
| 294 |
+
) -> Set[str]:
|
| 295 |
+
"""
|
| 296 |
+
Helper to get agent_ids from DB agents that match any of the given access groups.
|
| 297 |
+
"""
|
| 298 |
+
agent_ids: Set[str] = set()
|
| 299 |
+
if access_groups and prisma_client is not None:
|
| 300 |
+
try:
|
| 301 |
+
agents = await prisma_client.db.litellm_agentstable.find_many(
|
| 302 |
+
where={"agent_access_groups": {"hasSome": access_groups}}
|
| 303 |
+
)
|
| 304 |
+
for agent in agents:
|
| 305 |
+
agent_ids.add(agent.agent_id)
|
| 306 |
+
except Exception as e:
|
| 307 |
+
verbose_logger.debug(f"Error getting agents from access groups: {e}")
|
| 308 |
+
return agent_ids
|
| 309 |
+
|
| 310 |
+
@staticmethod
|
| 311 |
+
async def _get_agents_from_access_groups(
|
| 312 |
+
access_groups: List[str],
|
| 313 |
+
) -> List[str]:
|
| 314 |
+
"""
|
| 315 |
+
Resolve agent access groups to agent IDs by querying BOTH the agent table (DB) AND config-loaded agents.
|
| 316 |
+
"""
|
| 317 |
+
from litellm.proxy.agent_endpoints.agent_registry import global_agent_registry
|
| 318 |
+
from litellm.proxy.proxy_server import prisma_client
|
| 319 |
+
|
| 320 |
+
try:
|
| 321 |
+
# Use the helper for config-loaded agents
|
| 322 |
+
agent_ids = AgentRequestHandler._get_config_agent_ids_for_access_groups(
|
| 323 |
+
global_agent_registry.agent_list, access_groups
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
# Use the helper for DB agents
|
| 327 |
+
db_agent_ids = (
|
| 328 |
+
await AgentRequestHandler._get_db_agent_ids_for_access_groups(
|
| 329 |
+
prisma_client, access_groups
|
| 330 |
+
)
|
| 331 |
+
)
|
| 332 |
+
agent_ids.update(db_agent_ids)
|
| 333 |
+
|
| 334 |
+
return list(agent_ids)
|
| 335 |
+
except Exception as e:
|
| 336 |
+
verbose_logger.warning(f"Failed to get agents from access groups: {str(e)}")
|
| 337 |
+
return []
|
| 338 |
+
|
| 339 |
+
@staticmethod
|
| 340 |
+
async def get_agent_access_groups(
|
| 341 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 342 |
+
) -> List[str]:
|
| 343 |
+
"""
|
| 344 |
+
Get list of agent access groups for the given user/key based on permissions.
|
| 345 |
+
"""
|
| 346 |
+
access_groups: List[str] = []
|
| 347 |
+
access_groups_for_key = (
|
| 348 |
+
await AgentRequestHandler._get_agent_access_groups_for_key(
|
| 349 |
+
user_api_key_auth
|
| 350 |
+
)
|
| 351 |
+
)
|
| 352 |
+
access_groups_for_team = (
|
| 353 |
+
await AgentRequestHandler._get_agent_access_groups_for_team(
|
| 354 |
+
user_api_key_auth
|
| 355 |
+
)
|
| 356 |
+
)
|
| 357 |
+
|
| 358 |
+
# If team has access groups, then key must have a subset of the team's access groups
|
| 359 |
+
if len(access_groups_for_team) > 0:
|
| 360 |
+
for access_group in access_groups_for_key:
|
| 361 |
+
if access_group in access_groups_for_team:
|
| 362 |
+
access_groups.append(access_group)
|
| 363 |
+
else:
|
| 364 |
+
access_groups = access_groups_for_key
|
| 365 |
+
|
| 366 |
+
return list(set(access_groups))
|
| 367 |
+
|
| 368 |
+
@staticmethod
|
| 369 |
+
async def _get_agent_access_groups_for_key(
|
| 370 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 371 |
+
) -> List[str]:
|
| 372 |
+
"""Get agent access groups for the key."""
|
| 373 |
+
from litellm.proxy.auth.auth_checks import get_object_permission
|
| 374 |
+
from litellm.proxy.proxy_server import (
|
| 375 |
+
prisma_client,
|
| 376 |
+
proxy_logging_obj,
|
| 377 |
+
user_api_key_cache,
|
| 378 |
+
)
|
| 379 |
+
|
| 380 |
+
if user_api_key_auth is None:
|
| 381 |
+
return []
|
| 382 |
+
|
| 383 |
+
if user_api_key_auth.object_permission_id is None:
|
| 384 |
+
return []
|
| 385 |
+
|
| 386 |
+
if prisma_client is None:
|
| 387 |
+
verbose_logger.debug("prisma_client is None")
|
| 388 |
+
return []
|
| 389 |
+
|
| 390 |
+
try:
|
| 391 |
+
key_object_permission = await get_object_permission(
|
| 392 |
+
object_permission_id=user_api_key_auth.object_permission_id,
|
| 393 |
+
prisma_client=prisma_client,
|
| 394 |
+
user_api_key_cache=user_api_key_cache,
|
| 395 |
+
parent_otel_span=user_api_key_auth.parent_otel_span,
|
| 396 |
+
proxy_logging_obj=proxy_logging_obj,
|
| 397 |
+
)
|
| 398 |
+
if key_object_permission is None:
|
| 399 |
+
return []
|
| 400 |
+
|
| 401 |
+
return key_object_permission.agent_access_groups or []
|
| 402 |
+
except Exception as e:
|
| 403 |
+
verbose_logger.warning(
|
| 404 |
+
f"Failed to get agent access groups for key: {str(e)}"
|
| 405 |
+
)
|
| 406 |
+
return []
|
| 407 |
+
|
| 408 |
+
@staticmethod
|
| 409 |
+
async def _get_agent_access_groups_for_team(
|
| 410 |
+
user_api_key_auth: Optional[UserAPIKeyAuth] = None,
|
| 411 |
+
) -> List[str]:
|
| 412 |
+
"""Get agent access groups for the team."""
|
| 413 |
+
from litellm.proxy.auth.auth_checks import get_team_object
|
| 414 |
+
from litellm.proxy.proxy_server import (
|
| 415 |
+
prisma_client,
|
| 416 |
+
proxy_logging_obj,
|
| 417 |
+
user_api_key_cache,
|
| 418 |
+
)
|
| 419 |
+
|
| 420 |
+
if user_api_key_auth is None:
|
| 421 |
+
return []
|
| 422 |
+
|
| 423 |
+
if user_api_key_auth.team_id is None:
|
| 424 |
+
return []
|
| 425 |
+
|
| 426 |
+
if prisma_client is None:
|
| 427 |
+
verbose_logger.debug("prisma_client is None")
|
| 428 |
+
return []
|
| 429 |
+
|
| 430 |
+
try:
|
| 431 |
+
team_obj: Optional[LiteLLM_TeamTable] = await get_team_object(
|
| 432 |
+
team_id=user_api_key_auth.team_id,
|
| 433 |
+
prisma_client=prisma_client,
|
| 434 |
+
user_api_key_cache=user_api_key_cache,
|
| 435 |
+
parent_otel_span=user_api_key_auth.parent_otel_span,
|
| 436 |
+
proxy_logging_obj=proxy_logging_obj,
|
| 437 |
+
)
|
| 438 |
+
if team_obj is None:
|
| 439 |
+
verbose_logger.debug("team_obj is None")
|
| 440 |
+
return []
|
| 441 |
+
|
| 442 |
+
object_permissions = team_obj.object_permission
|
| 443 |
+
if object_permissions is None:
|
| 444 |
+
return []
|
| 445 |
+
|
| 446 |
+
return object_permissions.agent_access_groups or []
|
| 447 |
+
except Exception as e:
|
| 448 |
+
verbose_logger.warning(
|
| 449 |
+
f"Failed to get agent access groups for team: {str(e)}"
|
| 450 |
+
)
|
| 451 |
+
return []
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/admin_ui_utils.cpython-310.pyc
ADDED
|
Binary file (6.58 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/banner.cpython-310.pyc
ADDED
|
Binary file (1.29 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/cache_coordinator.cpython-310.pyc
ADDED
|
Binary file (6.89 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/cache_pydantic_utils.cpython-310.pyc
ADDED
|
Binary file (3.86 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/callback_utils.cpython-310.pyc
ADDED
|
Binary file (13.1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/custom_openapi_spec.cpython-310.pyc
ADDED
|
Binary file (10.7 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/debug_utils.cpython-310.pyc
ADDED
|
Binary file (19.1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/encrypt_decrypt_utils.cpython-310.pyc
ADDED
|
Binary file (2.85 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/expired_ui_session_key_cleanup_manager.cpython-310.pyc
ADDED
|
Binary file (5.19 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/get_routes.cpython-310.pyc
ADDED
|
Binary file (2.24 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/http_parsing_utils.cpython-310.pyc
ADDED
|
Binary file (13.2 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/key_rotation_manager.cpython-310.pyc
ADDED
|
Binary file (6.02 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/load_config_utils.cpython-310.pyc
ADDED
|
Binary file (4.17 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/openai_endpoint_utils.cpython-310.pyc
ADDED
|
Binary file (2.53 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/openapi_schema_compat.cpython-310.pyc
ADDED
|
Binary file (2.83 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/path_utils.cpython-310.pyc
ADDED
|
Binary file (2.16 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/performance_utils.cpython-310.pyc
ADDED
|
Binary file (8.44 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/proxy_state.cpython-310.pyc
ADDED
|
Binary file (1.43 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/rbac_utils.cpython-310.pyc
ADDED
|
Binary file (2.53 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/realtime_utils.cpython-310.pyc
ADDED
|
Binary file (741 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/reset_budget_job.cpython-310.pyc
ADDED
|
Binary file (17.7 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/resource_ownership.cpython-310.pyc
ADDED
|
Binary file (2.73 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/static_asset_utils.cpython-310.pyc
ADDED
|
Binary file (1.77 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/swagger_utils.cpython-310.pyc
ADDED
|
Binary file (1.29 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/timezone_utils.cpython-310.pyc
ADDED
|
Binary file (1.14 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/__pycache__/user_api_key_cache.cpython-310.pyc
ADDED
|
Binary file (5.26 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/__pycache__/cli_sso_success.cpython-310.pyc
ADDED
|
Binary file (7.22 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/__pycache__/jwt_display_template.cpython-310.pyc
ADDED
|
Binary file (9.12 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/__pycache__/ui_login.cpython-310.pyc
ADDED
|
Binary file (8.09 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/cli_sso_success.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from litellm.proxy.common_utils.banner import LITELLM_BANNER
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def render_cli_sso_success_page() -> str:
|
| 5 |
+
"""
|
| 6 |
+
Renders the CLI SSO authentication success page with minimal styling
|
| 7 |
+
|
| 8 |
+
Returns:
|
| 9 |
+
str: HTML content for the success page
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
html_content = f"""
|
| 13 |
+
<!DOCTYPE html>
|
| 14 |
+
<html lang="en">
|
| 15 |
+
<head>
|
| 16 |
+
<meta charset="UTF-8">
|
| 17 |
+
<title>CLI Authentication Successful - LiteLLM</title>
|
| 18 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 19 |
+
<style>
|
| 20 |
+
body {{
|
| 21 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 22 |
+
background-color: #f8fafc;
|
| 23 |
+
margin: 0;
|
| 24 |
+
padding: 20px;
|
| 25 |
+
display: flex;
|
| 26 |
+
justify-content: center;
|
| 27 |
+
align-items: center;
|
| 28 |
+
min-height: 100vh;
|
| 29 |
+
color: #1e293b;
|
| 30 |
+
}}
|
| 31 |
+
|
| 32 |
+
.container {{
|
| 33 |
+
background-color: #fff;
|
| 34 |
+
padding: 40px;
|
| 35 |
+
border-radius: 8px;
|
| 36 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 37 |
+
width: 450px;
|
| 38 |
+
max-width: 100%;
|
| 39 |
+
text-align: center;
|
| 40 |
+
}}
|
| 41 |
+
|
| 42 |
+
.logo-container {{
|
| 43 |
+
margin-bottom: 20px;
|
| 44 |
+
}}
|
| 45 |
+
|
| 46 |
+
.logo {{
|
| 47 |
+
font-size: 24px;
|
| 48 |
+
font-weight: 600;
|
| 49 |
+
color: #1e293b;
|
| 50 |
+
}}
|
| 51 |
+
|
| 52 |
+
h1 {{
|
| 53 |
+
margin: 0 0 10px;
|
| 54 |
+
color: #1e293b;
|
| 55 |
+
font-size: 28px;
|
| 56 |
+
font-weight: 600;
|
| 57 |
+
}}
|
| 58 |
+
|
| 59 |
+
.subtitle {{
|
| 60 |
+
color: #64748b;
|
| 61 |
+
margin: 0 0 30px;
|
| 62 |
+
font-size: 16px;
|
| 63 |
+
}}
|
| 64 |
+
|
| 65 |
+
.banner {{
|
| 66 |
+
background-color: #f8fafc;
|
| 67 |
+
color: #334155;
|
| 68 |
+
font-family: 'Courier New', Consolas, monospace;
|
| 69 |
+
font-size: 10px;
|
| 70 |
+
line-height: 1.1;
|
| 71 |
+
white-space: pre;
|
| 72 |
+
padding: 20px;
|
| 73 |
+
border-radius: 6px;
|
| 74 |
+
margin: 20px 0;
|
| 75 |
+
text-align: center;
|
| 76 |
+
border: 1px solid #e2e8f0;
|
| 77 |
+
overflow-x: auto;
|
| 78 |
+
}}
|
| 79 |
+
|
| 80 |
+
.success-box {{
|
| 81 |
+
background-color: #f8fafc;
|
| 82 |
+
border-radius: 6px;
|
| 83 |
+
padding: 20px;
|
| 84 |
+
margin-bottom: 30px;
|
| 85 |
+
border: 1px solid #e2e8f0;
|
| 86 |
+
}}
|
| 87 |
+
|
| 88 |
+
.success-header {{
|
| 89 |
+
display: flex;
|
| 90 |
+
align-items: center;
|
| 91 |
+
justify-content: center;
|
| 92 |
+
margin-bottom: 12px;
|
| 93 |
+
color: #1e293b;
|
| 94 |
+
font-weight: 600;
|
| 95 |
+
font-size: 16px;
|
| 96 |
+
}}
|
| 97 |
+
|
| 98 |
+
.success-header svg {{
|
| 99 |
+
margin-right: 8px;
|
| 100 |
+
}}
|
| 101 |
+
|
| 102 |
+
.success-box p {{
|
| 103 |
+
color: #64748b;
|
| 104 |
+
margin: 8px 0;
|
| 105 |
+
line-height: 1.5;
|
| 106 |
+
font-size: 14px;
|
| 107 |
+
}}
|
| 108 |
+
|
| 109 |
+
.instructions {{
|
| 110 |
+
background-color: #f8fafc;
|
| 111 |
+
border-radius: 6px;
|
| 112 |
+
padding: 20px;
|
| 113 |
+
margin-bottom: 20px;
|
| 114 |
+
border: 1px solid #e2e8f0;
|
| 115 |
+
}}
|
| 116 |
+
|
| 117 |
+
.instructions-header {{
|
| 118 |
+
display: flex;
|
| 119 |
+
align-items: center;
|
| 120 |
+
justify-content: center;
|
| 121 |
+
margin-bottom: 12px;
|
| 122 |
+
color: #1e293b;
|
| 123 |
+
font-weight: 600;
|
| 124 |
+
font-size: 16px;
|
| 125 |
+
}}
|
| 126 |
+
|
| 127 |
+
.instructions-header svg {{
|
| 128 |
+
margin-right: 8px;
|
| 129 |
+
}}
|
| 130 |
+
|
| 131 |
+
.instructions p {{
|
| 132 |
+
color: #64748b;
|
| 133 |
+
margin: 8px 0;
|
| 134 |
+
line-height: 1.5;
|
| 135 |
+
font-size: 14px;
|
| 136 |
+
}}
|
| 137 |
+
|
| 138 |
+
.countdown {{
|
| 139 |
+
color: #64748b;
|
| 140 |
+
font-size: 14px;
|
| 141 |
+
font-weight: 500;
|
| 142 |
+
padding: 12px;
|
| 143 |
+
background-color: #f8fafc;
|
| 144 |
+
border-radius: 6px;
|
| 145 |
+
border: 1px solid #e2e8f0;
|
| 146 |
+
}}
|
| 147 |
+
</style>
|
| 148 |
+
</head>
|
| 149 |
+
<body>
|
| 150 |
+
<div class="container">
|
| 151 |
+
<div class="logo-container">
|
| 152 |
+
<div class="logo">
|
| 153 |
+
🚅 LiteLLM
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<div class="banner">{LITELLM_BANNER}</div>
|
| 158 |
+
|
| 159 |
+
<h1>Authentication Successful!</h1>
|
| 160 |
+
<p class="subtitle">Your CLI authentication is complete.</p>
|
| 161 |
+
|
| 162 |
+
<div class="success-box">
|
| 163 |
+
<div class="success-header">
|
| 164 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 165 |
+
<path d="M9 12l2 2 4-4"></path>
|
| 166 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 167 |
+
</svg>
|
| 168 |
+
CLI Authentication Complete
|
| 169 |
+
</div>
|
| 170 |
+
<p>Your LiteLLM CLI has been successfully authenticated and is ready to use.</p>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<div class="instructions">
|
| 174 |
+
<div class="instructions-header">
|
| 175 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 176 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 177 |
+
<line x1="12" y1="16" x2="12" y2="12"></line>
|
| 178 |
+
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
| 179 |
+
</svg>
|
| 180 |
+
Next Steps
|
| 181 |
+
</div>
|
| 182 |
+
<p>Return to your terminal - the CLI will automatically detect the successful authentication.</p>
|
| 183 |
+
<p>You can now use LiteLLM CLI commands with your authenticated session.</p>
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<div class="countdown" id="countdown">This window will close in 3 seconds...</div>
|
| 187 |
+
</div>
|
| 188 |
+
|
| 189 |
+
<script>
|
| 190 |
+
let seconds = 3;
|
| 191 |
+
const countdownElement = document.getElementById('countdown');
|
| 192 |
+
|
| 193 |
+
const countdown = setInterval(function() {{
|
| 194 |
+
seconds--;
|
| 195 |
+
if (seconds > 0) {{
|
| 196 |
+
countdownElement.textContent = `This window will close in ${{seconds}} second${{seconds === 1 ? '' : 's'}}...`;
|
| 197 |
+
}} else {{
|
| 198 |
+
countdownElement.textContent = 'Closing...';
|
| 199 |
+
clearInterval(countdown);
|
| 200 |
+
window.close();
|
| 201 |
+
}}
|
| 202 |
+
}}, 1000);
|
| 203 |
+
</script>
|
| 204 |
+
</body>
|
| 205 |
+
</html>
|
| 206 |
+
"""
|
| 207 |
+
return html_content
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/jwt_display_template.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# JWT display template for SSO debug callback
|
| 2 |
+
jwt_display_template = """
|
| 3 |
+
<!DOCTYPE html>
|
| 4 |
+
<html lang="en">
|
| 5 |
+
<head>
|
| 6 |
+
<meta charset="UTF-8">
|
| 7 |
+
<title>LiteLLM SSO Debug - JWT Information</title>
|
| 8 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 9 |
+
<style>
|
| 10 |
+
body {
|
| 11 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 12 |
+
background-color: #f8fafc;
|
| 13 |
+
margin: 0;
|
| 14 |
+
padding: 20px;
|
| 15 |
+
display: flex;
|
| 16 |
+
justify-content: center;
|
| 17 |
+
align-items: center;
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
color: #333;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.container {
|
| 23 |
+
background-color: #fff;
|
| 24 |
+
padding: 40px;
|
| 25 |
+
border-radius: 8px;
|
| 26 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 27 |
+
width: 800px;
|
| 28 |
+
max-width: 100%;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.logo-container {
|
| 32 |
+
text-align: center;
|
| 33 |
+
margin-bottom: 30px;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.logo {
|
| 37 |
+
font-size: 24px;
|
| 38 |
+
font-weight: 600;
|
| 39 |
+
color: #1e293b;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
h2 {
|
| 43 |
+
margin: 0 0 10px;
|
| 44 |
+
color: #1e293b;
|
| 45 |
+
font-size: 28px;
|
| 46 |
+
font-weight: 600;
|
| 47 |
+
text-align: center;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.subtitle {
|
| 51 |
+
color: #64748b;
|
| 52 |
+
margin: 0 0 20px;
|
| 53 |
+
font-size: 16px;
|
| 54 |
+
text-align: center;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.info-box {
|
| 58 |
+
background-color: #f1f5f9;
|
| 59 |
+
border-radius: 6px;
|
| 60 |
+
padding: 20px;
|
| 61 |
+
margin-bottom: 30px;
|
| 62 |
+
border-left: 4px solid #2563eb;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.success-box {
|
| 66 |
+
background-color: #f0fdf4;
|
| 67 |
+
border-radius: 6px;
|
| 68 |
+
padding: 20px;
|
| 69 |
+
margin-bottom: 30px;
|
| 70 |
+
border-left: 4px solid #16a34a;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.info-header {
|
| 74 |
+
display: flex;
|
| 75 |
+
align-items: center;
|
| 76 |
+
margin-bottom: 12px;
|
| 77 |
+
color: #1e40af;
|
| 78 |
+
font-weight: 600;
|
| 79 |
+
font-size: 16px;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.success-header {
|
| 83 |
+
display: flex;
|
| 84 |
+
align-items: center;
|
| 85 |
+
margin-bottom: 12px;
|
| 86 |
+
color: #166534;
|
| 87 |
+
font-weight: 600;
|
| 88 |
+
font-size: 16px;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.info-header svg, .success-header svg {
|
| 92 |
+
margin-right: 8px;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.data-container {
|
| 96 |
+
margin-top: 20px;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.data-row {
|
| 100 |
+
display: flex;
|
| 101 |
+
border-bottom: 1px solid #e2e8f0;
|
| 102 |
+
padding: 12px 0;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.data-row:last-child {
|
| 106 |
+
border-bottom: none;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.data-label {
|
| 110 |
+
font-weight: 500;
|
| 111 |
+
color: #334155;
|
| 112 |
+
width: 180px;
|
| 113 |
+
flex-shrink: 0;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.data-value {
|
| 117 |
+
color: #475569;
|
| 118 |
+
word-break: break-all;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.jwt-container {
|
| 122 |
+
background-color: #f8fafc;
|
| 123 |
+
border-radius: 6px;
|
| 124 |
+
padding: 15px;
|
| 125 |
+
margin-top: 20px;
|
| 126 |
+
overflow-x: auto;
|
| 127 |
+
border: 1px solid #e2e8f0;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.jwt-text {
|
| 131 |
+
font-family: monospace;
|
| 132 |
+
white-space: pre-wrap;
|
| 133 |
+
word-break: break-all;
|
| 134 |
+
margin: 0;
|
| 135 |
+
color: #334155;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.back-button {
|
| 139 |
+
display: inline-block;
|
| 140 |
+
background-color: #6466E9;
|
| 141 |
+
color: #fff;
|
| 142 |
+
text-decoration: none;
|
| 143 |
+
padding: 10px 16px;
|
| 144 |
+
border-radius: 6px;
|
| 145 |
+
font-weight: 500;
|
| 146 |
+
margin-top: 20px;
|
| 147 |
+
text-align: center;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.back-button:hover {
|
| 151 |
+
background-color: #4138C2;
|
| 152 |
+
text-decoration: none;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.buttons {
|
| 156 |
+
display: flex;
|
| 157 |
+
gap: 10px;
|
| 158 |
+
margin-top: 20px;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.copy-button {
|
| 162 |
+
background-color: #e2e8f0;
|
| 163 |
+
color: #334155;
|
| 164 |
+
border: none;
|
| 165 |
+
padding: 8px 12px;
|
| 166 |
+
border-radius: 4px;
|
| 167 |
+
cursor: pointer;
|
| 168 |
+
font-size: 14px;
|
| 169 |
+
display: flex;
|
| 170 |
+
align-items: center;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.copy-button:hover {
|
| 174 |
+
background-color: #cbd5e1;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.copy-button svg {
|
| 178 |
+
margin-right: 6px;
|
| 179 |
+
}
|
| 180 |
+
</style>
|
| 181 |
+
</head>
|
| 182 |
+
<body>
|
| 183 |
+
<div class="container">
|
| 184 |
+
<div class="logo-container">
|
| 185 |
+
<div class="logo">
|
| 186 |
+
🚅 LiteLLM
|
| 187 |
+
</div>
|
| 188 |
+
</div>
|
| 189 |
+
<h2>SSO Debug Information</h2>
|
| 190 |
+
<p class="subtitle">Results from the SSO authentication process.</p>
|
| 191 |
+
|
| 192 |
+
<div class="success-box">
|
| 193 |
+
<div class="success-header">
|
| 194 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 195 |
+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
| 196 |
+
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
| 197 |
+
</svg>
|
| 198 |
+
Authentication Successful
|
| 199 |
+
</div>
|
| 200 |
+
<p>The SSO authentication completed successfully. Below is the information returned by the provider.</p>
|
| 201 |
+
</div>
|
| 202 |
+
|
| 203 |
+
<div class="data-container" id="userData">
|
| 204 |
+
<!-- Data will be inserted here by JavaScript -->
|
| 205 |
+
</div>
|
| 206 |
+
|
| 207 |
+
<div class="info-box">
|
| 208 |
+
<div class="info-header">
|
| 209 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 210 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 211 |
+
<line x1="12" y1="16" x2="12" y2="12"></line>
|
| 212 |
+
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
| 213 |
+
</svg>
|
| 214 |
+
JSON Representation
|
| 215 |
+
</div>
|
| 216 |
+
<div class="jwt-container">
|
| 217 |
+
<pre class="jwt-text" id="jsonData">Loading...</pre>
|
| 218 |
+
</div>
|
| 219 |
+
<div class="buttons">
|
| 220 |
+
<button class="copy-button" onclick="copyToClipboard('jsonData')">
|
| 221 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 222 |
+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
|
| 223 |
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
| 224 |
+
</svg>
|
| 225 |
+
Copy to Clipboard
|
| 226 |
+
</button>
|
| 227 |
+
</div>
|
| 228 |
+
</div>
|
| 229 |
+
|
| 230 |
+
<a href="/sso/debug/login" class="back-button">
|
| 231 |
+
Try Another SSO Login
|
| 232 |
+
</a>
|
| 233 |
+
</div>
|
| 234 |
+
|
| 235 |
+
<script>
|
| 236 |
+
// This will be populated with the actual data from the server
|
| 237 |
+
const userData = SSO_DATA;
|
| 238 |
+
|
| 239 |
+
function renderUserData() {
|
| 240 |
+
const container = document.getElementById('userData');
|
| 241 |
+
const jsonDisplay = document.getElementById('jsonData');
|
| 242 |
+
|
| 243 |
+
// Format JSON with indentation for display
|
| 244 |
+
jsonDisplay.textContent = JSON.stringify(userData, null, 2);
|
| 245 |
+
|
| 246 |
+
// Clear container
|
| 247 |
+
container.innerHTML = '';
|
| 248 |
+
|
| 249 |
+
// Add each key-value pair to the UI
|
| 250 |
+
for (const [key, value] of Object.entries(userData)) {
|
| 251 |
+
if (typeof value !== 'object' || value === null) {
|
| 252 |
+
const row = document.createElement('div');
|
| 253 |
+
row.className = 'data-row';
|
| 254 |
+
|
| 255 |
+
const label = document.createElement('div');
|
| 256 |
+
label.className = 'data-label';
|
| 257 |
+
label.textContent = key;
|
| 258 |
+
|
| 259 |
+
const dataValue = document.createElement('div');
|
| 260 |
+
dataValue.className = 'data-value';
|
| 261 |
+
dataValue.textContent = value !== null ? value : 'null';
|
| 262 |
+
|
| 263 |
+
row.appendChild(label);
|
| 264 |
+
row.appendChild(dataValue);
|
| 265 |
+
container.appendChild(row);
|
| 266 |
+
}
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
function copyToClipboard(elementId) {
|
| 271 |
+
const text = document.getElementById(elementId).textContent;
|
| 272 |
+
navigator.clipboard.writeText(text).then(() => {
|
| 273 |
+
alert('Copied to clipboard!');
|
| 274 |
+
}).catch(err => {
|
| 275 |
+
console.error('Could not copy text: ', err);
|
| 276 |
+
});
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
// Render the data when the page loads
|
| 280 |
+
document.addEventListener('DOMContentLoaded', renderUserData);
|
| 281 |
+
</script>
|
| 282 |
+
</body>
|
| 283 |
+
</html>
|
| 284 |
+
"""
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/common_utils/html_forms/ui_login.py
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from litellm.proxy.utils import get_custom_url
|
| 4 |
+
|
| 5 |
+
url_to_redirect_to = os.getenv("PROXY_BASE_URL", "")
|
| 6 |
+
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
|
| 7 |
+
if server_root_path != "":
|
| 8 |
+
url_to_redirect_to += server_root_path
|
| 9 |
+
url_to_redirect_to += "/login"
|
| 10 |
+
new_ui_login_url = get_custom_url("", "ui/login")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def build_ui_login_form(show_deprecation_banner: bool = False) -> str:
|
| 14 |
+
banner_html = (
|
| 15 |
+
f"""
|
| 16 |
+
<div class="deprecation-banner">
|
| 17 |
+
<strong>Deprecated:</strong> Logging in with username and password on this page is deprecated.
|
| 18 |
+
Please use the <a href="{new_ui_login_url}">new login page</a> instead.
|
| 19 |
+
This page will be dedicated to signing in via SSO in the future.
|
| 20 |
+
</div>
|
| 21 |
+
"""
|
| 22 |
+
if show_deprecation_banner
|
| 23 |
+
else ""
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
return f"""
|
| 27 |
+
<!DOCTYPE html>
|
| 28 |
+
<html lang="en">
|
| 29 |
+
<head>
|
| 30 |
+
<meta charset="UTF-8">
|
| 31 |
+
<title>LiteLLM Login</title>
|
| 32 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 33 |
+
<style>
|
| 34 |
+
body {{
|
| 35 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 36 |
+
background-color: #f8fafc;
|
| 37 |
+
margin: 0;
|
| 38 |
+
padding: 20px;
|
| 39 |
+
display: flex;
|
| 40 |
+
justify-content: center;
|
| 41 |
+
align-items: center;
|
| 42 |
+
min-height: 100vh;
|
| 43 |
+
color: #333;
|
| 44 |
+
}}
|
| 45 |
+
|
| 46 |
+
form {{
|
| 47 |
+
background-color: #fff;
|
| 48 |
+
padding: 40px;
|
| 49 |
+
border-radius: 8px;
|
| 50 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 51 |
+
width: 450px;
|
| 52 |
+
max-width: 100%;
|
| 53 |
+
}}
|
| 54 |
+
|
| 55 |
+
.logo-container {{
|
| 56 |
+
text-align: center;
|
| 57 |
+
margin-bottom: 30px;
|
| 58 |
+
}}
|
| 59 |
+
|
| 60 |
+
.logo {{
|
| 61 |
+
font-size: 24px;
|
| 62 |
+
font-weight: 600;
|
| 63 |
+
color: #1e293b;
|
| 64 |
+
}}
|
| 65 |
+
|
| 66 |
+
h2 {{
|
| 67 |
+
margin: 0 0 10px;
|
| 68 |
+
color: #1e293b;
|
| 69 |
+
font-size: 28px;
|
| 70 |
+
font-weight: 600;
|
| 71 |
+
text-align: center;
|
| 72 |
+
}}
|
| 73 |
+
|
| 74 |
+
.subtitle {{
|
| 75 |
+
color: #64748b;
|
| 76 |
+
margin: 0 0 20px;
|
| 77 |
+
font-size: 16px;
|
| 78 |
+
text-align: center;
|
| 79 |
+
}}
|
| 80 |
+
|
| 81 |
+
.info-box {{
|
| 82 |
+
background-color: #f1f5f9;
|
| 83 |
+
border-radius: 6px;
|
| 84 |
+
padding: 20px;
|
| 85 |
+
margin-bottom: 30px;
|
| 86 |
+
border-left: 4px solid #2563eb;
|
| 87 |
+
}}
|
| 88 |
+
|
| 89 |
+
.info-header {{
|
| 90 |
+
display: flex;
|
| 91 |
+
align-items: center;
|
| 92 |
+
margin-bottom: 12px;
|
| 93 |
+
color: #1e40af;
|
| 94 |
+
font-weight: 600;
|
| 95 |
+
font-size: 16px;
|
| 96 |
+
}}
|
| 97 |
+
|
| 98 |
+
.info-header svg {{
|
| 99 |
+
margin-right: 8px;
|
| 100 |
+
}}
|
| 101 |
+
|
| 102 |
+
.info-box p {{
|
| 103 |
+
color: #475569;
|
| 104 |
+
margin: 8px 0;
|
| 105 |
+
line-height: 1.5;
|
| 106 |
+
font-size: 14px;
|
| 107 |
+
}}
|
| 108 |
+
|
| 109 |
+
label {{
|
| 110 |
+
display: block;
|
| 111 |
+
margin-bottom: 8px;
|
| 112 |
+
font-weight: 500;
|
| 113 |
+
color: #334155;
|
| 114 |
+
font-size: 14px;
|
| 115 |
+
}}
|
| 116 |
+
|
| 117 |
+
.required {{
|
| 118 |
+
color: #dc2626;
|
| 119 |
+
margin-left: 2px;
|
| 120 |
+
}}
|
| 121 |
+
|
| 122 |
+
input[type="text"],
|
| 123 |
+
input[type="password"] {{
|
| 124 |
+
width: 100%;
|
| 125 |
+
padding: 10px 14px;
|
| 126 |
+
margin-bottom: 20px;
|
| 127 |
+
box-sizing: border-box;
|
| 128 |
+
border: 1px solid #e2e8f0;
|
| 129 |
+
border-radius: 6px;
|
| 130 |
+
font-size: 15px;
|
| 131 |
+
color: #1e293b;
|
| 132 |
+
background-color: #fff;
|
| 133 |
+
transition: border-color 0.2s, box-shadow 0.2s;
|
| 134 |
+
}}
|
| 135 |
+
|
| 136 |
+
input[type="text"]:focus,
|
| 137 |
+
input[type="password"]:focus {{
|
| 138 |
+
outline: none;
|
| 139 |
+
border-color: #3b82f6;
|
| 140 |
+
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
|
| 141 |
+
}}
|
| 142 |
+
|
| 143 |
+
.toggle-password {{
|
| 144 |
+
display: flex;
|
| 145 |
+
align-items: center;
|
| 146 |
+
margin-top: -15px;
|
| 147 |
+
margin-bottom: 20px;
|
| 148 |
+
}}
|
| 149 |
+
|
| 150 |
+
.toggle-password input[type="checkbox"] {{
|
| 151 |
+
margin-right: 8px;
|
| 152 |
+
vertical-align: middle;
|
| 153 |
+
width: 16px;
|
| 154 |
+
height: 16px;
|
| 155 |
+
}}
|
| 156 |
+
|
| 157 |
+
.toggle-password label {{
|
| 158 |
+
margin-bottom: 0;
|
| 159 |
+
font-size: 14px;
|
| 160 |
+
cursor: pointer;
|
| 161 |
+
line-height: 1;
|
| 162 |
+
}}
|
| 163 |
+
|
| 164 |
+
input[type="submit"] {{
|
| 165 |
+
background-color: #6466E9;
|
| 166 |
+
color: #fff;
|
| 167 |
+
cursor: pointer;
|
| 168 |
+
font-weight: 500;
|
| 169 |
+
border: none;
|
| 170 |
+
padding: 10px 16px;
|
| 171 |
+
transition: background-color 0.2s;
|
| 172 |
+
border-radius: 6px;
|
| 173 |
+
margin-top: 10px;
|
| 174 |
+
font-size: 14px;
|
| 175 |
+
width: 100%;
|
| 176 |
+
}}
|
| 177 |
+
|
| 178 |
+
input[type="submit"]:hover {{
|
| 179 |
+
background-color: #4138C2;
|
| 180 |
+
}}
|
| 181 |
+
|
| 182 |
+
a {{
|
| 183 |
+
color: #3b82f6;
|
| 184 |
+
text-decoration: none;
|
| 185 |
+
}}
|
| 186 |
+
|
| 187 |
+
a:hover {{
|
| 188 |
+
text-decoration: underline;
|
| 189 |
+
}}
|
| 190 |
+
|
| 191 |
+
code {{
|
| 192 |
+
background-color: #f1f5f9;
|
| 193 |
+
padding: 2px 4px;
|
| 194 |
+
border-radius: 4px;
|
| 195 |
+
font-family: monospace;
|
| 196 |
+
font-size: 13px;
|
| 197 |
+
color: #334155;
|
| 198 |
+
}}
|
| 199 |
+
|
| 200 |
+
.help-text {{
|
| 201 |
+
color: #64748b;
|
| 202 |
+
font-size: 14px;
|
| 203 |
+
margin-top: -12px;
|
| 204 |
+
margin-bottom: 20px;
|
| 205 |
+
}}
|
| 206 |
+
|
| 207 |
+
.deprecation-banner {{
|
| 208 |
+
background-color: #fee2e2;
|
| 209 |
+
border: 1px solid #ef4444;
|
| 210 |
+
color: #991b1b;
|
| 211 |
+
padding: 14px 16px;
|
| 212 |
+
border-radius: 6px;
|
| 213 |
+
margin-bottom: 20px;
|
| 214 |
+
font-size: 14px;
|
| 215 |
+
line-height: 1.5;
|
| 216 |
+
}}
|
| 217 |
+
|
| 218 |
+
.deprecation-banner a {{
|
| 219 |
+
color: #991b1b;
|
| 220 |
+
font-weight: 600;
|
| 221 |
+
text-decoration: underline;
|
| 222 |
+
}}
|
| 223 |
+
</style>
|
| 224 |
+
</head>
|
| 225 |
+
<body>
|
| 226 |
+
<form action="{url_to_redirect_to}" method="post">
|
| 227 |
+
{banner_html}
|
| 228 |
+
<div class="logo-container">
|
| 229 |
+
<div class="logo">
|
| 230 |
+
🚅 LiteLLM
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
<h2>Login</h2>
|
| 234 |
+
<p class="subtitle">Access your LiteLLM Admin UI.</p>
|
| 235 |
+
<div class="info-box">
|
| 236 |
+
<div class="info-header">
|
| 237 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 238 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 239 |
+
<line x1="12" y1="16" x2="12" y2="12"></line>
|
| 240 |
+
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
| 241 |
+
</svg>
|
| 242 |
+
Default Credentials
|
| 243 |
+
</div>
|
| 244 |
+
<p>By default, Username is <code>admin</code> and Password is your set LiteLLM Proxy <code>MASTER_KEY</code>.</p>
|
| 245 |
+
<p>Need to set UI credentials or SSO? <a href="https://docs.litellm.ai/docs/proxy/ui" target="_blank">Check the documentation</a>.</p>
|
| 246 |
+
</div>
|
| 247 |
+
<label for="username">Username<span class="required">*</span></label>
|
| 248 |
+
<input type="text" id="username" name="username" required placeholder="Enter your username" autocomplete="username">
|
| 249 |
+
|
| 250 |
+
<label for="password">Password<span class="required">*</span></label>
|
| 251 |
+
<input type="password" id="password" name="password" required placeholder="Enter your password" autocomplete="current-password">
|
| 252 |
+
<div class="toggle-password">
|
| 253 |
+
<input type="checkbox" id="show-password" onclick="togglePasswordVisibility()">
|
| 254 |
+
<label for="show-password">Show password</label>
|
| 255 |
+
</div>
|
| 256 |
+
<input type="submit" value="Login">
|
| 257 |
+
</form>
|
| 258 |
+
<script>
|
| 259 |
+
function togglePasswordVisibility() {{
|
| 260 |
+
var passwordField = document.getElementById("password");
|
| 261 |
+
passwordField.type = passwordField.type === "password" ? "text" : "password";
|
| 262 |
+
}}
|
| 263 |
+
</script>
|
| 264 |
+
</body>
|
| 265 |
+
</html>
|
| 266 |
+
"""
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
html_form = build_ui_login_form(show_deprecation_banner=True)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/credential_endpoints/__pycache__/endpoints.cpython-310.pyc
ADDED
|
Binary file (8.29 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aim/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.05 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aim/__pycache__/aim.cpython-310.pyc
ADDED
|
Binary file (9.86 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/akto/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.18 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/akto/__pycache__/akto.cpython-310.pyc
ADDED
|
Binary file (13.4 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aporia_ai/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/aporia_ai/__pycache__/aporia_ai.cpython-310.pyc
ADDED
|
Binary file (5.46 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/litellm/proxy/guardrails/guardrail_hooks/crowdstrike_aidr/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.19 kB). View file
|
|
|