Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Transport-error messages expose authenticated proxy passwords, and IPv6 NO_PROXY matching incorrectly routes direct traffic through the proxy.
3 open issues
What changed in this PR
This PR extends the proxy-support work in #20185 to Kiro Crew sign-in and token refresh, using explicit proxy selection without enabling .netrc credential discovery.
Changes:
- Routes authentication requests through the shared proxy resolver.
- Adds port-qualified
NO_PROXYhandling and proxy-aware CLI error messages. - Documents transport behavior and adds proxy-routing tests.
| File | Description |
|---|---|
test/test_update_feed_proxy.py |
Updates bypass-call expectations. |
test/test_sign_in_refresher.py |
Allows proxy arguments in the refresh fake. |
test/test_kas_login_signout_generation.py |
Allows proxy arguments in the session fake. |
test/test_kas_login_service.py |
Updates the login-service session fake. |
test/test_kas_login_loopback.py |
Updates the loopback session fake. |
test/test_kas_auth_shape_idp.py |
Updates the IdP session fake. |
test/test_kas_auth_proxy.py |
Adds authentication proxy and bypass coverage. |
test/test_kas_auth_flows.py |
Updates authentication request doubles. |
test/test_kas_auth_device.py |
Updates the device-login session fake. |
test/test_http_proxy.py |
Tests port-qualified bypass behavior. |
src/kiro_crew/http_proxy.py |
Checks effective ports for proxy bypasses. |
src/kiro_crew/cli_kas_login.py |
Adds proxy context to connection errors. |
src/kiro_crew/auth/service.py |
Applies proxy selection to service polling. |
src/kiro_crew/auth/refresh.py |
Applies proxy selection to all refresh paths. |
src/kiro_crew/auth/login/portal.py |
Proxies portal token exchange. |
src/kiro_crew/auth/login/external_idp.py |
Proxies external IdP token exchange. |
src/kiro_crew/auth/login/device.py |
Proxies social device authorization and polling. |
src/kiro_crew/auth/login/control_plane.py |
Proxies profile lookup requests. |
src/kiro_crew/auth/login/builder_id.py |
Proxies OIDC registration, authorization, and polling. |
docs/system-specs/modules/kas-auth.md |
Documents authentication proxy transport rules. |
Review effort: Balanced
| proxy = resolve_proxy(base) | ||
| if not proxy: | ||
| return "" | ||
| return f"; the request goes through your configured proxy ({proxy}) -- check it is reachable" |
There was a problem hiding this comment.
Fixed in f383f36. _configured_proxy_note() now passes the proxy URL through redact_log_via_context() before formatting, so http://user:pass@proxy:3128 prints as [REDACTED: credential]proxy:3128. Regression: test_unreachable_message_redacts_proxy_credentials in test/test_kas_auth_proxy.py.
| port = None | ||
| if port is None: | ||
| port = 443 if parsed.scheme in ("https", "wss") else 80 | ||
| if urllib.request.proxy_bypass(host) or urllib.request.proxy_bypass(f"{host}:{port}"): |
There was a problem hiding this comment.
Fixed in f383f36. The port-qualified check now builds [addr]:port when the host is an IPv6 literal, so NO_PROXY=[2001:db8::1]:8443 bypasses https://[2001:db8::1]:8443/token. Covered by test_environment_bypass_ipv6_port_qualified (match and non-matching port) and test_ipv6_port_qualified_check_keeps_brackets in test/test_http_proxy.py.
| Enterprise IdP endpoints are operator-configured, so the shared resolver | ||
| checks the effective port alongside the bare host -- the finding the GPT 6.1 | ||
| lane upheld on #31732. |
There was a problem hiding this comment.
Fixed in f383f36. Removed the ticket IDs and review/reporter history from both docstrings in test/test_kas_auth_proxy.py, keeping only the current-behavior explanation. check_comment_history.py now passes on this diff.
f383f36 to
a9b1b73
Compare
a9b1b73 to
b30dcfa
Compare
|
Rebased onto main to resolve conflicts with #31732 and #32445. At the author's request, the |
Every issuer request in the auth path now passes proxy=resolve_proxy(url), the helper the update check and MCP registry already use, so kirocrew kas login and token refresh work on a proxy-only network while the sessions keep trust_env off (no ~/.netrc credentials). The shared resolver now also checks a port-qualified NO_PROXY entry against the URL's effective port -- the defect the GPT 6.1 lane upheld on kirodotdev#31732. kirocrew kas login names the configured proxy in its unreachable-service and lost-contact errors. Part of kirodotdev#20185. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The kas login connection-error note printed the configured proxy URL verbatim, so an authenticated proxy's user:password reached stderr and captured login logs. The note now passes the URL through redact_log_via_context before formatting it. The port-qualified NO_PROXY check built "addr:port" from the bracketless hostname, so an IPv6 entry such as [2001:db8::1]:8443 never matched and the request went through the proxy. The check now keeps the brackets. Also drop ticket and review history from two test docstrings, which the comment-history gate rejects.
b30dcfa to
f713dcb
Compare
|
Thanks for this work, @okajun35. The same change landed on main in #36978 (merged 2026-11-14, commit c8f45fb): sign-in, polls, code exchange and every token refresh in |



