Skip to content

Commit 7a5223c

Browse files
fix: update Azure credential retrieval to use client ID for improved security in ChatService and HistoryService
1 parent 572f684 commit 7a5223c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/api/services/chat_service.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def _delete_thread_async(self, thread_conversation_id: str):
7272
try:
7373
if thread_conversation_id:
7474
# Get credential and use async context managers to ensure proper cleanup
75-
credential = await get_azure_credential_async()
75+
credential = await get_azure_credential_async(client_id=config.azure_client_id)
7676
async with AIProjectClient(
7777
endpoint=config.ai_project_endpoint,
7878
credential=credential
@@ -98,9 +98,11 @@ class ChatService:
9898
"""
9999

100100
def __init__(self):
101-
self.config = Config()
102-
self.azure_openai_deployment_name = self.config.azure_openai_deployment_model
103-
self.orchestrator_agent_name = self.config.orchestrator_agent_name
101+
config = Config()
102+
self.azure_openai_deployment_name = config.azure_openai_deployment_model
103+
self.orchestrator_agent_name = config.orchestrator_agent_name
104+
self.azure_client_id = config.azure_client_id
105+
self.ai_project_endpoint = config.ai_project_endpoint
104106

105107
def get_thread_cache(self):
106108
"""Get or create the global thread cache."""
@@ -114,8 +116,8 @@ async def stream_openai_text(self, conversation_id: str, query: str) -> Streamin
114116
Get a streaming text response from OpenAI.
115117
"""
116118
async with (
117-
await get_azure_credential_async() as credential,
118-
AIProjectClient(endpoint=self.config.ai_project_endpoint, credential=credential) as project_client,
119+
await get_azure_credential_async(client_id=self.azure_client_id) as credential,
120+
AIProjectClient(endpoint=self.ai_project_endpoint, credential=credential) as project_client,
119121
):
120122
thread = None
121123
complete_response = ""

src/api/services/history_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def generate_title(self, conversation_messages):
6969

7070
try:
7171
async with (
72-
await get_azure_credential_async() as credential,
72+
await get_azure_credential_async(client_id=self.azure_client_id) as credential,
7373
AIProjectClient(endpoint=self.ai_project_endpoint, credential=credential) as project_client,
7474
):
7575
# Create chat client with title agent

0 commit comments

Comments
 (0)