mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(Security fix) - remove code block that inserts master key hash into DB (#8268)
* remove code block upserting master key hash to db * run test to check if key upserted into db * run ci/cd again * litellm_proxy_security_tests * litellm_proxy_security_tests * run prisma entrypoint * ci/cd run again * fix test master key not in db
This commit is contained in:
parent
88e7046165
commit
6cef115bb0
3 changed files with 115 additions and 42 deletions
|
@ -515,14 +515,6 @@ async def proxy_startup_event(app: FastAPI):
|
|||
prompt_injection_detection_obj.update_environment(router=llm_router)
|
||||
|
||||
verbose_proxy_logger.debug("prisma_client: %s", prisma_client)
|
||||
if prisma_client is not None and master_key is not None:
|
||||
ProxyStartupEvent._add_master_key_hash_to_db(
|
||||
master_key=master_key,
|
||||
prisma_client=prisma_client,
|
||||
litellm_proxy_admin_name=litellm_proxy_admin_name,
|
||||
general_settings=general_settings,
|
||||
)
|
||||
|
||||
if prisma_client is not None and litellm.max_budget > 0:
|
||||
ProxyStartupEvent._add_proxy_budget_to_db(
|
||||
litellm_proxy_budget_name=litellm_proxy_admin_name
|
||||
|
@ -3205,39 +3197,6 @@ class ProxyStartupEvent:
|
|||
litellm_jwtauth=litellm_jwtauth,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _add_master_key_hash_to_db(
|
||||
cls,
|
||||
master_key: str,
|
||||
prisma_client: PrismaClient,
|
||||
litellm_proxy_admin_name: str,
|
||||
general_settings: dict,
|
||||
):
|
||||
"""Adds master key hash to db for cost tracking"""
|
||||
if os.getenv("PROXY_ADMIN_ID", None) is not None:
|
||||
litellm_proxy_admin_name = os.getenv(
|
||||
"PROXY_ADMIN_ID", litellm_proxy_admin_name
|
||||
)
|
||||
if general_settings.get("disable_adding_master_key_hash_to_db") is True:
|
||||
verbose_proxy_logger.info("Skipping writing master key hash to db")
|
||||
else:
|
||||
# add master key to db
|
||||
# add 'admin' user to db. Fixes https://github.com/BerriAI/litellm/issues/6206
|
||||
task_1 = generate_key_helper_fn(
|
||||
request_type="user",
|
||||
duration=None,
|
||||
models=[],
|
||||
aliases={},
|
||||
config={},
|
||||
spend=0,
|
||||
token=master_key,
|
||||
user_id=litellm_proxy_admin_name,
|
||||
user_role=LitellmUserRoles.PROXY_ADMIN,
|
||||
query_type="update_data",
|
||||
update_key_values={"user_role": LitellmUserRoles.PROXY_ADMIN},
|
||||
)
|
||||
asyncio.create_task(task_1)
|
||||
|
||||
@classmethod
|
||||
def _add_proxy_budget_to_db(cls, litellm_proxy_budget_name: str):
|
||||
"""Adds a global proxy budget to db"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue