feat(agentex): forward user session cookie to agent pods via acp headers#250
Open
cdvillegas wants to merge 2 commits into
Open
feat(agentex): forward user session cookie to agent pods via acp headers#250cdvillegas wants to merge 2 commits into
cdvillegas wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
@greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Summary
PR #245 added
x-acting-user-api-keyfor API-key callers. Browser and Ops Hub users authenticate with the_identityJwtsession cookie, so agent pods still had no delegatable credential.This PR extends runtime delegation v1 for cookie-based auth:
x-api-keypresent: forward asx-acting-user-api-key(unchanged from feat(agentex): forward user api key to agent pods via acp headers #245).Cookieheader and forward only allowlistedname=valuepairs onx-acting-user-cookie. Never replay the full browserCookieheader (no CSRF, analytics, or third-party cookies)._identityJwt(Scale Ops Hub / EGP / Spark). No Helm change required for default deployments.AGENTEX_DELEGATION_SESSION_COOKIE_NAMES(comma-separated). Unset = default. Empty string = cookie delegation disabled (API key path only).x-acting-user-cookie,x-selected-account-id,x-api-key, and rawcookieremain blocked on client passthrough; delegation values are server-set only.cookie(in addition to existing api-key redaction).Agent SDK
PassthroughResolverand agent-side SGP consumption remain follow-up work.Test Plan
tests/unit/domain/test_delegation_headers.py: API key and cookie paths, API key precedence, env unset/empty/override for cookie names, skip when no principal or agent identity, no credential.test_send_message_includes_cookie_delegation_headersonAgentACPService: asserts only_identityJwtis forwarded when extra cookies are present.TestFilterRequestHeaders: acting cookie and selected-account-id spoof headers stripped from passthrough.Linear Issue
Resolves AGX1-293
Greptile Summary
This PR extends ACP runtime delegation for browser/Ops Hub users who authenticate via the
_identityJwtsession cookie rather than an API key. After successful auth, agentex parses the inboundCookieheader and forwards only allowlisted cookie name-value pairs (default:_identityJwt) on the newx-acting-user-cookieheader; API key takes precedence when both are present.delegation_headers.py):_minimal_session_cookieuses Python'sSimpleCookieto parse and extract only configured cookie names, controlled byAGENTEX_DELEGATION_SESSION_COOKIE_NAMES(unset =_identityJwt; empty = disabled; comma-separated = override).agent_acp_service.py):x-acting-user-cookieandx-selected-account-idadded toBLOCKED_HEADERSso clients cannot inject these into agent-pod-bound requests; delegation values are set server-side only.request_utils.py):r"cookie"added to the key blacklist so raw cookie values are stripped from request logs.Confidence Score: 5/5
Safe to merge. The cookie delegation logic is well-scoped: only allowlisted cookie names are extracted and forwarded, the full browser Cookie header never reaches agent pods, and newly added BLOCKED_HEADERS entries close the client-spoofing gap on both the new and existing delegation headers.
The allowlist approach with
SimpleCookieis correct —morsel.valuereturns only the parsed value without surrounding whitespace or quoting artefacts, and thetry/except CookieErrorprovides a safe fallback. The merge order inget_headersensures server-set delegation values always win over any client passthrough. Test coverage spans every documented behavioral variant. No logic errors or security gaps were found.No files require special attention.
Important Files Changed
_minimal_session_cookieallowlist filter usingSimpleCookie, env-configured cookie names, and API-key precedence. Logic is correct and secure.x-acting-user-cookieandx-selected-account-idtoBLOCKED_HEADERS, preventing client spoofing of delegation and account-selection headers. Correct anti-spoofing change.r"cookie"to the logging redaction blacklist so raw cookie values are stripped from request logs. Correct and minimal change._identityJwtis forwarded and updates spoofing test to include new blocked headers.Reviews (3): Last reviewed commit: "fix(agentex): forward only configured se..." | Re-trigger Greptile