shiftlabs Start free
Menu Connections

Connections

Exact hosts and an auth template, owned by an admin. The gateway applies it to every request a linked workflow sends to those hosts.

Create and link

An admin creates the connection. A developer links it to workflows. The workflow code then calls the host without credentials.

shellcurl
# Create or replace a connection (admin key).
# Answers the connection with its version.
curl -X PUT https://api.shiftlabs.org/v1/connections/stripe \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "hosts": ["api.stripe.com"],
    "template": {
      "headers": {"Authorization": "Bearer {{ secret.STRIPE_KEY }}"}
    }
  }'

# Link it (developer key).
# The list replaces the workflow's links; [] removes them all.
curl -X PUT https://api.shiftlabs.org/v1/workflows/refund-check/connections \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"connections": ["stripe"]}'
refund-check
import { workflow } from "shiftlabs";

export default workflow<{ id: string }>(async ({ payload, step }) => {
  // No Authorization header: the stripe connection sets it.
  const charge = await step.run("fetch charge", () =>
    fetch(`https://api.stripe.com/v1/charges/${payload.id}`)
      .then((r) => r.json()),
  );
  return charge.status;
});
  • Name

    1 to 63 lowercase letters, digits and hyphens, starting with a letter or digit. Workflows link it by this name.

  • Saving

    PUT replaces the whole connection and raises its version. Every secret the template names must already exist.

  • Linking

    A workflow uses only the connections linked to it. Linking an unknown name is refused. You can link before the first deploy.

  • Deleting

    Deleting a connection unlinks it everywhere and moves it to the trash for 7 days, with its links. An admin can restore it until then. Its name stays taken while it's there: a PUT returns 409. You can't delete a secret a connection uses. The API returns 409 with usedBy.

  • Admins create, change and delete connections. Developers link them to workflows. Everyone in the workspace, viewers included, can read connections and their templates. Templates contain expressions, not secret values.
  • A workspace holds 10 connections on the free tier. Creating one more returns 403 {"error": "quota exceeded", "limit": "connections", "max": 10}.
  • If an SDK requires an API key, pass a placeholder. The template replaces it. To set credentials in your code yourself, use secret stand-ins.

Hosts

A connection applies only to the hostnames it lists, matched exactly.

  • Exact names

    1 to 20 hostnames. No wildcards, ports or IP addresses: api.stripe.com does not cover files.stripe.com. Names are trimmed, lowercased and de-duplicated.

  • Shape

    At most 253 characters and at least two labels. Each label is 1 to 63 letters, digits or hyphens, not starting or ending with a hyphen, and the last one contains a letter.

  • https only

    A connection's credentials are only sent over https. A plain http:// request to a covered host is refused.

  • Overlaps

    When two connections linked to one workflow cover the same host, each request must pick one with x-shiftlabs-connection, or it is refused. The gateway strips the header before forwarding.

two connections cover api.stripe.com
await fetch("https://api.stripe.com/v1/transfers", {
  method: "POST",
  headers: {
    "content-type": "application/x-www-form-urlencoded",
    "x-shiftlabs-connection": "stripe-connect",
  },
  body: new URLSearchParams({ amount: "500", currency: "usd" }),
});

The header must name a connection linked to this workflow whose hosts include this host. If only one connection covers the host, you don't need the header.

Requests to hosts that no linked connection covers go out as your code sent them, with any stand-ins replaced.

The template

A JSON object with up to four parts. Every value is a template string: literal text with {{ expressions }} in it.

Template parts
PartKeysWhat the gateway does
headersHeader names, up to 128 characters.Sets each header, replacing any value the code sent.
queryParameter names, 1 to 128 characters.Sets each query parameter, replacing any the code sent.
pathOne template, starting with /.Replaces the whole path. Expression output is percent-encoded. The literal text around it is kept.
body.jsonJSON pointers, starting with /.Sets a string at each pointer, creating objects on the way. The request must send content-type: application/json and a JSON object.
body.formForm fields, 1 to 128 characters.Sets each field. The request must send content-type: application/x-www-form-urlencoded.
templateJSON
// Bearer token
{ "headers": { "Authorization": "Bearer {{ secret.STRIPE_KEY }}" } }

