CXH-2166: implement PAT (workspace token) authentication - #54
CXH-2166: implement PAT (workspace token) authentication#54al-conductorone wants to merge 1 commit into
Conversation
Re-add the personal-access-token auth path removed in e84a1ae so the connector matches its docs. Workspace tokens authenticate per-workspace against the Databricks Workspace API and scope the sync to the workspaces those tokens belong to; OAuth stays the default. - config: restore workspaces + workspace-tokens fields and the OAuth/token constraints; OAuth client id/secret are no longer hard-required - auth: restore TokenAuth, selecting the token by workspace host prefix so Azure dotted deployment names match correctly - connector: token-aware Validate and prepareClientAuth; thread workspaces through to the workspace builder - workspace builder: build minimal workspace resources from the configured list when the Account API is unavailable (token auth)
| func NewTokenAuth(workspaces, tokens []string) *TokenAuth { | ||
| tokensMap := make(map[string]string, len(workspaces)) | ||
| for i, workspace := range workspaces { | ||
| tokensMap[workspace] = tokens[i] | ||
| } | ||
|
|
||
| return &TokenAuth{tokens: tokensMap} | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion (low confidence): NewTokenAuth indexes tokens[i] while ranging over workspaces, so it panics with index-out-of-range if len(tokens) < len(workspaces). In practice ValidateConfig enforces equal lengths before this is reached, so no panic occurs today — but that invariant lives far away in pkg/config. Consider guarding here (e.g. skip when i >= len(tokens)) to make this exported constructor safe on its own.
Connector PR Review: CXH-2166: implement PAT (workspace token) authenticationBlocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0 Review SummaryScanned the full PR diff for security and correctness. This PR adds per-workspace personal-access-token auth alongside OAuth: a new Security IssuesNone found. Tokens are marked Correctness IssuesNone found. Suggestions
Prompt for AI agents |
| field.FieldsMutuallyExclusive( | ||
| DatabricksClientIdField, | ||
| WorkspaceTokensField, | ||
| ), | ||
| field.FieldsRequiredTogether( | ||
| DatabricksClientIdField, | ||
| DatabricksClientSecretField, | ||
| ), | ||
| field.FieldsDependentOn( | ||
| []field.SchemaField{WorkspaceTokensField}, | ||
| []field.SchemaField{WorkspacesField}, | ||
| ), |
There was a problem hiding this comment.
@al-conductorone Would it make sense to use FieldGroups for OAuth and PAT? I think it might simplify these relationships.
| WorkspaceTokensField, | ||
| BaseURLField, | ||
| } | ||
| fieldRelationships = []field.SchemaFieldRelationship{ |
There was a problem hiding this comment.
Instead of field relationships we probably want to keep required fields and use different group fields
| databricksClientSecret := cfg.DatabricksClientSecret | ||
| accountHostname := getAccountHostname(cfg, cfg.Hostname) | ||
| if len(cfg.WorkspaceTokens) > 0 { | ||
| l.Info("using workspace token auth", zap.String("account-id", cfg.AccountId)) |
There was a problem hiding this comment.
unreachable info log, i don't think it is needed. you can keep it as debug log or remove it entirely
| return databricks.NewTokenAuth(cfg.Workspaces, cfg.WorkspaceTokens) | ||
| } | ||
|
|
||
| l.Info("using oauth", zap.String("account-id", cfg.AccountId)) |
There was a problem hiding this comment.
same here. we should avoid noisy logs as much as we can
The Databricks connector can again authenticate with per-workspace personal access tokens, matching the setup docs, so customers who use workspace tokens instead of OAuth can connect. Additive change: OAuth stays the default and existing setups are unaffected.