Skip to content

fix(auth): send the connector User-Agent on OAuth M2M requests - #562

Open
vuanhphung wants to merge 1 commit into
mainfrom
fix/issue-413-oauth-http-client
Open

vuanhphung wants to merge 1 commit into
mainfrom
fix/issue-413-oauth-http-client

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

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 WithTransport and 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

Driver State Notes
JDBC Partial Configured SDK HTTP, connector-UA gap; ClientConfigurator.java:63 @0ad7a49.
Python Partial Native configured HTTP carries UA; external providers own HTTP; unified_http_client.py:242, auth/oauth.py:340 @1fbbe28.
Go / Thrift Not supported → Supported Connector UA over request-time defaults; shared authenticator cache, SQL transport remains separate.
Go / kernel Supported, unchanged Native UA; caller transport rejected; kernel_config.go:95,166 @73b9a3a.
Node.js Partial Configured OAuth agents, connector-UA gap; OAuthManager.ts:62,84,105 @abedbbf.
Kernel Supported Configured HTTP/UA for discovery and grants; http.rs:524, oidc.rs:98 @5125f01.

Adversarial review: maintainer transport finding fixed; independent delta review found no issues. Bot approved rebased head 67fefb3 with 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.

@vuanhphung
vuanhphung marked this pull request as ready for review November 14, 2026 06:26

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung
vuanhphung force-pushed the fix/issue-413-oauth-http-client branch from 64ba30e to 2877915 Compare November 20, 2026 00:57

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

Comment thread auth/oauth/oauth.go Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

Comment thread auth/oauth/m2m/m2m.go Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

Comment thread auth/oauth/m2m/m2m.go Resolved
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

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.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

Comment thread auth/oauth/oauth.go Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

Comment thread auth/oauth/oauth.go Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

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.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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…

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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 — validateEndpoint only accepts endpoints whose host ends in a Databricks suffix. A token endpoint on the user's own configured hostName gets rejected too, so
    Judge's evidence: // Suffix matching (not the substring matching InferCloudFromHost uses for cloud

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@vuanhphung
vuanhphung force-pushed the fix/issue-413-oauth-http-client branch from d2b6ccf to 76461ca Compare November 23, 2026 23:56

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

@vuanhphung vuanhphung changed the title fix(auth): honor connector HTTP settings in OAuth M2M fix(auth): send the connector User-Agent on OAuth M2M requests Nov 24, 2026
@vuanhphung
vuanhphung force-pushed the fix/issue-413-oauth-http-client branch from 76461ca to 975d73a Compare November 24, 2026 03:51

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

Comment thread internal/client/client.go
if configurable, ok := authenticator.(interface {
WithHTTPClient(*http.Client) auth.Authenticator
}); ok {
httpClient := &http.Client{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@vuanhphung vuanhphung Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open at 975d73a: client.go:657-660 still omits http.DefaultClient.CheckRedirect. Keeping this thread open to track the deferred follow-up.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

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.

@vuanhphung
vuanhphung force-pushed the fix/issue-413-oauth-http-client branch from 975d73a to a21c43e Compare November 26, 2026 03:40

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.GetEndpoint and m2m.GetConfig now honor a ctx oauth2.HTTPClient, and that M2M traffic now follows http.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)

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Re the changelog nit: grant routing already follows http.DefaultClient.Transport on main (withTokenRequestTimeout copies the default client). The discovery/context-client difference is real and is documented in the PR description and the GetEndpoint/GetConfig comments. I’m retaining the previously approved changelog entry for this rebase-only pass; expanding that wording remains an optional follow-up.


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]>
@vuanhphung
vuanhphung force-pushed the fix/issue-413-oauth-http-client branch from a21c43e to 67fefb3 Compare November 26, 2026 17:57

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth M2M: token requests ignore the connector's User-Agent (WithUserAgentEntry not threaded into the token exchange)

1 participant