// Basic auth from two secrets
{ "headers": {
    "Authorization": "{{ basic(secret.TWILIO_SID, secret.TWILIO_TOKEN) }}" } }

// Key in the query string, account in the path
{ "query": { "key": "{{ secret.MAPS_KEY }}" },
  "path": "/v2/accounts/{{ var.ACCOUNT_ID }}/geocode" }

// Token in a JSON body field
{ "body": { "json": { "/auth/token": "{{ secret.PAGER_TOKEN }}" } } }

// Signed request: timestamp and HMAC of the final body
{ "headers": {
    "X-Timestamp": "{{ now() }}",
    "X-Signature": "{{ hmac_sha256(secret.SIGNING_KEY, now() ~ '.' ~ request.body) | base64 }}"
} }
  • At least one entry and at most 32, counted across all parts. Any other top-level key is refused. body patches json or form, not both.
  • Each template string is at most 2,048 characters, renders to at most 16 KiB, and nests expressions at most 32 deep.
  • Reserved headers cannot be set: Host, Content-Length, Transfer-Encoding, Connection, x-shiftlabs-connection, X-Shiftlabs-Tenant and X-Abuse-Contact.
  • Secrets the template names must exist when you save it. Vars are looked up on each request. If a var is not set, the request is refused.
  • The gateway patches the body, then the path, then the query, and renders headers last. Header templates see the final request. Only header templates can read request.body.
  • A path template replaces the path the code sent on every request to these hosts.

Expressions

Inside {{ }}: references, quoted text, functions, ~ to join and | to pipe.

References and syntax
ExpressionGives
secret.NAMEThe secret's value. Only the gateway sees it.
var.NAMEThe calling workflow's var: its own value, or the workspace value. See Vars.
request.method · request.hostThe outgoing request's method and hostname.
request.path · request.queryIts path, and its query string without the ?.
request.bodyIts body as text, up to 1 MiB. Header templates only.
oauth.access_tokenAn OAuth 2.0 connection's access token. Only the gateway sees it.
'text' · "text"Literal text, with \n and \t escapes. Use single quotes inside a JSON template to avoid escaping.
a ~ bThe two joined.
x | fThe same as f(x).
x | f(y)The same as f(x, y).
( … )Grouping.
Functions
FunctionGives
base64(x) · base64url(x) · hex(x)The text or bytes encoded.
urlencode(x)The text percent-encoded.
json(x)The text as a JSON string, quotes included.
lower(x) · upper(x) · trim(x)The text lowercased, uppercased or trimmed.
sha256(x)The SHA-256 digest, as bytes.
hmac_sha256(key, data) · hmac_sha512(key, data)The HMAC of data under key, as bytes.
basic(user, password)Basic and the base64 of user:password: a whole Authorization value.
now() · now_ms()The time in Unix seconds or milliseconds, the same for every template in one request.
uuid()A random UUID.

Bytes from sha256 and the HMACs come out as lowercase hex unless you pipe them to base64, base64url or hex. Functions that take text, and ~, don't accept bytes. Encode them first. Functions with no arguments still need their parentheses.

If a template fails at request time, the request is refused with 403 and the reason.

At the gateway

Every fetch your code makes goes through the egress gateway. It handles each request in this order. TCP connections your code opens go through the same gateway, under the rules in TCP.

  1. Destination

    Refuses IP addresses, ports other than 80 and 443, and any *.shiftlabs.org host. Allows a set number of requests a minute to one host: 30 on Free, 600 on Pro, and up to 6,000 on Enterprise. Applies to all requests, with or without a connection.

  2. Quota

    Counts the request against the workspace's outbound requests: 3,000 per 24 hours on the free tier, then 429. Requests refused by connection rules count too.

  3. Choose

    Finds the linked connections whose hosts include this host, or the one named in x-shiftlabs-connection. Without a match, the request goes out as sent.

  4. Apply

    Loads the secrets and vars the template names, patches the request and overwrites what the code set. Each use is audited as inject, with the connection, host and secret names.

  5. Send

    Every request carries X-Shiftlabs-Tenant and X-Abuse-Contact. A request a connection applied to is sent over https only and does not follow redirects. Your code gets the 3xx. If it re-issues the request, the rules apply again.

  6. Scrub

    If the response to that request echoes a secret, as it was sent (a query parameter or form field percent-encoded, with + for a space) or in a reversible encoding such as base64, hex or Basic auth, in a header or a text body, your code sees [redacted]. Signatures from sha256 and the HMACs stay visible. Binary bodies pass through unchanged.

