Repository navigation
fix(auth): send the connector User-Agent on OAuth M2M requests - #562
vuanhphung wants to merge 1 commit into
Conversation
64ba30e to
2877915
Compare
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with one low concern. I traced the cache/marker re-entrancy, the cloned OAuth TLS config with chain-only verification, and the discovery client copy, and they look correct. Endpoint validation newly rejects some hosts that cloud inference still accepts.
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Mostly solid: 1 medium concern (unbounded per-transport token-cache map). The PR description says WithSkipTLSHostVerify relaxes the OAuth check for the connector hostname. The code, CHANGELOG and tests all keep full OAuth verification, so the description should be updated to match.
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Mostly solid, with 1 medium concern: the shared cache map keyed by transport keeps every new transport alive. Discovery validation, the TLS hardening and the recursive-auth marker look correct, and tests cover them well.
|
The PR description now records the maintainer's post-round-1 R1-3 decision: built-in Thrift OAuth always verifies chain and hostname, superseding both original Finding 1 options. The stale name-skip wording is gone. Adversarial round 2 converged; the remaining cache-retention/disclosure items are fixed in 0d3b7f9, and redirects remain the accepted follow-up. This comment was generated with GitHub MCP. |
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 1 low concern. The cache partitioning, recursion marker, timeout composition and TLS hardening all check out against PooledTransport and the m2m code paths. The custom-TLS cache partition can't be reached through the public config today, since TLSConfig only ever carries MinVersion or the skip flag.
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
One medium concern. The transport, User-Agent, timeout and cache-partition wiring looks correct and is well tested. The new discovery-endpoint validation breaks AWS/GCP alias hosts, while the Azure equivalent still works.
|
Updated in dbb9860 to address both maintainer findings. OAuth discovery, grants and refreshes now always use the driver's verified, environment-proxy/system-root transport, never the caller's SQL transport: host rewrites/private TLS settings must not break cross-host issuers or expose the client secret to caller hooks. All copies of one authenticator again share one cache and lock, avoiding N discoveries/grants and restoring concurrent-startup single-flight. Connector User-Agent, shorter client timeout and existing request caps remain; SQL/CloudFetch routing and kernel behavior are unchanged. Updated docs, regression tests, live checks and benchmark results are in the PR body; the follow-up now awaits adversarial review. This comment was generated with GitHub MCP. |
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 High · 1 Low
Looks good, with one low concern. The code, README and CHANGELOG agree: OAuth uses a verified driver transport and authenticator copies share one cache. Two claims in the PR description don't match the code: that WithTransport carries OAuth, and that each caller-transport connector owns its cache. Please update the description.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟠 High — Disputed by the cross-check judge (it quotes
cache: c.cache,); a human should decide. Original finding: Every HTTP-client binding shares token/config state with the standalone authenticator, so a token or discovery configuration obtained through an unverified custom/default client can bypass discovery and TLS verification in a subsequently bound strict connector. Separate standalone and custom-client caches from the verified built-in partition, and add a custom-first/strict-second regression instead of asserting unconditional cache sharing. (Found by GPT-6.1 Sol · disputed by the judge)
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
internal/client/client.go:657— Whenever WithTransport is set, OAuth replaces it with a fresh default transport, so connector-specific proxies, custom roots, mTLS, and tracing still do not rea
Judge's evidence:if cfg.Transport != nil || (cfg.TLSConfig != nil && cfg.TLSConfig.InsecureSkipVerify) { oauthBase = PooledTransport(&con…
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 1 finding considered and dismissed by the judge
- 🟡 Medium
auth/oauth/oauth.go:86—validateEndpointonly accepts endpoints whose host ends in a Databricks suffix. A token endpoint on the user's own configuredhostNamegets rejected too, so
Judge's evidence:// Suffix matching (not the substring matching InferCloudFromHost uses for cloud
3609c63 to
6d0305e
Compare
d2b6ccf to
76461ca
Compare
76461ca to
975d73a
Compare
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, no findings. Each per-connection authenticator copy shares one token/config cache and lock. OAuth requests go through Go's default transports, resolved per request, with the connector UA; the caller's transport stays SQL-only. Nit: the anonymous WithHTTPClient interface is repeated in three places and could be one named type.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
| if configurable, ok := authenticator.(interface { | ||
| WithHTTPClient(*http.Client) auth.Authenticator | ||
| }); ok { | ||
| httpClient := &http.Client{ |
There was a problem hiding this comment.
🔵 Low — The new OAuth client only reuses http.DefaultClient's Transport and drops its CheckRedirect and Jar. The old code copied the whole default client in withTokenRequestTimeout, so any custom redirect policy was kept, and now it is lost. Copy the other fields from http.DefaultClient into the new client and add a redirect-policy test. This only affects apps that customise http.DefaultClient, so the impact is narrow.
🔀 Found by GPT-6.1 Sol · confirmed by the judge
There was a problem hiding this comment.
Confirmed as a limitation versus main, but it predates this routing revision: 76461ca already creates the UA client with only Transport and Timeout (client.go:660-663). Redirect-policy work was explicitly deferred in the prior accepted scope (also noted in the November 20 scope comment). This maintainer revision restores request-time transport routing, not all DefaultClient state; copying its Jar would additionally introduce cookies into discovery that main does not carry. Keeping global redirect/cookie policy as a separate follow-up rather than expanding this patch.
There was a problem hiding this comment.
Still open at 975d73a: client.go:657-660 still omits http.DefaultClient.CheckRedirect. Keeping this thread open to track the deferred follow-up.
|
Re the named-interface nit: the assertion occurs once in production; the other two instances are private HTTP-client recorders in tests in different packages. Sharing one name across those packages would add exported API solely to deduplicate test scaffolding, so I am retaining the small local assertions. |
975d73a to
a21c43e
Compare
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Nit
Looks good: one low concern. The per-request client routing, the shared token/config cache and the timeout capping are all correct, and the tests cover user-agent, caller-transport bypass, single-flight and timeouts. The one gap is that the CHANGELOG entry doesn't flag the discovery-routing behavior change.
Other findings
- ⚪ Nit — The changelog entry mentions only the User-Agent change. It leaves out that exported
oauth.GetEndpointandm2m.GetConfignow honor a ctxoauth2.HTTPClient, and that M2M traffic now followshttp.DefaultClient.Transport. Expand the entry to name both changes and mark it as a behavior change. (Found by Claude Opus 5.5 · confirmed by the judge)
|
Re the changelog nit: grant routing already follows This comment was generated with GitHub MCP. |
Attribute OAuth discovery, grants and refreshes without changing main's grant routing. Resolve default transports per request and retain shared authenticator caches and existing timeout caps. Fixes #413 Signed-off-by: Vu Anh Phung <[email protected]> Co-authored-by: Isaac <[email protected]>
a21c43e to
67fefb3
Compare
OAuth M2M discovery, grants and refreshes now send the connector User-Agent, preserving partner attribution without moving OAuth traffic to a private pool. Routing resolves Go's defaults per request; each authenticator retains one shared token/config cache and lock. Caller
WithTransportand SQL TLS options still do not configure OAuth, and connector timeouts still compose with the existing 60s token and 10s discovery caps.Grant routing matches main; discovery does too unless an application sets
http.DefaultClient.Transport, which now also carries discovery.Verification: rebased onto
319b145(after #565 and #595) without source/test patch changes; range-diff changes only the changelog hunk. The complete signed-off commit message is unchanged. The late-DefaultTransport regression fails with DNS lookup failure at 76461ca and passes after this fix.make test: 1,998 tests, 11 credential-gated skips; lint 0 issues; shuffled auth/client/root race, pure-Go build/vet, e2e/tools-tag checks, kernel-tagged build and full tagged suite pass on Go1.27.4. Three generated-file gofmt exceptions reproduce identically on main; changed files are formatted.Live Thrift and kernel invalid-client M2M checks pass without skips (1.430s / 1.531s, including PAT smoke checks). Thrift observes connector UA and rejects caller OAuth routing; PAT SELECT 1 and kernel closed-connection checks pass. Credentials remain PAT-only, so successful SP authentication and native wire-UA are unverified. Shared-warehouse timings are smoke checks, not performance measurements.
Pre-rebase synthetic grant/request benchmark versus then-main
73b9a3a, alternating build/execution order over three fresh processes/revision with six samples each: median 8.127 → 8.778µs (+8.01%, +0.651µs), 102 → 113 allocations. This measures forced grants/refreshes without network/TLS, not cached-token SQL traffic. Benchstat uses pinned x/perf because the approved proxy lacks@latest. The rebase adds no OAuth request-path changes, so the benchmark was not repeated.Cross-driver state
ClientConfigurator.java:63@0ad7a49.unified_http_client.py:242,auth/oauth.py:340@1fbbe28.kernel_config.go:95,166@73b9a3a.OAuthManager.ts:62,84,105@abedbbf.http.rs:524,oidc.rs:98@5125f01.Adversarial review: maintainer transport finding fixed; independent delta review found no issues. Bot approved rebased head
67fefb3with no new findings. The acknowledged global redirect/cookie-policy follow-up remains deferred.Fixes #413
This pull request and its description were written by Isaac.