Support HTTP Basic auth in API-key connections

Cursor's Admin API authenticates with the admin key as the HTTP
Basic auth username (empty password) and rejects Bearer tokens.
The API-key connection previously supported only Bearer and a
custom header (Anthropic's x-api-key); add a Basic-auth mode
selected by Registration.APIKeyBasicAuth, and reject providers
that set both it and APIKeyHeader.

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-05-28 23:44:28 +02:00
parent 72c35a9967
commit 0149ca4f55
6 changed files with 179 additions and 2 deletions

View File

@@ -71,6 +71,13 @@ func (r *Registry) Register(reg *Registration) error {
return fmt.Errorf("cannot register connector provider %q: missing DisplayName", reg.Provider)
}
// APIKeyBasicAuth and APIKeyHeader select different presentations of
// the same key; setting both is a programmer error with a silent
// winner (Client checks BasicAuth first). Reject it at startup.
if reg.APIKeyBasicAuth && reg.APIKeyHeader != "" {
return fmt.Errorf("cannot register connector provider %q: APIKeyBasicAuth and APIKeyHeader are mutually exclusive", reg.Provider)
}
r.mu.Lock()
defer r.mu.Unlock()
@@ -132,6 +139,18 @@ func (r *Registry) APIKeyHeader(p coredata.ConnectorProvider) string {
return ""
}
// APIKeyUsesBasicAuth reports whether an API-key connection for the
// given provider must present its key as an HTTP Basic auth username
// (empty password) instead of a Bearer token. Returns false for unknown
// providers and for providers that use the default Bearer scheme.
func (r *Registry) APIKeyUsesBasicAuth(p coredata.ConnectorProvider) bool {
if reg, ok := r.Get(p); ok {
return reg.APIKeyBasicAuth
}
return false
}
// ProviderOAuth2Scopes returns the OAuth2 scopes the access review
// driver for the given provider needs to list user accounts. Returns
// nil for providers that do not need any scopes (Notion, Intercom)