security: stop logging token prefix on failed agent auth

The first 6 characters of invalid agent tokens were logged, leaking
partial credential information. Remove token_prefix from log messages
while preserving the request path for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hugh Brown
2026-03-03 13:39:04 -07:00
committed by Abhimanyu Saharan
parent 66da278673
commit 4257c08ba9

View File

@@ -128,9 +128,8 @@ async def get_agent_auth_context(
agent = await _find_agent_for_token(session, resolved)
if agent is None:
logger.warning(
"agent auth invalid token path=%s token_prefix=%s",
"agent auth invalid token path=%s",
request.url.path,
resolved[:6],
)
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
await _touch_agent_presence(request, session, agent)
@@ -170,9 +169,8 @@ async def get_agent_auth_context_optional(
if agent is None:
if agent_token:
logger.warning(
"agent auth optional invalid token path=%s token_prefix=%s",
"agent auth optional invalid token path=%s",
request.url.path,
resolved[:6],
)
return None
await _touch_agent_presence(request, session, agent)