From 37ae5ca77a77eef22de3e6afcaecd1342dc70802 Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Wed, 23 Oct 2024 14:27:28 +0100 Subject: [PATCH 1/2] refactor (backend): enhance logic for creating and injecting API key scoped to the workspace project when starting variant container in cloud --- agenta-backend/agenta_backend/services/app_manager.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/agenta-backend/agenta_backend/services/app_manager.py b/agenta-backend/agenta_backend/services/app_manager.py index 680a81fd7f..e0af60d636 100644 --- a/agenta-backend/agenta_backend/services/app_manager.py +++ b/agenta-backend/agenta_backend/services/app_manager.py @@ -107,10 +107,9 @@ async def start_variant( ) if isCloudEE(): user = await db_manager.get_user(user_uid=user_uid) - project = await db_manager_ee.get_project_by_id(project_id=project_id) api_key = await api_key_service.create_api_key( str(user.id), - workspace_id=str(project.workspace_id), + project_id=project_id, expiration_date=None, hidden=True, ) From f6880f85532e2d34fc799adefe45290d17ca5b5f Mon Sep 17 00:00:00 2001 From: Abraham 'Abram' Israel Date: Tue, 5 Nov 2024 15:13:45 +0100 Subject: [PATCH 2/2] cleanup (backend): remove redundant function 'get_workspace_id_from_apikey' from oss --- agenta-backend/agenta_backend/routers/app_router.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/agenta-backend/agenta_backend/routers/app_router.py b/agenta-backend/agenta_backend/routers/app_router.py index c3644ff00b..c059d89cf2 100644 --- a/agenta-backend/agenta_backend/routers/app_router.py +++ b/agenta-backend/agenta_backend/routers/app_router.py @@ -220,11 +220,8 @@ async def create_app( Permission.CREATE_APPLICATION, ) - workspace_id_from_apikey = await db_manager_ee.get_workspace_id_from_apikey( - api_key_from_headers, request.state.user_id - ) if payload.workspace_id is None: - payload.workspace_id = workspace_id_from_apikey + payload.workspace_id = request.state.workspace_id try: user_org_workspace_data = await get_user_org_and_workspace_id(