Outbound requests · refund-check

4 · 600 a minute to one host · 1 rate limited
RequestStatusTime
GET api.stripe.comvia connection stripe200182 ms
GET api.stripe.comno connectionblockedconnection billing is not declared for workflow refund-check3 ms
POST hooks.slack.comno connection20095 ms
GET api.stripe.comvia connection stripe429 rate limitedrate limited: over 600 requests/min to api.stripe.com0 ms
Refusals: {"error": "egress_blocked", "reason": "…"} with x-shiftlabs-gateway: blocked
ReasonStatusWhen
connections stripe, stripe-connect all cover api.stripe.com; pick one with the x-shiftlabs-connection header403Two linked connections cover the host and the request names neither.
connection billing is not declared for workflow refund-check403x-shiftlabs-connection names a connection this workflow has not linked.
connection billing does not cover api.stripe.com403It names one whose hosts do not include this host.
credentials are only sent over https403The request to a covered host is plain http.
connection stripe patches the body; GET has none403A body.json or body.form template meets a GET or HEAD.
connection patches a JSON body; send content-type: application/json403The content type does not match the body part. The form part needs application/x-www-form-urlencoded. A JSON body that is not an object is refused as well.
request body too large for a connection that reads or patches it (1 MiB)403The template patches the body or reads request.body, and the body is over 1 MiB.
var ACCOUNT_ID used by connection maps is not set403The template names a var with no value for this workflow.
connection google isn't connected; an admin must connect it403An OAuth 2.0 connection no admin has connected yet.
connection google's OAuth sign-in was revoked or expired; an admin must reconnect it403The provider refused the connection's refresh token.
connection google's token couldn't be refreshed: the token endpoint answered 503403The access token expired while refreshes kept failing. The reason says why.
header X-Signature template produced a control character403A rendered header holds a line break or a NUL.
quota exceeded: egressPerDay=3000429The workspace's outbound requests for the last 24 hours are used up (3,000 on the free tier).
rate limited: over 30 requests/min to api.stripe.com429One host got more requests from the workspace in a minute than its plan allows: 30 on Free, 600 on Pro. The count starts again within a minute.

Every refusal shows in the run's outbound requests with its reason. The heading there also shows the workspace's limit for one host, and how many requests it refused, each marked 429 rate limited. Refusals about which connection applies, or a missing var, are also written to the audit log as blocked.

OAuth 2.0

An OAuth 2.0 connection signs in to an API, such as Google's, with your own OAuth client. An admin connects it once in the dashboard. The vault keeps the access and refresh tokens and refreshes the access token before it expires. The template sends it as {{ oauth.access_token }}, and workflow code never receives either token.

Create one in the dashboard or with the API. In New connection, choose HTTP, then oauth2 under Credentials, and enter your OAuth client's authorize, token and optional revoke URLs, client ID, client secret, scopes and extra authorize parameters. The form shows the redirect URI to register, and the template starts as {"headers": {"Authorization": "Bearer {{ oauth.access_token }}"}}. With the API:

shellcurl
# The OAuth client's secret is a secret like any other (admin key).
curl -X PUT https://api.shiftlabs.org/v1/secrets/GOOGLE_CLIENT_SECRET \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"value": "GOCSPX-…"}'

