OAuth M2M fails with scoped secrets because all-apis is always requested
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- go
- Domain
- authentication, backend
Research direction
Start with NewAuthenticatorWithScopes and GetScopes, where the issue reports that all-apis is appended unconditionally. Reproduce the scoped-secret flow with the provided SQL scope and verify that a nonempty caller-provided scope reaches the token request without requiring all-apis; confirm that the SQL connection succeeds.
Written by the indexing model from the issue text.
Description
Hi team! We are having trouble with service principal authentication following the introduction of scoped OAuth secrets. The M2M authenticator in databricks-sql-go unconditionally requests all-apis, but all-apis is no longer the default in the UI.
Steps to reproduce
- Create a Databricks service principal with access to a SQL warehouse.
- Generate an OAuth secret restricted to the
sqlscope. - Verify the credential directly:
curl --request POST \
--url "https://<workspace-host>/oidc/v1/token" \
--user "<client-id>:<client-secret>" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "scope=sql"
This succeeds and returns a token with scope sql.
- Connect using the Go driver's M2M authenticator:
authenticator := m2m.NewAuthenticator(
clientID,
clientSecret,
workspaceHost,
)
connector, err := dbsql.NewConnector(
dbsql.WithServerHostname(workspaceHost),
dbsql.WithPort(443),
dbsql.WithHTTPPath(warehouseHTTPPath),
dbsql.WithAuthenticator(authenticator),
)
if err != nil {
return err
}
db := sql.OpenDB(connector)
defer db.Close()
var result int
err = db.QueryRowContext(context.Background(), "SELECT 1").Scan(&result)
The connection fails before opening the SQL session:
oauth2: "access_denied" "Scopes 'all-apis' are not assigned to the client <redacted>"
Root cause
NewAuthenticatorWithScopes calls GetScopes, which always appends all-apis:
func GetScopes(hostName string, scopes []string) []string {
if !oauth.HasScope(scopes, "all-apis") {
scopes = append(scopes, "all-apis")
}
return scopes
}
The code comments say the behavior matches the underlying kernel unconditionally requiring all-apis.
Suggested fix: Investigate whether NewAuthenticatorWithScopes can pass through nonempty caller-provided scopes.
Thank you!
- Dominant language
- Go
- Stars
- 53
- Forks
- 66
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databricks/databricks-sql-go
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
databricks/databricks-sql-go#481 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
databricks/databricks-sql-go#480 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
databricks/databricks-sql-go#475 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
databricks/databricks-sql-go#474 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 62/100
databricks/databricks-sql-go#473 ·
All issues in databricks/databricks-sql-go
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·