Skip to main content

HTTP Data Connectors

· 8 min read

proxiML now supports HTTP data connectors, letting your jobs call your own and your vendors' HTTP APIs without exposing API keys, client secrets, or certificates to job code. Configure the connection once at the region level, attach it to a job, and your code makes plain HTTP calls to a local proxiML hostname while proxiML handles authentication to the upstream API.

How It Works​

We announced PostgreSQL and Redis data connectors earlier this week. Today's connector completes the set: HTTP. An HTTP connector points at an API's hostname and port, and proxiML:

  • Stores the connection's credentials, encrypted at rest, and never returns them through the proxiML API.
  • When a job using the connector starts, runs a pass-through HTTP proxy between the job and your API and injects the configured authentication on every request.
  • Gives the job a local hostname, http://CONNECTOR_ID.proximl.internal, instead of the API's real address. The job's network egress is fenced to the connector, so it can only reach the API through it.

The proxy is a full pass-through: any method, path, query string, headers, and body, streamed in both directions without buffering. That makes it suitable for large uploads and long-running responses, not just small request/response calls.

Supported Authentication​

The HTTP connector supports five auth methods, the broadest of any connector type:

Username and Password -- The connector injects an Authorization: Basic header on every request.

API Key -- The connector sends the key in the header you choose (API Key Header, required) with an optional value prefix (API Key Prefix). For example, header Authorization with prefix Bearer produces Authorization: Bearer <key> -- the setup for the large majority of vendor APIs -- while header X-Api-Key with no prefix sends the raw key.

Certificate -- The connector presents a client certificate over a mutual TLS (mTLS) connection. For APIs that gate access by client certificate.

OAuth Client Secret -- The connector performs the client credentials grant against your token endpoint (Token URL), using the Client ID and Client Secret, and injects the resulting token into the Authorization header with the Bearer prefix by default. Tokens are cached and refreshed automatically ahead of expiry, so long-running jobs do not hammer your identity provider. Optional Scopes are requested with the grant.

OAuth Private Key -- For identity providers that support JWT client assertions (private key JWT), the connector signs a single-use assertion with your Client Private Key -- EC keys use ES256, RSA keys use RS256 -- exchanges it at the Token URL, and injects the token, with the same caching and refresh behavior as above.

All methods support a Use TLS toggle (on by default) and an optional CA Certificate. When TLS is enabled, the connector talks to the API over TLS and verifies its certificate against the CA certificate you provide, or the system certificate store when you leave it blank. When TLS is off, the connection to the API is plaintext. Certificate auth always requires TLS, so the toggle is locked on for it.

Two behaviors worth knowing about, both about keeping your credentials out of the job:

  • The connector strips any authentication headers the job sends (Authorization, Proxy-Authorization, Cookie, X-Api-Key, X-Goog-Api-Key) and injects its own. A job cannot override the connector's identity, and a compromised job cannot present stolen credentials to the API under a different identity.
  • For API Key and OAuth methods, the header name and prefix are part of the connector configuration, not the job.

Using the Web Platform​

Select View Region from the action menu of the region that can reach the API, then click the Add button on the Data Connectors toolbar.

  • Name -- A unique name for the connector (lowercase letters, digits, and hyphens).
  • Type -- HTTP.
  • Host -- The hostname of the API (e.g. api.example.com).
  • Port -- The port the API listens on. Defaults to 443 with TLS enabled and 80 with TLS disabled.
  • Use TLS -- Connect to the API over TLS. On by default and locked on for Certificate auth.
  • CA Certificate -- Optional PEM-encoded CA certificate. Shown when TLS is enabled. Pins the CA to verify the API's certificate against; when left blank the system certificate store is used.
  • Auth Method -- One of the five methods above. The form shows only the fields the selected method needs:
    • Username and Password: Username, Password.
    • API Key: API Key, API Key Header (required), optional API Key Prefix.
    • Certificate: Client Certificate, Client Private Key (PEM).
    • OAuth Client Secret: Client ID, Client Secret, Token URL, optional Scopes, optional Authorization Header (defaults to Authorization) and Authorization Prefix (defaults to Bearer ).
    • OAuth Private Key: Client ID, Token URL, Client Private Key (PEM), optional Scopes, optional Authorization Header and Authorization Prefix.

The connector is saved when you click Submit. When editing an existing connector, leave a secret field blank to keep its current value, or enter a new value to rotate it. The connector type and auth method cannot be changed after creation.

Using the SDK​

Create an API-key connector (the bearer-style header, the most common setup):