# Create the connection. Without a template, requests get
# Authorization: Bearer {{ oauth.access_token }}.
curl -X PUT https://api.shiftlabs.org/v1/connections/google \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "hosts": ["www.googleapis.com"],
    "oauth2": {
      "authorizeUrl": "https://accounts.google.com/o/oauth2/v2/auth",
      "tokenUrl": "https://oauth2.googleapis.com/token",
      "revokeUrl": "https://oauth2.googleapis.com/revoke",
      "clientId": "1234-abcd.apps.googleusercontent.com",
      "clientSecret": "{{ secret.GOOGLE_CLIENT_SECRET }}",
      "scopes": ["https://www.googleapis.com/auth/drive.readonly"],
      "extraAuthorizeParams": {"access_type": "offline", "prompt": "consent"}
    }
  }'
  • Your OAuth client

    Add https://app.shiftlabs.org/oauth/callback to your OAuth client's redirect URIs. The client and its consent screen are yours.

  • Connect

    An admin opens the connection on the Connections screen and chooses Connect. The provider asks them to consent, then sends them back to the dashboard, and the connection shows Connected. Workflows link it like any connection.

  • Refresh

    The vault refreshes the access token when 2 minutes or less are left. While the token endpoint fails, it tries again at most every 30 seconds.

  • Disconnect

    Disconnect revokes the token at revokeUrl, if you set one, and forgets both tokens. Requests through the connection are refused until an admin connects it again.

  • authorizeUrl, tokenUrl and revokeUrl are https URLs on port 443 with a public hostname. clientSecret is a template that uses secrets only. Up to 50 scopes, and up to 16 extraAuthorizeParams, which can't set response_type, client_id, redirect_uri, scope, state, code_challenge or code_challenge_method.
  • The template must use {{ oauth.access_token }}, and only an OAuth 2.0 connection's template can.
  • Google returns a refresh token only with access_type=offline and prompt=consent. Without one, the connection stays Not connected and says why.
  • The admin who chooses Connect must finish in the same session within 10 minutes.
  • Saving the connection with the same client and scopes keeps its tokens. A change to authorizeUrl, tokenUrl, revokeUrl, clientId, clientSecret or scopes forgets them, and an admin connects it again. Deleting it, or saving it without oauth2, forgets them too. Each of these also revokes the old tokens at the old revokeUrl, if one was set. In the dashboard, Edit asks before a save that would forget a connected connection's tokens, with Save and forget tokens.
  • Reconnect replaces the stored sign-in without revoking it. Some providers, Google included, end the app's whole access to the account on any revoke, which would end the new sign-in too. Disconnect first to revoke the old sign-in, for example before connecting a different account. A reconnect that gets no refresh token does revoke the one it replaced.
  • Each change of status is audited. A change a refresh makes goes to the workspace's alert emails and webhook as connections.status.
Status
StatusMeansRequests through it
Not connected (pending)No admin has connected it, or the provider sent no refresh token.Refused
Connected (connected)The vault holds a token and refreshes it.Get the access token
Refresh failed (refresh_failed)The token endpoint failed or couldn't be reached. lastError says why.Get the current token until it expires, then refused
Revoked (revoked)The provider refused the refresh token, such as after someone removed the app's access.Refused until an admin connects it again

TCP

A TCP connection lists exact host:port targets, such as a Postgres, MySQL or Redis server. Workflow code that links it can open TCP connections to those targets, and to nothing else. For Postgres and Redis, the connection can also hold a login: the gateway logs in with a secret, and your code never holds the password. Pro and Enterprise workspaces have TCP connections. Free workspaces don't.

shellcurl
# Create or replace a TCP connection (admin key).
# Answers the connection with its version.
# The gateway logs in to Postgres as report, with the secret PG_PASSWORD.
curl -X PUT https://api.shiftlabs.org/v1/connections/prod-db \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "protocol": "tcp",
    "targets": ["db.example.com:5432"],
    "tls": "postgres",
    "auth": {
      "postgres": {"user": "report", "password": "{{ secret.PG_PASSWORD }}"}
    }
  }'

# Link it like any connection (developer key).
curl -X PUT https://api.shiftlabs.org/v1/workflows/nightly-report/connections \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"connections": ["prod-db"]}'
nightly-report
import postgres from "postgres";
import { workflow } from "shiftlabs";

