OAuth M2M: token requests ignore the connector's User-Agent (WithUserAgentEntry not threaded into the token exchange)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- go
调研方向
首先阅读 auth/oauth/m2m/m2m.go 和 internal/client/client.go,重点关注用于创建 token source 的 context,以及应用 BuildUserAgent 的位置。跟踪 connector 的 OAuth M2M 路径,并验证 token 请求使用配置的 User-Agent,同时检查 auth/oauth/oauth.go 中另行指出的 endpoint 解析限制。完成的标准是,mintOAuthToken 审计条目能够识别配置的 connector,而不是 Go 的默认 client。
由索引模型根据 Issue 内容生成。
描述
Summary
When a connector authenticates with OAuth M2M (WithClientCredentials, or client credentials via DSN), the driver's token requests are issued with Go's default HTTP client, so they reach the workspace as Go-http-client/2.0 instead of the User-Agent configured through WithUserAgentEntry. Query traffic is attributed correctly — only the token exchange is anonymous.
This matters for ISV partner attribution: the Databricks partner program asks integrations to identify themselves via a programmatic User-Agent, and these token grants show up in system.access.audit as an unidentified generic Go client.
Current behavior
Connector configured as:
connector, err := dbsql.NewConnector(
dbsql.WithServerHostname(host),
dbsql.WithPort(443),
dbsql.WithHTTPPath(httpPath),
dbsql.WithClientCredentials(clientID, clientSecret),
dbsql.WithUserAgentEntry("MyISV_MyProduct/1.0"),
)
system.access.audit rows for the resulting activity (identifiers redacted):
| service_name | action_name | user_agent |
|---|---|---|
| workspace | workspaceInHouseOAuthClientAuthentication |
Go-http-client/2.0 |
| workspace | mintOAuthToken |
Go-http-client/2.0 |
| accounts | oidcTokenAuthorization |
godatabrickssqlconnector/1.13.0 (MyISV_MyProduct/1.0) |
The Thrift/query path carries the configured entry as expected; the token-mint requests do not.
Root cause
BuildUserAgent(cfg) is applied only to the Thrift HTTP client:
internal/client/client.go—thriftHttpClient.SetHeader("User-Agent", BuildUserAgent(cfg))
The M2M authenticator builds its token source with a hardcoded background context, so a caller has no way to supply an *http.Client — oauth2 takes its HTTP client from the context (oauth2.HTTPClient), and that context never leaves the package:
auth/oauth/m2m/m2m.go(onmain) —GetConfig(context.Background(), ...)andconfig.TokenSource(context.Background())
Because of that, neither WithUserAgentEntry nor WithTransport can influence token requests.
This is adjacent to a limitation already acknowledged in-tree for the endpoint-resolution path (auth/oauth/oauth.go):
NOTE: this client uses the default transport, matching the existing
oidc.NewProviderdiscovery below. A connector-supplied transport / TLS config (WithTransport,WithSkipTLSHostVerify) is not yet threaded into the OAuth endpoint-resolution path; that is a pre-existing limitation, tracked separately.
This report is that same limitation one step further along: the token exchange itself.
Expected behavior
Token requests (and ideally OIDC discovery) carry the same User-Agent as the rest of the connector's traffic — which is what BuildUserAgent's own doc comment states as the intent:
…used by the driver for Thrift, telemetry, and feature-flag requests so all traffic from a single connection is attributable to the same identifier in access logs.
Possible directions
- Thread the connector's HTTP client/context into the authenticator — e.g. have the connector pass an
*http.Clientbuilt with the driver's transport + User-Agent, and create the token source withcontext.WithValue(ctx, oauth2.HTTPClient, client). - Or expose an option to supply the token-exchange HTTP client, so callers can set headers without re-implementing the M2M flow.
We verified direction 1 works: injecting an *http.Client whose RoundTripper sets the User-Agent into the token source makes every mintOAuthToken audit row correctly attributed. We did not keep that as a workaround — replacing the built-in authenticator with an application-side copy of the credential flow would risk drifting from upstream on every release, which is exactly why we'd prefer this handled in the driver.
Environment
databricks-sql-gov1.13.0 — code path verified unchanged in v1.14.0 and onmain- Auth: OAuth M2M (client credentials, Databricks-managed service principal)
- Go 1.25, Linux
Happy to open a PR for direction 1 if you'd like it contributed.
- 主要语言
- Go
- 星标
- 53
- 派生
- 66
- 平均合并
- 7 小时 57 分钟
- 30 天内合并 PR
- 16
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
databricks/databricks-sql-go 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
databricks/databricks-sql-go#476 ·
-
难度 3/5 1-2 天 新手友好度 55/100
databricks/databricks-sql-go#481 ·
-
难度 4/5 3-5 天 新手友好度 52/100
databricks/databricks-sql-go#480 ·
-
难度 5/5 一周以上 新手友好度 35/100
databricks/databricks-sql-go#475 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 65/100
databricks/databricks-sql-go#474 ·
查看 databricks/databricks-sql-go 的全部 Issue
相似的 Issue
-
ai-generated
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 72/100
SiaFoundation/indexd#1116 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
triage
难度 2/5 1-3 小时 新手友好度 82/100
wakatime/wakatime-cli#1585 ·