connector = await proximl.cloudbender.data_connectors.create( provider_uuid="PROVIDER_ID", region_uuid="REGION_ID", name="vendor-api", type="http", host="api.example.com", port=443, auth_type="api_key", api_key="API_KEY", authorization_header="Authorization", authorization_prefix="Bearer ", )

An API key sent in a custom header with no prefix (e.g. X-Api-Key: API_KEY):

connector = await proximl.cloudbender.data_connectors.create(
provider_uuid="PROVIDER_ID",
region_uuid="REGION_ID",
name="vendor-api-raw",
type="http",
host="api.example.com",
port=443,
auth_type="api_key",
api_key="API_KEY",
authorization_header="X-Api-Key",
authorization_prefix="",
)

An OAuth client credentials connector:

connector = await proximl.cloudbender.data_connectors.create(
provider_uuid="PROVIDER_ID",
region_uuid="REGION_ID",
name="corp-api",
type="http",
host="api.corp.example.com",
port=443,
auth_type="oauth_client_secret",
client_id="proxiML-client",
client_secret="CLIENT_SECRET",
token_url="https://auth.corp.example.com/oauth/token",
scopes="read write",
)

An OAuth private key JWT connector:

connector = await proximl.cloudbender.data_connectors.create(
provider_uuid="PROVIDER_ID",
region_uuid="REGION_ID",
name="corp-api-jwt",
type="http",
host="api.corp.example.com",
port=443,
auth_type="oauth_private_key",
client_id="proxiML-client",
token_url="https://auth.corp.example.com/oauth/token",
client_private_key=open("client.pem").read(),
)

Then enable the connector for your project (from the Data Connectors section of the project page) and attach it to a job by its ID:

job = await proximl.jobs.create(
name="http-job",
type="training",
gpu_type="rtx3090",
gpu_count=1,
data=dict(connectors=[connector.id]),
)

Inside the job, call the API through the connector's local hostname with no credentials of your own:

import requests

# No Authorization header here -- the connector injects it.
resp = requests.get(
"http://vendor-api-0123456789abcdef.proximl.internal/v1/datasets",
timeout=30,
)
resp.raise_for_status()
print(resp.json())

Use the connector's actual ID (shown in the Data Connectors grid, returned by create, or listed with data_connectors.list) in place of the placeholder above. Paths, methods, queries, and bodies all pass through unchanged -- the local port is always 80.

Using the CLI​

# List connectors in a region (ID, NAME, TYPE, HOST, AUTH_TYPE, PROTOCOL)
trainml cloudbender data_connector list --provider PROVIDER_ID --region REGION_ID

# Create an API key connector sent as "Authorization: Bearer <key>" (TLS on by default)
trainml cloudbender data_connector create vendor-api \
--provider PROVIDER_ID --region REGION_ID \
--type http --host api.example.com --port 443 \
--auth-type api_key --api-key "API_KEY" \
--authorization-header Authorization --authorization-prefix "Bearer "

# Create an API key connector sent raw in a custom header, plaintext upstream
trainml cloudbender data_connector create vendor-api-raw \
--provider PROVIDER_ID --region REGION_ID \
--type http --host api.internal.example.com --port 8080 \
--no-tls --auth-type api_key --api-key "API_KEY" \
--authorization-header X-Api-Key --authorization-prefix ""

# Create an OAuth client secret connector
trainml cloudbender data_connector create corp-api \
--provider PROVIDER_ID --region REGION_ID \
--type http --host api.corp.example.com --port 443 \
--auth-type oauth_client_secret \
--client-id proxiML-client --client-secret "CLIENT_SECRET" \
--token-url https://auth.corp.example.com/oauth/token \
--scopes "read write"

# Create a certificate-authenticated connector
trainml cloudbender data_connector create mtls-api \
--provider PROVIDER_ID --region REGION_ID \
--type http --host api.mtls.example.com --port 443 \
--auth-type certificate \
--ca-certificate-file ca.crt \
--client-certificate-file client.crt \
--client-private-key-file client.key

# Rotate an API key without re-entering the other settings
trainml cloudbender data_connector edit vendor-api \
--provider PROVIDER_ID --region REGION_ID \
--api-key "NEW_API_KEY"

# Remove a connector
trainml cloudbender data_connector remove vendor-api \
--provider PROVIDER_ID --region REGION_ID

Security Notes​

  • Credentials are encrypted at rest with the same passphrase scheme proxiML uses for other secrets, and secret fields are never returned by the proxiML API.
  • The job's network egress is restricted to its connectors, so a job can only talk to the API through the authenticated connector and cannot discover or reach the API's real address.
  • Client-supplied authentication headers are always stripped and replaced by the connector's own, as described above.

See the CloudBender reference for the full data connector field reference, and revisit the PostgreSQL and Redis announcements for the rest of this week's set.