export default workflow(async ({ step }) => {
  return step.run("count orders", async () => {
    // TLS off and any password: the prod-db connection adds TLS, and the
    // gateway logs in.
    const sql = postgres({
      host: "db.example.com",
      port: 5432,
      database: "shop",
      username: "report",
      ssl: false,
      password: "x",
    });
    try {
      const [row] = await sql`select count(*)::int as n from orders`;
      return row.n;
    } finally {
      await sql.end();
    }
  });
});
  • Targets

    1 to 20 host:port entries. The host follows the rules for hosts: an exact name, no wildcards, never an IP address, and never shiftlabs.org or a subdomain. The port is 1 to 65535. Targets are lowercased, de-duplicated and sorted.

  • Exact address

    Code connects to a target exactly as listed. db.example.com:5432 does not cover db.example.com:5433.

  • Its own kind

    A TCP connection takes targets, tls and auth, not hosts or template. To reuse an HTTP connection's name for a TCP one, or the reverse, delete it, then delete it for good from the trash.

  • One per target

    A workflow can link only one TCP connection that covers a target.

cloudflare:sockets
import { connect } from "cloudflare:sockets";

// The address must be a target of a TCP connection linked to this workflow.
const socket = connect("db.example.com:5432");
const writer = socket.writable.getWriter();
const reader = socket.readable.getReader();

TypeScript code can use cloudflare:sockets, node:net or a driver built on them. Python code can use socket, asyncio or a driver such as asyncpg.

Ports never allowed
PortsUsed for
23Telnet
25, 465, 587, 2525SMTP (sending mail)
135, 137-139, 445Windows RPC and SMB
1900, 5353Discovery
6660-6669, 6697IRC
  • Special-use names are never targets: names under .local, .localhost, .internal, .home.arpa, .test, .invalid and .onion don't name a public server.
TLS modes: tls is required
tlsWhat the gateway does
offSends plain text to the server. Use it only on a network you trust.
onSpeaks TLS from the first byte, as rediss:// does.
postgresSends Postgres' SSLRequest, then upgrades to TLS. Use it for every Postgres server: Postgres 17's direct TLS needs a TLS option the gateway can't send.
mysqlReads the MySQL server's greeting, then upgrades to TLS inside MySQL's handshake. Use it for MySQL and MariaDB servers.
  • Connect with TLS off in your code: ssl: false, ssl=False or sslmode=disable. The gateway adds TLS as tls says. Code that asks for TLS itself, with secureTransport: "on" or "starttls", or node:tls, fails. A driver that sends an SSLRequest anyway gets "no" when tls is postgres. With tls mysql, your driver is shown a server without TLS, and a driver that asks for TLS anyway is refused.
  • With tls mysql, MySQL 8's caching_sha2_password asks for the password itself on a user's first login after the server starts. Your driver sees no TLS, so it asks for the server's RSA key: the gateway answers with a key of its own, then sends the password to the server over TLS. mysql2 does this by default.
  • The gateway checks the server's certificate against public certificate authorities only. Managed databases that use a private CA, such as Amazon RDS, Google Cloud SQL, Supabase, DigitalOcean and Aiven, fail verification. Neon and Azure use public CAs.
  • The TLS the gateway adds can't present a client certificate or trust a private CA. Reach a server that needs either from your own runner: see Client certificates and private CAs.
  • With tls off, your code chooses every byte the target gets. A target that is a proxy (HTTP CONNECT, SOCKS), or a front that routes by TLS server name, reaches whatever it forwards to. Declare one only if the workflow may reach all of that.
  • Targets per workspace

    tcpTargets, counted across all TCP connections: none on Free, 20 on Pro, and as agreed on Enterprise. GET /v1/usage returns tcpTargets, and limits.tcpTargets is the most you can declare.

  • Connections

    TCP and HTTP connections count together toward the workspace's connections.

  • Rate

    10 new connections a minute to one target from the workspace.

  • Length

    A connection lasts at most 15 minutes and carries at most 1 GiB each way. It also ends when the workflow step's invocation ends.

  • Outbound requests

    Each connection that passes the address, port and rate checks counts as one outbound request toward the workspace's quota, including one that no TCP connection covers.

  • On Free, saving a TCP connection returns 403 {"error": "TCP connections need the Pro plan", "limit": "tcpTargets", "max": 0}.
  • Saving more targets than tcpTargets allows returns 403 {"error": "quota exceeded", "limit": "tcpTargets", "max": 20}.