Problem / Motivation
Goal:
kirocrew kas loginand token refresh reach the sign-in service on a proxy-only network.On a network whose only egress is an HTTP(S) proxy,
kirocrew kas loginand the dashboard's Sign in time out: every request to the issuer is dialed directly because aiohttp sessions do not readHTTP_PROXY/HTTPS_PROXY/NO_PROXYon their own, and each token refresh fails the same way afterwards. Reported by Zedmor on #20185.Why it matters
Sign-in is the onboarding gate: a fresh user on a proxy-only network cannot authenticate at all even though install worked, and an existing sign-in silently degrades once the token needs refreshing. The unreachable-service error also reads as "the service is down", sending users to retry instead of checking their proxy.
Not a goal
messaging_api/*_settings, source providers, web push, weixin, teams, URL fetching) — later splits of that issue.response_url/download path — landed separately in fix: send slack button replies and file downloads through the proxy #31732, which this PR builds on.trust_env=True: it would re-enable aiohttp's~/.netrccredential discovery on these requests.What changed (motivation → approach → change)
Symptom: sign-in and refresh dial the issuer directly, so proxy-required networks time out. Root cause: none of the auth call sites passed
proxy=, and the sessions correctly keeptrust_envoff, so the environment's proxy settings are never consulted. Change: every issuer request inkiro_crew.authnow passesproxy=resolve_proxy(url)— the helper the update check and MCP registry already use — covering device authorization, both poll loops, portal and external-IdP code exchange, control-plane profile lookup, and all three refresh paths (the sessionsauth/provider.pyanddashboard/sign_in_refresher.pycreate issue no requests themselves; their calls flow throughauth/refresh.py). Every control-plane host the profile lookup falls through to gets its ownresolve_proxy. On top of the port-qualifiedNO_PROXYcheck from #31732, the shared resolver insrc/kiro_crew/http_proxy.pynow also keeps an IPv6 literal's brackets ([2001:db8::1]:8443), treatswssas port 443, and falls back to the scheme's default port on an unparsable port instead of raising.kirocrew kas loginnames the configured proxy, with anyuser:password@redacted, in its unreachable-service and lost-contact errors, anddocs/system-specs/modules/kas-auth.mddocuments the transport rules.Backwards compatibility
Compatible: with no proxy variables configured every request resolves to a direct dial, exactly as today, and
NO_PROXYsemantics only get strictly more faithful.Removes nothing: the diff only adds request kwargs, a bypass check, and error text.
Tests
test/test_kas_auth_proxy.py(new): every issuer call site × {HTTPS-first, HTTPS-only, HTTP-fallback, direct} plusNO_PROXYcases (exact host, suffix, wildcard, port-qualified, unrelated host, custom IdP port), the control-plane fallback to a second host, the end-to-endbegin_device+ poll path, thetrust_env is Falsepin, and both CLI error messages including credential redaction.test_http_proxy.pyadds the IPv6 bracket cases, and it andtest_update_feed_proxy.pypin the resolver's two-step bypass check. Seven existing fakepost()doubles accept the newproxykwarg.Proof: PROVEN test/test_http_proxy.py::test_environment_bypass_ipv6_port_qualified[[2001:db8::1]:8443-None], test/test_http_proxy.py::test_ipv6_port_qualified_check_keeps_brackets, test/test_kas_auth_proxy.py::test_auth_request_uses_the_env_proxy[social-authorize-https-first], test/test_kas_auth_proxy.py::test_auth_request_uses_the_env_proxy[social-authorize-https-only], test/test_kas_auth_proxy.py::test_auth_request_uses_the_env_proxy[social-authorize-http-fallback] (head b30dcfa)
Manual verification
No live proxy host was available; coverage sits at the request seam (
aiohttp.ClientSession._requestkwargs, including the realtrust_envflag on live sessions) plus urllib's real environment readers forNO_PROXYsemantics.Related Issues
Part of #20185
Sibling sweep
Swept: git grep -nE "session\.(get|post|put|request|ws_connect)|ClientSession\(" -- src/kiro_crew/auth/ src/kiro_crew/cli_kas_login.py src/kiro_crew/dashboard/sign_in_refresher.py src/kiro_crew/dashboard/handlers/kas_login.py
Sibling: src/kiro_crew/auth/provider.py:82 -- not affected -- the session issues no requests; its refresh call flows through auth/refresh.py
Sibling: src/kiro_crew/dashboard/sign_in_refresher.py:121 -- not affected -- the session is only handed to ensure_fresh
Sibling: src/kiro_crew/auth/login/builder_id.py -- changed here
Sibling: src/kiro_crew/auth/login/control_plane.py -- changed here
Sibling: src/kiro_crew/auth/login/device.py -- changed here
Sibling: src/kiro_crew/auth/login/external_idp.py -- changed here
Sibling: src/kiro_crew/auth/login/portal.py -- changed here
Sibling: src/kiro_crew/auth/refresh.py -- changed here
Sibling: src/kiro_crew/auth/service.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/link_meta.py -- tracked in #20185
Sibling: src/kiro_crew/dashboard/messaging_api/teams_settings.py -- tracked in #20185
Pattern harvest
Rule candidate: review-prompt
Pattern: outbound aiohttp request to an external URL issued without an explicit proxy= argument while trust_env stays off -- #20185 tracks the remaining sweep.
Checklist
fix: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.