quiet robotBook a call

Kip

Sign-in gateway

Sign people in to Kip through your own gateway instead of the office password.

View as Markdown

With KIP_GATEWAY_SECRET set, a gateway in front of Kip (your own sign-in system, for example) can sign people in by adding three headers to each request it forwards. The office password keeps working alongside it.

File
KIP_GATEWAY_SECRET=at-least-32-random-characters-shared-only-with-the-gateway

Without the setting, these headers are ignored.

The headers

HeaderValue
x-kip-gateway-userThe person's name, base64url-encoded.
x-kip-gateway-tsThe time, in milliseconds since 1970.
x-kip-gateway-sigHMAC-SHA256 with the secret, over user.ts.METHOD.path

user is the base64url name as sent, METHOD is the HTTP method in capitals, and path includes the query string. Requests more than 60 seconds old are refused. The exact encoding is gatewaySignature in packages/core; use it if your gateway runs on Node.js:

TypeScript
import { gatewaySignature } from "@quietrobot/kip-core";

const user = Buffer.from("Dana").toString("base64url");
const ts = String(Date.now());
headers["x-kip-gateway-user"] = user;
headers["x-kip-gateway-ts"] = ts;
headers["x-kip-gateway-sig"] = gatewaySignature(process.env.KIP_GATEWAY_SECRET!, user, ts, req.method, url.pathname + url.search);

The person's name appears in the activity log as usual.

Keep it safe

  • Put Kip where only the gateway can reach it if you can. If not, use HTTPS between them.
  • Kip refuses form posts whose Origin names another host. Behind a gateway, Kip sees the gateway's address, not the public one. The gateway must check that form posts come from its own site, then either pass the public Host through unchanged or drop the Origin header.