shellcurl
# The gateway logs in as the ACL user worker, with the secret REDIS_PASSWORD.
curl -X PUT https://api.shiftlabs.org/v1/connections/cache \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "protocol": "tcp",
    "targets": ["cache.example.com:6380"],
    "tls": "on",
    "auth": {
      "redis": {"user": "worker", "password": "{{ secret.REDIS_PASSWORD }}"}
    }
  }'
  • auth

    Optional: a gateway login for Postgres or Redis. It holds one of postgres or redis, with a user and a password. The password is a template string, with the same {{ secret.NAME }}, {{ var.NAME }} and pipes. It must use at least one secret, and it can't use request values.

  • The secret

    It needs neither hosts nor readable. The gateway uses it, and your code never receives it. While a connection's auth uses a secret, the secret can't be deleted. Restoring a connection from the trash whose login's secret is gone returns 409 with the secret in missing.

  • Postgres

    user is required. Your code connects with TLS off, and any user and password, or none. The gateway puts the connection's user in place of your code's, and keeps the database and the other settings. With tls on or postgres, it logs in with SCRAM-SHA-256, MD5 or a cleartext password. With tls off, it logs in only with SCRAM-SHA-256 of at least 4,096 iterations, so nobody on the path can crack the password offline. It checks the server's SCRAM-SHA-256 proof. Then it tells your code the login succeeded. A driver's cancel requests pass to the server unchanged. A Postgres login with tls mysql is refused with 400 {"error": "auth.postgres needs tls off, on or postgres"}.

  • Redis

    tls must be on: AUTH carries the password as written, so a Redis login with off, postgres or mysql is refused with 400 {"error": "auth.redis needs tls on"}. user is optional. Without it, the gateway logs in as Redis' default user. The gateway sends AUTH before any of your code's commands. Your code's own AUTH gets +OK from the gateway, with any password. A HELLO loses its AUTH part. Other commands go to the server as sent.

  • Without auth

    Your code logs in itself, with a readable secret. See Passwords over TCP below.

Redis' default user

  • Log in as an ACL user without admin commands, for example one with -@admin.
  • Redis' default user, with requirepass, can run CONFIG GET requirepass. That returns the password to whoever is logged in, your workflow code included.

Postgres users

  • Any Postgres user can change its own password with ALTER ROLE CURRENT_USER PASSWORD '…', workflow code included. With the new password, code could log in to the server directly.
  • Give the connection's user only the privileges the workflow needs.
  • Alert on ALTER ROLE in the server's logs, and on failed gateway logins: each is an error in the workspace's outbound traffic.

Passwords over TCP

  • Postgres and Redis: use a gateway login with auth. The secret needs neither hosts nor readable, and your code never receives it.
  • SSH, MySQL and other servers: a secret an admin marks readable. Your code reads it with reveal("NAME"), or ctx.reveal("NAME") in Python.
  • A readable secret is the weaker model: the value reaches your code. Every load is audited, and the value is replaced by [redacted] in logs, in the run's output and in errors.
  • Apart from a login, and MySQL's handshake with tls mysql, the gateway never reads inside a TCP stream. HTTP templates don't apply there, and a stand-in stays literal text.

A refusal reaches your code in the protocol it speaks, and the connection closes. A Postgres client gets a FATAL error (SQLSTATE 08004) whose message starts shiftlabs: . A Redis client gets -ERR shiftlabs: <reason>. Once a target with tls mysql is allowed, a MySQL client gets a server error whose message starts shiftlabs: . Anything else gets one text line, shiftlabs: <reason>. When a Postgres server refuses the gateway's login, or a MySQL server refuses the connection, your code gets the server's own error instead.

