|
1 | 1 | import asyncio |
2 | 2 | import base64 |
3 | | -import hashlib |
4 | 3 | import inspect |
5 | 4 | import json |
6 | 5 | import os |
@@ -103,9 +102,9 @@ async def _handle_jsonrpc(self, request: Request): |
103 | 102 | rpc_request = JSONRPCRequest(**data) |
104 | 103 |
|
105 | 104 | # Check if the request is authenticated |
106 | | - if refreshed_environment_variables and getattr(refreshed_environment_variables, "AGENT_API_KEY_HASH", None): |
| 105 | + if refreshed_environment_variables and getattr(refreshed_environment_variables, "AGENT_API_KEY", None): |
107 | 106 | authorization_header = request.headers.get("Authorization") |
108 | | - if authorization_header != f"Bearer {refreshed_environment_variables.AGENT_API_KEY_HASH}": |
| 107 | + if authorization_header != f"Bearer {refreshed_environment_variables.AGENT_API_KEY}": |
109 | 108 | return JSONRPCResponse( |
110 | 109 | id=rpc_request.id, |
111 | 110 | error=JSONRPCError(code=-32601, message="Unauthorized"), |
@@ -406,16 +405,13 @@ async def _register_agent(self, env_vars: EnvironmentVariables): |
406 | 405 | agent = response.json() |
407 | 406 | agent_id, agent_name = agent["id"], agent["name"] |
408 | 407 | agent_api_key = agent["agent_api_key"] |
409 | | - agent_api_key_hash = hashlib.sha256(agent_api_key.encode()).hexdigest() |
410 | 408 |
|
411 | 409 | os.environ["AGENT_ID"] = agent_id |
412 | 410 | os.environ["AGENT_NAME"] = agent_name |
413 | 411 | os.environ["AGENT_API_KEY"] = agent_api_key |
414 | | - os.environ["AGENT_API_KEY_HASH"] = agent_api_key_hash |
415 | 412 | refreshed_environment_variables.AGENT_ID = agent_id |
416 | 413 | refreshed_environment_variables.AGENT_NAME = agent_name |
417 | 414 | refreshed_environment_variables.AGENT_API_KEY = agent_api_key |
418 | | - refreshed_environment_variables.AGENT_API_KEY_HASH = agent_api_key_hash |
419 | 415 | get_async_agentex_client() # refresh cache |
420 | 416 | logger.info( |
421 | 417 | f"Successfully registered agent '{env_vars.AGENT_NAME}' with Agentex server with acp_url: {full_acp_url}. Registration data: {registration_data}" |
|
0 commit comments