Refusals over TCP
ReasonWhen
TCP connections need the Pro planThe workspace has no TCP targets.
port 25 is never allowedThe port is one of the ports never allowed.
TCP targets must be hostnames, not IP addressesThe code connected to an IP address.
connections to shiftlabs.org are not allowed from workflowsThe host is shiftlabs.org or a subdomain.
.local names are not allowedThe host is a special-use name.
no TCP connection linked to workflow nightly-report covers db.example.com:5433No TCP connection the workflow links lists this host:port.
rate limited: over 10 connections/min to db.example.com:5432More than 10 new connections to one target in a minute.
quota exceeded: egressPerDay=1000000The workspace's outbound requests for the last 24 hours are used up.
could not connect to db.example.com:5432: <detail>The server could not be reached. The detail says why.
db.example.com:5432 does not offer TLStls is on, postgres or mysql, and the server didn't start TLS, or its MySQL greeting doesn't offer it.
db.example.com:3306 did not send a MySQL greetingtls is mysql, and the server's first packet isn't a MySQL greeting.
db.example.com:3306 sent no MySQL greeting within 10 stls is mysql, and the server sent no greeting within 10 seconds.
db.example.com:3306 sent more than its greeting before TLStls is mysql, and the server sent more bytes after its greeting, before TLS started.
db.example.com:3306 refused the connection: <error>tls is mysql, and the server sent an error instead of a greeting, such as for a host it doesn't allow. Your code gets the server's own error, as the server sent it.
the code asked for TLS; connect with TLS off, and tls mysql adds ittls is mysql, and your code's driver asked for TLS itself.
the code did not answer the MySQL greetingtls is mysql, and your code sent no handshake response within 10 seconds.
the code's MySQL handshake response is malformedtls is mysql, and your code's handshake response isn't one MySQL 4.1 or later sends.
the address is not a valid host:portThe address the code connected to isn't a hostname and a port, such as a number or a URL. The reason never repeats the address.
password authentication failed for user "report"Postgres refused the gateway's login. Your code gets the server's own error, as the server sent it.
the server refused the login: WRONGPASS invalid username-password pair or user is disabled.Redis refused the gateway's login. The reason ends with the server's error line.
the server asks for a cleartext password, which the gateway sends only over TLS; set tls to on or postgresPostgres asked for a cleartext password, and tls is off.
the server asks for an MD5 password, which the gateway sends only over TLS; set tls to on or postgresPostgres asked for an MD5 password, and tls is off.
the server offers <mechanisms>; the gateway logs in with SCRAM-SHA-256Postgres offered a SASL login without SCRAM-SHA-256.
the server asks for a login the gateway doesn't support (authentication method <n>)Postgres asked for a login other than SCRAM-SHA-256, MD5 or a cleartext password.
the server could not prove it knows the passwordThe server's SCRAM-SHA-256 proof was wrong or missing.
the server sent an unexpected message during the loginThe server's login messages came out of order.
the server asks for <n> SCRAM iterations; the gateway allows 1 to 100,000The server's SCRAM-SHA-256 login asks for too many iterations. With tls off, the gateway allows 4,096 to 100,000.
the server did not finish the login within 10 sThe whole login took longer than 10 seconds.
the server refused the login with an error that isn't shown, since it may echo the passwordRedis answered the gateway's AUTH with an error other than WRONGPASS or NOAUTH.
connection prod-db changed since its login was saved; save it againAn older version of shiftlabs changed the connection without its login. Save it again with its auth.
the code did not open a Postgres connectionThe connection has a Postgres login, and your code didn't start a Postgres connection.
secret PG_PASSWORD used by connection prod-db no longer existsA secret the login uses was deleted.
var DB_SUFFIX used by connection prod-db is not setA var the login uses is not set.
  • Firewalls

    The addresses TCP connections come from are not published, so a database that allow-lists IP addresses can't allow-list shiftlabs yet.

  • Unreachable targets

    Connections can't reach Cloudflare's own addresses or private addresses. A target hosted behind Cloudflare, or a name that resolves to a private address, gets could not connect to <host:port>: <detail>.

  • SSH

    Workflows have no SSH client.

  • Agents

    Agents reach a database only through a workflow. Their code tools have no network.

  • Audit

    Each connection the gateway allows is audited as socket, with the connection name, the host:port, its tls mode, its login in auth (postgres, redis or null) and the secrets the login uses. A connection to a target that no linked TCP connection covers, or whose login's secret or var is gone, is audited as blocked.

  • Outbound traffic

    Each attempt is recorded with its target, port, outcome, bytes each way and duration. A failed login is recorded as an error, with its reason. TCP traffic carries no run, so it isn't listed under a run's outbound requests.

Client certificates and private CAs

Workflow code can't present a client certificate (mTLS) or trust a private certificate authority. Reach such a server from a runner in your network instead, with step.exec or a registered activity. The certificate, its key and the CA stay in files on the runner's host.

ledger-balance
import { workflow } from "shiftlabs";

export default workflow(async ({ step }) => {
  // The files are on the runner's host, mounted into its container.
  const r = await step.exec("ledger balance", {
    command: [
      "curl", "-fsS",
      "--cert", "/etc/ledger-tls/client.crt",
      "--key", "/etc/ledger-tls/client.key",
      "--cacert", "/etc/ledger-tls/ca.crt",
      "https://ledger.corp.example.com/v1/balance",
    ],
  });
  return r.stdout;
});
  • Mount the folder into the runner's container read-only, such as -v /srv/ledger-tls:/etc/ledger-tls:ro with Docker. The files must be readable by uid 1000.
  • Don't store the key, the certificate or the CA as a shiftlabs secret. Left on the runner's host, they never reach shiftlabs.
  • For a server with a private CA that asks for no client certificate, --cacert alone is enough. Any client on the runner works the same way, such as Python's ssl.
  • A command's requests leave from the runner's host, not through the gateway, so connections don't apply to them.
  • The gateway's own fetch sends no client certificate and checks servers against public certificate authorities only, as its TCP TLS does.

Dashboard and API

Manage connections in the dashboard or with the /v1 API. Roles are the same in both.

  • Connections screen

    Every connection with its hosts, the secrets and vars its template uses, its version, and an OAuth 2.0 connection's status, last refresh and who connected it. Admins create one with a name, hosts one per line and the template in a JSON editor, and for an OAuth 2.0 connection, oauth2 under Credentials with its client's URLs, client ID, client secret, scopes and extra authorize parameters. They edit or delete it from its panel, where they also connect or disconnect an OAuth 2.0 connection. Edit asks before a save that changes a connected OAuth 2.0 client and so forgets its tokens.

  • Workflows screen

    Open a workflow and find its Connections section. Developers and admins choose Edit links, tick the connections the workflow uses and save.

  • Audit

    connection_put, connection_delete, connection_restore, connection_purge, workflow_link, inject, socket, blocked, and for OAuth 2.0 oauth_connect, oauth_refresh, oauth_refresh_failed, oauth_revoked and oauth_disconnect, for admins on the Audit screen and at /v1/audit.

Routes
RouteMethodMinimum role
/v1/connections [{name, hosts, template, secrets, vars, version, updatedAt}]; TCP connections add protocol, targets, tls and auth, and their secrets and vars are the ones auth's password uses; OAuth 2.0 connections add oauth2 and oauth: {status, lastError, refreshedAt, consentedBy, consentedAt}GETviewer
/v1/connections/:name {"hosts", "template"}, {"hosts", "oauth2", "template"?} for OAuth 2.0, or {"protocol": "tcp", "targets", "tls", "auth"?} for TCP; returns the connectionPUTadmin
/v1/connections/:name {"deleted": name, "purgeAt"}; moves it to the trash for 7 days, and its name stays taken while it's there (409); or 404DELETEadmin
/v1/connections/:name/oauth/start {url}, the provider's consent page; from the dashboard onlyPOSTadmin
/v1/connections/oauth/callback {"code", "state"} from the provider's redirect; returns the connection; from the dashboard onlyPOSTadmin
/v1/connections/:name/oauth revokes and forgets the tokens; returns the connectionDELETEadmin
/v1/workflows/:workflow/connections the linked namesGETviewer
/v1/workflows/:workflow/connections {"connections": [...]}; returns the linked namesPUTdeveloper