mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-18 08:19:19 +00:00
feat: reconcile per-mailbox Cloud health with current reporting and verify mixed report availability
This commit is contained in:
@@ -46,8 +46,10 @@ function configuration(env) {
|
||||
}
|
||||
const bake = Number(String(env.DEPLOY_BAKE_SECONDS ?? "").trim() || 300);
|
||||
if (!Number.isInteger(bake) || bake < 0 || bake > 3600) throw new Error("DEPLOY_BAKE_SECONDS must be 0 through 3600");
|
||||
const fleetBake = Number(String(env.DEPLOY_FLEET_BAKE_SECONDS ?? "").trim() || 300);
|
||||
if (!Number.isInteger(fleetBake) || fleetBake < 300 || fleetBake > 3600) throw new Error("DEPLOY_FLEET_BAKE_SECONDS must be 300 through 3600");
|
||||
return {
|
||||
cluster, prefix, mode, tag, services, allServices: raw === "all", secretVersions, bake,
|
||||
cluster, prefix, mode, tag, services, allServices: raw === "all", secretVersions, bake, fleetBake,
|
||||
fleet: env.DEPLOY_FLEET !== "false",
|
||||
allowDroppedSecrets: env.DEPLOY_ALLOW_DROPPED_SECRETS === "true",
|
||||
images: env.DEPLOY_IMAGES_JSON ? JSON.parse(readFileSync(env.DEPLOY_IMAGES_JSON, "utf8")) : null,
|
||||
@@ -169,8 +171,9 @@ async function logTail(clients, definition, task, report, quiet) {
|
||||
|
||||
// runTask runs a one-off task to completion; capture may be a predicate the log tail must meet.
|
||||
async function runTask(clients, config, network, arn, definition, label, sleep, report, options = {}) {
|
||||
const { command, environment, capture } = Array.isArray(options) ? { command: options } : options;
|
||||
const token = createHash("sha256").update(`${config.run}/${arn}/${label}/${JSON.stringify(command || [])}/${JSON.stringify(environment || [])}`).digest("hex");
|
||||
const { command, environment, capture, imagePullRetries = 0, pullAttempt = 0 } = Array.isArray(options) ? { command: options } : options;
|
||||
const identity = `${config.run}/${arn}/${label}/${JSON.stringify(command || [])}/${JSON.stringify(environment || [])}`;
|
||||
const token = createHash("sha256").update(identity + (pullAttempt ? `/pull-retry-${pullAttempt}` : "")).digest("hex");
|
||||
const name = definition.containerDefinitions[0].name;
|
||||
const override = { name, ...(command ? { command } : {}), ...(environment ? { environment } : {}) };
|
||||
const started = assertResponse(await clients.ecs.send(new RunTaskCommand({
|
||||
@@ -189,7 +192,16 @@ async function runTask(clients, config, network, arn, definition, label, sleep,
|
||||
const container = status.containers?.find((c) => c.name === name);
|
||||
const ok = status.stopCode === "EssentialContainerExited" && container?.exitCode === 0;
|
||||
let lines = !ok || command || capture ? await logTail(clients, definition, task, report, ok && capture) : [];
|
||||
if (!ok) throw new Error(`${label} failed; its log tail is above`);
|
||||
if (!ok) {
|
||||
const neverStarted = !status.startedAt && status.containers?.length > 0 && status.containers.every((c) => c.exitCode === undefined);
|
||||
const pullFailure = status.stopCode === "TaskFailedToStart" && /^CannotPullContainerError:/.test(status.stoppedReason || "");
|
||||
if (neverStarted && pullFailure && pullAttempt < imagePullRetries) {
|
||||
report(`${label} image pull failed before execution; retry ${pullAttempt + 1}/${imagePullRetries} with the same definition and overrides`);
|
||||
await sleep(30000 * (pullAttempt + 1));
|
||||
return runTask(clients, config, network, arn, definition, label, sleep, report, { ...options, pullAttempt: pullAttempt + 1 });
|
||||
}
|
||||
throw new Error(`${label} failed (${status.stopCode || "unknown stop code"}); inspect stopped task ${task}; its log tail is above`);
|
||||
}
|
||||
// Log delivery can trail the task stopping by a few seconds.
|
||||
for (let retry = 0; typeof capture === "function" && !capture(lines) && retry < 6; retry++) {
|
||||
await sleep(5000);
|
||||
@@ -383,10 +395,10 @@ async function deploy(clients, config, sleep = (ms) => new Promise((r) => setTim
|
||||
const digests = ["worker", "worker-kafka", "consumer", "consumer-kafka"]
|
||||
.filter((k) => DIGEST_RE.test(config.images.images?.[k] || ""))
|
||||
.map((k) => `${k}=${config.images.images[k]}`);
|
||||
const command = ["fleet", "rollout", "start", tag, "--canary", "1", "--waves", "100", "--bake", "30m"];
|
||||
const command = ["fleet", "rollout", "start", tag, "--canary", "1", "--waves", "100", "--bake", `${config.fleetBake}s`];
|
||||
if (digests.length) command.push("--digests", digests.join(","));
|
||||
await runTask(clients, config, network, arns.ops, rendered.ops, "Fleet rollout", sleep, report, { command });
|
||||
report(`Workers move to ${tag} in canary waves; follow with \`warmblyctl fleet rollout status\``);
|
||||
await runTask(clients, config, network, arns.ops, rendered.ops, "Fleet rollout", sleep, report, { command, imagePullRetries: 2 });
|
||||
report(`Workers move to ${tag}: one canary, then all remaining hosts, with ${config.fleetBake}s of healthy uptime per stage plus update time; follow with \`warmblyctl fleet rollout status\``);
|
||||
}
|
||||
return { tag, arns, pins: Object.fromEntries(Object.entries(pins).map(([arn, v]) => [secretService(arn, config.prefix) || arn, v])) };
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ const assert = require("node:assert/strict");
|
||||
const { mkdtempSync, writeFileSync } = require("node:fs");
|
||||
const { join } = require("node:path");
|
||||
const { tmpdir } = require("node:os");
|
||||
const { configuration, deploy, compareTags, parseRef } = require("./aws-deploy.cjs");
|
||||
const { configuration, deploy, runTask, compareTags, parseRef } = require("./aws-deploy.cjs");
|
||||
|
||||
const root = "arn:aws:ecs:us-east-1:000000000000:";
|
||||
const registry = "ghcr.io/warmbly/warmbly";
|
||||
@@ -149,6 +149,11 @@ const valueFrom = (def, key) => def.containerDefinitions[0].secrets.find((s) =>
|
||||
test("configuration refuses prereleases, bad modes and secret pins outside refresh-secrets", () => {
|
||||
assert.throws(() => config({ DEPLOY_TAG: "v1.3.0-rc.1" }), /prereleases never deploy/);
|
||||
assert.throws(() => config({ DEPLOY_MODE: "yolo" }), /DEPLOY_MODE/);
|
||||
for (const value of ["0", "299", "3601", "NaN", "300.5"]) {
|
||||
assert.throws(() => config({ DEPLOY_FLEET_BAKE_SECONDS: value }), /DEPLOY_FLEET_BAKE_SECONDS/);
|
||||
}
|
||||
assert.equal(config().fleetBake, 300);
|
||||
assert.equal(config({ DEPLOY_FLEET_BAKE_SECONDS: "1800" }).fleetBake, 1800);
|
||||
assert.throws(() => config({ DEPLOY_SERVICES: "backend,worker" }), /DEPLOY_SERVICES/);
|
||||
assert.throws(() => config({ DEPLOY_SECRET_VERSIONS: JSON.stringify({ backend: "a".repeat(36) }) }), /refresh-secrets/);
|
||||
assert.throws(() => config({ DEPLOY_MODE: "refresh-secrets", DEPLOY_SECRET_VERSIONS: JSON.stringify({ backend: "x" }) }), /secret version id/);
|
||||
@@ -286,10 +291,66 @@ test("the fleet rollout gets the worker and consumer digests per variant", async
|
||||
const ops = runs(f).find((r) => r.overrides);
|
||||
const command = ops.overrides.containerOverrides[0].command;
|
||||
assert.deepEqual(command.slice(0, 4), ["fleet", "rollout", "start", "v1.3.0"]);
|
||||
assert.equal(command[command.indexOf("--bake") + 1], "300s");
|
||||
assert.equal(command[command.indexOf("--digests") + 1], `worker=${d("b")},worker-kafka=${d("c")},consumer=${d("b")},consumer-kafka=${d("c")}`);
|
||||
assert.equal(ops.overrides.containerOverrides[0].name, "ops");
|
||||
});
|
||||
|
||||
test("hosted fleet rollout carries a configured longer bake", async () => {
|
||||
const f = fixture();
|
||||
await run(f, config({ DEPLOY_FLEET_BAKE_SECONDS: "1800" }));
|
||||
const command = runs(f).find((r) => r.overrides).overrides.containerOverrides[0].command;
|
||||
assert.equal(command[command.indexOf("--bake") + 1], "1800s");
|
||||
});
|
||||
|
||||
test("fleet startup retries only confirmed image-pull failures before execution, with stable retry tokens", async () => {
|
||||
const pullFailure = { lastStatus: "STOPPED", stopCode: "TaskFailedToStart", stoppedReason: "CannotPullContainerError: manifest not found", containers: [{ name: "ops", runtimeId: "allocated-before-pull" }] };
|
||||
const success = { lastStatus: "STOPPED", stopCode: "EssentialContainerExited", containers: [{ name: "ops", exitCode: 0 }] };
|
||||
async function attempt(statuses, options = {}) {
|
||||
const requests = [], sleeps = [];
|
||||
const clients = {
|
||||
ecs: { async send(command) {
|
||||
if (command.constructor.name === "RunTaskCommand") {
|
||||
requests.push(command.input);
|
||||
return { tasks: [{ taskArn: `${root}task/fixture/${requests.length}` }] };
|
||||
}
|
||||
return { tasks: [statuses[Math.min(requests.length - 1, statuses.length - 1)]] };
|
||||
} },
|
||||
logs: { async send() { return { events: [] }; } },
|
||||
};
|
||||
const execute = () => runTask(clients, config(), {}, "fixture-ops:3", definition("ops", 3, {}), "Fleet rollout", async (ms) => sleeps.push(ms), () => {}, { command: ["fleet", "rollout", "start", "v1.3.0"], imagePullRetries: 2, ...options });
|
||||
return { execute, requests, sleeps };
|
||||
}
|
||||
const recovered = await attempt([pullFailure, success]);
|
||||
await recovered.execute();
|
||||
assert.equal(recovered.requests.length, 2);
|
||||
assert.deepEqual(recovered.sleeps, [30000]);
|
||||
assert.deepEqual(recovered.requests[0].overrides, recovered.requests[1].overrides);
|
||||
assert.equal(recovered.requests[0].taskDefinition, recovered.requests[1].taskDefinition);
|
||||
assert.notEqual(recovered.requests[0].clientToken, recovered.requests[1].clientToken);
|
||||
const replay = await attempt([pullFailure, success]);
|
||||
await replay.execute();
|
||||
assert.deepEqual(replay.requests.map((r) => r.clientToken), recovered.requests.map((r) => r.clientToken));
|
||||
const exhausted = await attempt([pullFailure]);
|
||||
await assert.rejects(exhausted.execute(), /Fleet rollout failed/);
|
||||
assert.equal(exhausted.requests.length, 3);
|
||||
assert.deepEqual(exhausted.sleeps, [30000, 60000]);
|
||||
for (const failure of [
|
||||
{ ...success, containers: [{ name: "ops", exitCode: 1 }] },
|
||||
{ ...pullFailure, startedAt: new Date() },
|
||||
{ ...pullFailure, containers: [{ name: "ops", exitCode: 1 }] },
|
||||
{ ...pullFailure, containers: [] },
|
||||
{ ...pullFailure, stoppedReason: "ResourceInitializationError: unavailable" },
|
||||
]) {
|
||||
const failed = await attempt([failure]);
|
||||
await assert.rejects(failed.execute(), /Fleet rollout failed/);
|
||||
assert.equal(failed.requests.length, 1);
|
||||
}
|
||||
const migration = await attempt([pullFailure], { imagePullRetries: 0 });
|
||||
await assert.rejects(migration.execute(), /failed/);
|
||||
assert.equal(migration.requests.length, 1);
|
||||
});
|
||||
|
||||
test("an unchanged definition reuses its revision and redeploy forces a fresh deployment", async () => {
|
||||
const f = fixture();
|
||||
await run(f, config({ DEPLOY_SERVICES: "forms", DEPLOY_FLEET: "false" }));
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
export function summarizeLiveTests(input, outcome) {
|
||||
const tests = new Map();
|
||||
const subtests = new Map();
|
||||
const failedPackages = new Set();
|
||||
for (const line of input.split("\n")) {
|
||||
let event;
|
||||
try {
|
||||
event = JSON.parse(line);
|
||||
} catch {
|
||||
continue; // Compiler diagnostics can be plain text alongside go test JSON.
|
||||
}
|
||||
if (!event || typeof event !== "object") continue;
|
||||
if (event.Action === "fail" && typeof event.Package === "string" && !event.Test) {
|
||||
failedPackages.add(event.Package);
|
||||
}
|
||||
if (typeof event.Test !== "string" || !event.Test.startsWith("TestLive")) continue;
|
||||
if (!["pass", "fail", "skip"].includes(event.Action)) continue;
|
||||
const results = event.Test.includes("/") ? subtests : tests;
|
||||
results.set(`${event.Package}/${event.Test}`, event.Action);
|
||||
}
|
||||
const names = (action) => [...tests].filter(([, result]) => result === action).map(([name]) => name).sort();
|
||||
const passed = names("pass");
|
||||
const failed = names("fail");
|
||||
const skipped = names("skip");
|
||||
const skippedSubtests = [...subtests].filter(([, result]) => result === "skip").map(([name]) => name).sort();
|
||||
const list = (heading, entries) => [
|
||||
`### ${heading}`,
|
||||
"",
|
||||
...(entries.length ? entries.slice(0, 200).map((name) => `- \`${name.replaceAll("`", "\\`")}\``) : ["None recorded."]),
|
||||
...(entries.length > 200 ? ["", "Showing the first 200 entries; see the complete output artifact."] : []),
|
||||
"",
|
||||
];
|
||||
return {
|
||||
needsAttention: outcome !== "success" || tests.size === 0 || failed.length > 0 || skipped.length > 0 || skippedSubtests.length > 0 || failedPackages.size > 0,
|
||||
markdown: [
|
||||
"## PostgreSQL catch-all (advisory)",
|
||||
"",
|
||||
`Test step outcome: **${outcome || "not started"}**. This job is outside the required CI Status aggregate while #1078 is triaged.`,
|
||||
"",
|
||||
"| Top-level TestLive results | Count |",
|
||||
"| --- | ---: |",
|
||||
`| Passed | ${passed.length} |`,
|
||||
`| Failed | ${failed.length} |`,
|
||||
`| Skipped | ${skipped.length} |`,
|
||||
"",
|
||||
...(tests.size === 0 ? ["No completed TestLive results were recorded. Check setup, compilation and timeouts.", ""] : []),
|
||||
...list("Failed packages (including setup or build failures)", [...failedPackages].sort()),
|
||||
...list("Failed tests", failed),
|
||||
...list("Skipped tests and subtests", [...skipped, ...skippedSubtests]),
|
||||
"Full JSON events and compiler output are retained in the postgres-live-advisory artifact. Subtests are included there; counts above include each top-level test once.",
|
||||
"",
|
||||
].join("\n"),
|
||||
};
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
const file = process.argv[2];
|
||||
const report = summarizeLiveTests(file && existsSync(file) ? readFileSync(file, "utf8") : "", process.env.LIVE_TEST_OUTCOME);
|
||||
if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, report.markdown);
|
||||
else process.stdout.write(report.markdown);
|
||||
if (report.needsAttention) console.log("::warning::Advisory PostgreSQL coverage needs triage. See the job summary and complete output artifact.");
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { summarizeLiveTests } from "./live-tests-summary.mjs";
|
||||
|
||||
const events = (...rows) => rows.map((row) => JSON.stringify(row)).join("\n");
|
||||
|
||||
test("reports failures, skips and failed packages without counting subtests twice", () => {
|
||||
const report = summarizeLiveTests(events(
|
||||
{ Action: "pass", Package: "app", Test: "TestLivePassed/child" },
|
||||
{ Action: "pass", Package: "app", Test: "TestLivePassed" },
|
||||
{ Action: "fail", Package: "repository", Test: "TestLiveFailed/child" },
|
||||
{ Action: "fail", Package: "repository", Test: "TestLiveFailed" },
|
||||
{ Action: "fail", Package: "repository" },
|
||||
{ Action: "skip", Package: "app", Test: "TestLiveSkipped" },
|
||||
{ Action: "pass", Package: "app", Test: "TestOther" },
|
||||
), "failure");
|
||||
assert.equal(report.needsAttention, true);
|
||||
assert.match(report.markdown, /\| Passed \| 1 \|/);
|
||||
assert.match(report.markdown, /\| Failed \| 1 \|/);
|
||||
assert.match(report.markdown, /\| Skipped \| 1 \|/);
|
||||
assert.match(report.markdown, /`repository\/TestLiveFailed`/);
|
||||
assert.match(report.markdown, /`app\/TestLiveSkipped`/);
|
||||
assert.doesNotMatch(report.markdown, /\/child/);
|
||||
});
|
||||
|
||||
test("empty, interrupted and compile-only output cannot look like passing coverage", () => {
|
||||
for (const input of ["", "# app\ncompiler error", 'null\n{"Action":"fail","Package":"app"}']) {
|
||||
const report = summarizeLiveTests(input, "failure");
|
||||
assert.equal(report.needsAttention, true);
|
||||
assert.match(report.markdown, /No completed TestLive results/);
|
||||
}
|
||||
assert.equal(summarizeLiveTests(events({ Action: "pass", Package: "app", Test: "TestLiveOK" }), "cancelled").needsAttention, true);
|
||||
});
|
||||
|
||||
test("successful coverage is clean only when completed tests contain no skips", () => {
|
||||
assert.equal(summarizeLiveTests(events({ Action: "pass", Package: "app", Test: "TestLiveOK" }), "success").needsAttention, false);
|
||||
assert.equal(summarizeLiveTests(events({ Action: "skip", Package: "app", Test: "TestLiveSkipped" }), "success").needsAttention, true);
|
||||
});
|
||||
|
||||
test("a skipped subtest is actionable even when its parent passes", () => {
|
||||
const report = summarizeLiveTests(events(
|
||||
{ Action: "skip", Package: "app", Test: "TestLiveExample/needs-fixture" },
|
||||
{ Action: "pass", Package: "app", Test: "TestLiveExample" },
|
||||
), "success");
|
||||
assert.equal(report.needsAttention, true);
|
||||
assert.match(report.markdown, /\| Passed \| 1 \|/);
|
||||
assert.match(report.markdown, /\| Skipped \| 0 \|/);
|
||||
assert.match(report.markdown, /`app\/TestLiveExample\/needs-fixture`/);
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export function previewURL(entries, project, sha) {
|
||||
const matches = entries.filter(deployment => deployment.type === 'pages-deploy-detailed'
|
||||
&& deployment.version === 1
|
||||
&& deployment.pages_project === project
|
||||
&& deployment.environment === 'preview'
|
||||
&& deployment.deployment_trigger?.metadata?.commit_hash === sha
|
||||
&& typeof deployment.deployment_id === 'string' && deployment.deployment_id.length > 0);
|
||||
assert.equal(matches.length, 1, 'Require one Wrangler preview receipt for this project and commit');
|
||||
const url = new URL(matches[0].url);
|
||||
assert.equal(url.protocol, 'https:');
|
||||
assert.ok(url.hostname.endsWith(`.${project}.pages.dev`), 'Require the configured Pages project');
|
||||
assert.ok(!url.username && !url.password && url.pathname === '/' && !url.search && !url.hash);
|
||||
return url;
|
||||
}
|
||||
|
||||
export async function verifyPreview(url, policy, request = fetch, directory = new URL('../../site/dist/', import.meta.url)) {
|
||||
for (const [path, status, type] of [
|
||||
['/', 200, 'text/html'], ['/terms/', 200, 'text/html'], ['/privacy/', 200, 'text/html'],
|
||||
['/marketing-csp-missing-page', 404, 'text/html'],
|
||||
['/install.sh', 200, null], ['/cli.sh', 200, null],
|
||||
]) {
|
||||
const response = await request(new URL(path, url), { redirect: 'error', signal: AbortSignal.timeout(30000) });
|
||||
assert.equal(response.status, status, `Unexpected preview status for ${path}`);
|
||||
assert.equal(response.headers.get('content-security-policy'), policy, `Unexpected preview CSP for ${path}`);
|
||||
assert.equal(response.headers.get('x-content-type-options'), 'nosniff');
|
||||
if (type) assert.ok(response.headers.get('content-type')?.startsWith(type));
|
||||
else assert.equal(await response.text(), await readFile(new URL(path.slice(1), directory), 'utf8'));
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||
const { CLOUDFLARE_PAGES_PROJECT_NAME: project, WRANGLER_OUTPUT_FILE_PATH: receipt, GITHUB_SHA: sha } = process.env;
|
||||
assert.ok(project && receipt && sha, 'Require preview deployment configuration');
|
||||
const entries = (await readFile(receipt, 'utf8')).split(/\r?\n/).filter(line => line.trim()).map(line => JSON.parse(line));
|
||||
const url = previewURL(entries, project, sha);
|
||||
const headers = await readFile(new URL('../../site/dist/_headers', import.meta.url), 'utf8');
|
||||
const policies = [...headers.matchAll(/^\s+Content-Security-Policy: (.+)$/gm)];
|
||||
assert.equal(policies.length, 1, 'Require one built policy');
|
||||
await verifyPreview(url, policies[0][1]);
|
||||
console.log('Marketing preview headers, routes and published installers verified');
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { test } from 'node:test';
|
||||
import { previewURL, verifyPreview } from './pages-marketing-preview.mjs';
|
||||
|
||||
test('accepts only a versioned Wrangler preview receipt for the reviewed commit and project', () => {
|
||||
const deployment = { type: 'pages-deploy-detailed', version: 1, pages_project: 'marketing',
|
||||
deployment_id: 'deployment-id', environment: 'preview', url: 'https://abc.marketing.pages.dev',
|
||||
deployment_trigger: { metadata: { commit_hash: 'sha' } } };
|
||||
const select = value => previewURL([value], 'marketing', 'sha');
|
||||
assert.equal(select(deployment).origin, 'https://abc.marketing.pages.dev');
|
||||
for (const override of [
|
||||
{ environment: 'production' }, { url: 'https://abc.other.pages.dev' },
|
||||
{ type: 'pages-deploy' }, { version: 2 }, { pages_project: 'other' }, { deployment_id: null },
|
||||
{ deployment_trigger: { metadata: { commit_hash: 'old' } } },
|
||||
]) assert.throws(() => select({ ...deployment, ...override }));
|
||||
assert.throws(() => previewURL([deployment, deployment], 'marketing', 'sha'));
|
||||
assert.equal(previewURL([{ type: 'pages-deploy' }, deployment], 'marketing', 'sha').origin, 'https://abc.marketing.pages.dev');
|
||||
});
|
||||
|
||||
test('verifies page, error and byte-identical installer responses with the built policy', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'marketing-preview-'));
|
||||
try {
|
||||
for (const file of ['install.sh', 'cli.sh']) await writeFile(join(root, file), `# ${file}\n`);
|
||||
const paths = [];
|
||||
const request = async url => {
|
||||
paths.push(url.pathname);
|
||||
const script = url.pathname.endsWith('.sh');
|
||||
return new Response(script ? `# ${url.pathname.slice(1)}\n` : '<html>Page</html>', {
|
||||
status: url.pathname.includes('missing-page') ? 404 : 200,
|
||||
headers: { 'content-security-policy': 'policy', 'x-content-type-options': 'nosniff',
|
||||
'content-type': script ? 'text/plain' : 'text/html; charset=utf-8' },
|
||||
});
|
||||
};
|
||||
await verifyPreview('https://abc.marketing.pages.dev', 'policy', request, pathToFileURL(`${root}/`));
|
||||
assert.deepEqual(paths, ['/', '/terms/', '/privacy/', '/marketing-csp-missing-page', '/install.sh', '/cli.sh']);
|
||||
await writeFile(join(root, 'cli.sh'), 'different bytes');
|
||||
await assert.rejects(verifyPreview('https://abc.marketing.pages.dev', 'policy', request, pathToFileURL(`${root}/`)));
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('blocks promotion for absent or different policy, redirects and unexpected responses', async () => {
|
||||
for (const response of [
|
||||
new Response('', { status: 200 }),
|
||||
new Response('', { status: 200, headers: { 'content-security-policy': 'other' } }),
|
||||
new Response('', { status: 503 }),
|
||||
]) await assert.rejects(verifyPreview('https://abc.marketing.pages.dev', 'policy', async () => response));
|
||||
await assert.rejects(verifyPreview('https://abc.marketing.pages.dev', 'policy', async (url, options) => {
|
||||
assert.equal(options.redirect, 'error');
|
||||
throw new Error('redirect refused');
|
||||
}), /redirect refused/);
|
||||
});
|
||||
Executable
+191
@@ -0,0 +1,191 @@
|
||||
#!/usr/bin/env bash
|
||||
# Finalize runtime TLS through the protected environment using a versioned private snapshot.
|
||||
set -euo pipefail
|
||||
|
||||
check_plan() {
|
||||
local stage=${2:-route}
|
||||
[[ "$stage" = route || "$stage" = drain || "$stage" = on ]]
|
||||
jq -e --arg stage "$stage" '
|
||||
def service: "\\[\\\"(backend|forms|tracking|realtime)\\\"\\]";
|
||||
def normalize:
|
||||
map(.mountPoints //= [] | .systemControls //= [] | .volumesFrom //= [] |
|
||||
.portMappings = ((.portMappings // []) | map(.hostPort //= .containerPort)));
|
||||
def same_except($keys):
|
||||
(.change.before | delpaths($keys | map([.]))) == (.change.after | delpaths($keys | map([.])));
|
||||
def normalize_empty_description:
|
||||
.change.actions == ["update"] and same_except(["description"]) and
|
||||
.change.before.description == "" and .change.after.description == null;
|
||||
def normalize_registration:
|
||||
if .elb_name == "" then .elb_name = null else . end;
|
||||
def task_settings:
|
||||
del(.arn, .arn_without_revision, .id, .revision, .container_definitions) |
|
||||
.enable_fault_injection //= false | .ipc_mode //= "" | .pid_mode //= "";
|
||||
def same_task_settings:
|
||||
(.change.before | task_settings) == (.change.after | task_settings);
|
||||
def same_container_except_loopback:
|
||||
(.change.before.container_definitions | fromjson | normalize) as $before |
|
||||
(.change.after.container_definitions | fromjson | normalize) as $after |
|
||||
($after | map(.environment |= map(select(.name != "SERVE_HTTP_LOOPBACK_ONLY")))) ==
|
||||
($before | map(.environment |= map(select(.name != "SERVE_HTTP_LOOPBACK_ONLY")))) and
|
||||
all($after[]; if $stage == "on" then
|
||||
any(.environment[]; .name == "SERVE_HTTP_LOOPBACK_ONLY" and .value == "true")
|
||||
else all(.environment[]; .name != "SERVE_HTTP_LOOPBACK_ONLY") end);
|
||||
[.resource_changes[]? | select(.change.actions != ["no-op"] and .change.actions != ["read"])] as $changes |
|
||||
all($changes[];
|
||||
if (.address | test("^aws_ecs_task_definition\\.service" + service + "$")) then
|
||||
.change.actions == ["delete", "create"] and same_container_except_loopback and same_task_settings
|
||||
elif (.address | test("^aws_ecs_service\\.service" + service + "$")) then
|
||||
.change.actions == ["update"] and same_except(["load_balancer"]) and
|
||||
($stage == "drain") and
|
||||
(.change.before.load_balancer | length == 2) and
|
||||
(.change.after.load_balancer | length == 1) and
|
||||
((.change.after.load_balancer[0] | normalize_registration) as $tls |
|
||||
($tls.target_group_arn | contains("-tls/")) and
|
||||
(.change.before.load_balancer | map(normalize_registration) | index($tls) != null))
|
||||
elif (.address | test("^aws_cloudwatch_metric_alarm\\.target_5xx" + service + "$")) then
|
||||
.change.actions == ["update"] and same_except(["metric_query"])
|
||||
elif (.address | test("^aws_cloudwatch_metric_alarm\\.unhealthy_hosts" + service + "$")) then
|
||||
.change.actions == ["update"] and same_except(["dimensions"])
|
||||
elif (.address | test("^aws_lb_listener_rule\\.(service" + service + "|tracking_alias\\[\\\"[0-9]+\\\"\\])$")) then
|
||||
.change.actions == ["update"] and same_except(["action"])
|
||||
elif (.address | test("^aws_lb_target_group\\.service" + service + "$")) then
|
||||
$stage == "on" and .change.actions == ["delete"]
|
||||
elif (.address | test("^aws_vpc_security_group_ingress_rule\\.service" + service + "$")) or
|
||||
.address == "aws_vpc_security_group_ingress_rule.internal_backend[0]" then
|
||||
($stage == "on" and .change.actions == ["delete"]) or normalize_empty_description
|
||||
else false end)
|
||||
' "$1" >/dev/null || { echo 'Plan contains changes outside the runtime TLS switch' >&2; return 1; }
|
||||
}
|
||||
|
||||
check_live() {
|
||||
jq -e --arg stage "$2" --arg release "$3" --arg port "$4" --arg prefix "$5" '
|
||||
. as $live |
|
||||
(.services.failures | length == 0) and
|
||||
([.services.services[].serviceName] | sort) ==
|
||||
(["backend", "forms", "tracking", "realtime"] | map($prefix + "-" + .) | sort) and
|
||||
all(.services.services[];
|
||||
. as $service |
|
||||
.desiredCount > 0 and .runningCount == .desiredCount and .pendingCount == 0 and
|
||||
(.deployments | length == 1) and .deployments[0].rolloutState == "COMPLETED" and
|
||||
(.loadBalancers | length == (if $stage == "on" then 1 else 2 end)) and
|
||||
any(.loadBalancers[]; .containerPort == ($port | tonumber) and
|
||||
(.targetGroupArn | contains("-tls/"))) and
|
||||
any($live.definitions[];
|
||||
.taskDefinition.taskDefinitionArn == $service.taskDefinition and
|
||||
any(.tags[]; .key == "warmbly-release" and .value == $release) and
|
||||
(.taskDefinition.containerDefinitions | length > 0) and
|
||||
all(.taskDefinition.containerDefinitions[];
|
||||
(.environment | map({key:.name,value:.value}) | from_entries) as $env |
|
||||
($env.SERVE_TLS == "supplied" or $env.SERVE_TLS == "self-signed") and
|
||||
$env.SERVE_TLS_PORT == $port and $env.SERVE_HTTP_LOOPBACK_ONLY != "true")))
|
||||
' "$1" >/dev/null || { echo 'Live services must be stable on the expected release with compatible TLS listeners and registrations' >&2; return 1; }
|
||||
}
|
||||
|
||||
check_cleanup() {
|
||||
jq -e '
|
||||
(.tlsPort // 8443) as $port |
|
||||
(.services | length == 4) and (.httpGroups | length == 4) and
|
||||
all(.services[]; (.loadBalancers | length > 0) and
|
||||
all(.loadBalancers[]; .containerPort == $port and (.targetGroupArn | contains("-tls/")))) and
|
||||
all(.httpGroups[]; (.LoadBalancerArns | length == 0) and (.targets | length == 0))
|
||||
' "$1" >/dev/null || { echo 'HTTP listeners and registrations must be drained before cleanup' >&2; return 1; }
|
||||
}
|
||||
|
||||
main() {
|
||||
local action=${1:?}
|
||||
if [ "$action" = check-plan ]; then check_plan "${2:?}" "${3:-route}"; return; fi
|
||||
if [ "$action" = check-live ]; then check_live "${2:?}" "${3:?}" "${4:?}" "${5:?}" "${6:?}"; return; fi
|
||||
if [ "$action" = check-cleanup ]; then check_cleanup "${2:?}"; return; fi
|
||||
case "$action" in plan|apply) ;; *) echo 'Unknown action' >&2; return 1 ;; esac
|
||||
: "${STATE_BUCKET:?}" "${WORK:?}" "${VARS_VERSION:?}" "${RELEASE:?}"
|
||||
: "${STAGE:?}"
|
||||
[[ "$STAGE" = route || "$STAGE" = drain || "$STAGE" = on ]]
|
||||
[[ "$VARS_VERSION" != null && "$VARS_VERSION" != *$'\n'* && "$RELEASE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
|
||||
mkdir -p "$WORK"
|
||||
chmod 700 "$WORK"
|
||||
umask 077
|
||||
local dir=deploy/terraform/aws/runtime vars="$WORK/runtime.tfvars.json" log="$WORK/runtime.log"
|
||||
aws s3api get-object --bucket "$STATE_BUCKET" --key warmbly/production/vars/runtime-tls.tfvars.json \
|
||||
--version-id "$VARS_VERSION" "$vars" >/dev/null
|
||||
local previous=both
|
||||
case "$STAGE" in drain) previous=route ;; on) previous=drain ;; esac
|
||||
jq -e --arg previous "$previous" '.target_tls == $previous' "$vars" >/dev/null
|
||||
jq -r '.. | strings | select(length >= 6)' "$vars" | while IFS= read -r line; do
|
||||
printf '::add-mask::%s\n' "$line" >&2
|
||||
done
|
||||
local account cluster prefix definition port
|
||||
account=$(aws sts get-caller-identity --query Account --output text)
|
||||
[ "$account" = 925323749693 ]
|
||||
cluster=$(jq -r '.name // "warmbly-production"' "$vars")
|
||||
prefix=$cluster
|
||||
port=$(jq -r '.target_tls_port // 8443' "$vars")
|
||||
aws ecs describe-services --cluster "$cluster" --services \
|
||||
"$prefix-backend" "$prefix-forms" "$prefix-tracking" "$prefix-realtime" >"$WORK/services.json"
|
||||
: >"$WORK/definitions.jsonl"
|
||||
while IFS= read -r definition; do
|
||||
aws ecs describe-task-definition --task-definition "$definition" --include TAGS >>"$WORK/definitions.jsonl"
|
||||
done < <(jq -r '.services[].taskDefinition' "$WORK/services.json")
|
||||
jq -n --slurpfile services "$WORK/services.json" --slurpfile definitions "$WORK/definitions.jsonl" \
|
||||
'{services:$services[0],definitions:$definitions}' >"$WORK/live.json"
|
||||
check_live "$WORK/live.json" "$STAGE" "$RELEASE" "$port" "$prefix"
|
||||
local service arn count
|
||||
for service in backend forms tracking realtime; do
|
||||
arn=$(aws elbv2 describe-target-groups --names "$prefix-$service-tls" --query 'TargetGroups[0].TargetGroupArn' --output text)
|
||||
count=$(aws elbv2 describe-target-health --target-group-arn "$arn" --query 'TargetHealthDescriptions' --output json |
|
||||
jq 'if length > 0 and all(.[]; .TargetHealth.State == "healthy") then length else 0 end')
|
||||
[ "$count" -gt 0 ] || { echo "HTTPS targets are not healthy for $service" >&2; return 1; }
|
||||
if [ "$STAGE" = route ]; then
|
||||
arn=$(aws elbv2 describe-target-groups --names "$prefix-$service" --query 'TargetGroups[0].TargetGroupArn' --output text)
|
||||
count=$(aws elbv2 describe-target-health --target-group-arn "$arn" --query 'TargetHealthDescriptions' --output json |
|
||||
jq 'if length > 0 and all(.[]; .TargetHealth.State == "healthy") then length else 0 end')
|
||||
[ "$count" -gt 0 ] || { echo "HTTP fallback is not healthy for $service" >&2; return 1; }
|
||||
fi
|
||||
done
|
||||
if [ "$STAGE" != route ]; then
|
||||
: "${PREVIOUS_RUN:?}" "${GITHUB_REPOSITORY:?}"
|
||||
[[ "$PREVIOUS_RUN" =~ ^[0-9]+$ ]]
|
||||
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$PREVIOUS_RUN" |
|
||||
jq -e --arg title "Runtime TLS $previous $RELEASE" '
|
||||
.conclusion == "success" and .head_branch == "main" and
|
||||
.path == ".github/workflows/runtime-tls.yml" and .display_title == $title
|
||||
' >/dev/null || { echo 'The preceding stage workflow and its release bakes must succeed first' >&2; return 1; }
|
||||
fi
|
||||
if [ "$STAGE" = on ]; then
|
||||
aws elbv2 describe-target-groups --names "$prefix-backend" "$prefix-forms" \
|
||||
"$prefix-tracking" "$prefix-realtime" >"$WORK/http-groups.json"
|
||||
: >"$WORK/http-health.jsonl"
|
||||
while IFS= read -r arn; do
|
||||
aws elbv2 describe-target-health --target-group-arn "$arn" |
|
||||
jq --arg arn "$arn" '{arn:$arn,targets:.TargetHealthDescriptions}' >>"$WORK/http-health.jsonl"
|
||||
done < <(jq -r '.TargetGroups[].TargetGroupArn' "$WORK/http-groups.json")
|
||||
jq -n --slurpfile services "$WORK/services.json" --slurpfile groups "$WORK/http-groups.json" \
|
||||
--argjson port "$(jq '.target_tls_port // 8443' "$vars")" \
|
||||
--slurpfile health "$WORK/http-health.jsonl" '{tlsPort:$port,services:$services[0].services,httpGroups:[
|
||||
$groups[0].TargetGroups[] | . as $group | . + {targets:[$health[] | select(.arn == $group.TargetGroupArn) | .targets[]]}]}' >"$WORK/cleanup.json"
|
||||
check_cleanup "$WORK/cleanup.json"
|
||||
fi
|
||||
terraform -chdir="$dir" init -input=false -no-color -backend-config="bucket=$STATE_BUCKET" >"$log" 2>&1
|
||||
terraform -chdir="$dir" plan -input=false -no-color -lock-timeout=5m -var-file="$vars" \
|
||||
-var="state_bucket=$STATE_BUCKET" -var="target_tls=$STAGE" \
|
||||
-target=aws_ecs_service.service -target=aws_lb_listener_rule.tracking_alias \
|
||||
-target=aws_vpc_security_group_ingress_rule.service -target=aws_vpc_security_group_ingress_rule.internal_backend \
|
||||
-out="$WORK/runtime.tfplan" >>"$log" 2>&1 || { echo 'Runtime TLS plan failed; inspect the private runner log' >&2; return 1; }
|
||||
terraform -chdir="$dir" show -json "$WORK/runtime.tfplan" >"$WORK/runtime.json"
|
||||
check_plan "$WORK/runtime.json" "$STAGE"
|
||||
local digest
|
||||
digest=$(jq -cS '[.resource_changes[]? | select(.change.actions != ["no-op"] and .change.actions != ["read"])] | sort_by(.address)' "$WORK/runtime.json" | sha256sum | cut -d' ' -f1)
|
||||
if [ "$action" = plan ]; then
|
||||
printf 'digest=%s\n' "$digest" >>"${GITHUB_OUTPUT:?}"
|
||||
jq -r '.resource_changes[]? | select(.change.actions != ["no-op"] and .change.actions != ["read"]) | "\(.change.actions | join("/")) \(.address)"' "$WORK/runtime.json" >>"${GITHUB_STEP_SUMMARY:?}"
|
||||
else
|
||||
[ "$digest" = "${APPROVED_DIGEST:?}" ] || { echo 'Runtime TLS plan changed; start a new approval run' >&2; return 1; }
|
||||
if ! terraform -chdir="$dir" apply -input=false -no-color -lock-timeout=5m "$WORK/runtime.tfplan" >>"$log" 2>&1; then
|
||||
local diagnostic="warmbly/production/diagnostics/runtime-tls/${GITHUB_RUN_ID:?}/${GITHUB_RUN_ATTEMPT:?}/apply.log"
|
||||
aws s3 cp "$log" "s3://$STATE_BUCKET/$diagnostic" --only-show-errors || echo 'Private diagnostic upload failed' >&2
|
||||
echo "Runtime TLS apply failed; inspect state and private diagnostic $diagnostic before retrying" >&2
|
||||
return 1
|
||||
fi
|
||||
echo 'Runtime TLS apply completed'
|
||||
fi
|
||||
}
|
||||
main "$@"
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/../.."
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
expect() {
|
||||
local want=$1 address=$2 actions=$3 stage=${4:-route}
|
||||
jq -n --arg address "$address" --argjson actions "$actions" '{resource_changes:[{address:$address,change:{actions:$actions}}]}' >"$work/plan.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/plan.json" "$stage" 2>/dev/null; then
|
||||
[ "$want" = pass ]
|
||||
else
|
||||
[ "$want" = fail ]
|
||||
fi
|
||||
}
|
||||
expect fail 'aws_lb_target_group.service["backend"]' '["delete"]'
|
||||
expect pass 'aws_lb_target_group.service["backend"]' '["delete"]' on
|
||||
expect fail 'aws_ecs_service.service["forms"]' '["update"]'
|
||||
expect fail 'aws_vpc_security_group_ingress_rule.internal_backend[0]' '["delete"]'
|
||||
expect pass 'aws_vpc_security_group_ingress_rule.internal_backend[0]' '["delete"]' on
|
||||
expect fail 'aws_vpc_security_group_ingress_rule.service["backend"]' '["delete"]'
|
||||
expect pass 'aws_vpc_security_group_ingress_rule.service["backend"]' '["delete"]' on
|
||||
expect fail 'aws_ecs_task_definition.validation' '["delete","create"]'
|
||||
expect fail 'aws_s3_bucket.data' '["delete"]'
|
||||
expect fail 'aws_ecs_service.service["consumer"]' '["update"]'
|
||||
expect fail 'aws_lb_target_group.service["backend"]' '["delete","create"]'
|
||||
expect fail 'aws_lb_target_group.service["backend"]' '["delete"]' drain
|
||||
expect fail 'aws_vpc_security_group_ingress_rule.internal_backend[0]' '["delete"]' drain
|
||||
jq -n '{resource_changes:[{address:"aws_ecs_service.service[\"forms\"]",change:{actions:["update"],
|
||||
before:{load_balancer:[{target_group_arn:"forms/1",container_port:8090},{target_group_arn:"forms-tls/2",container_port:8443}]},
|
||||
after:{load_balancer:[{target_group_arn:"forms-tls/2",container_port:8443}]}}}]}' >"$work/plan.json"
|
||||
bash .github/scripts/runtime-tls.sh check-plan "$work/plan.json" drain
|
||||
for stage in route on; do
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/plan.json" "$stage" 2>/dev/null; then
|
||||
echo 'Registration detached outside the drain stage' >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
jq '.resource_changes[0].change |= (
|
||||
.before.load_balancer |= map(. + {elb_name:"",advanced_configuration:[]}) |
|
||||
.after.load_balancer |= map(. + {elb_name:null,advanced_configuration:[]}))' "$work/plan.json" >"$work/normalized.json"
|
||||
bash .github/scripts/runtime-tls.sh check-plan "$work/normalized.json" drain
|
||||
for change in '.after.load_balancer[0].elb_name="classic-lb"' \
|
||||
'.before.load_balancer[1].elb_name="classic-lb"' \
|
||||
'.after.load_balancer[0].container_port=9443' \
|
||||
'.after.load_balancer[0].container_name="other"' \
|
||||
'.after.load_balancer[0].target_group_arn="other-tls/3"' \
|
||||
'.after.load_balancer[0].advanced_configuration=[{alternate_target_group_arn:"other-tls/3"}]'; do
|
||||
jq ".resource_changes[0].change |= ($change)" "$work/normalized.json" >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/changed.json" drain 2>/dev/null; then
|
||||
echo 'Changed HTTPS registration accepted as empty ELB name normalization' >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
jq -n '{resource_changes:[{address:"aws_vpc_security_group_ingress_rule.service[\"backend\"]",change:{actions:["update"],
|
||||
before:{description:"",from_port:8080},after:{description:null,from_port:8080}}}]}' >"$work/plan.json"
|
||||
bash .github/scripts/runtime-tls.sh check-plan "$work/plan.json" route
|
||||
jq '.resource_changes[0].change.after.from_port=8443' "$work/plan.json" >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/changed.json" route 2>/dev/null; then
|
||||
echo 'Network change accepted as metadata normalization' >&2
|
||||
exit 1
|
||||
fi
|
||||
jq -n '{resource_changes:[{address:"aws_ecs_task_definition.service[\"backend\"]",change:{actions:["delete","create"],before:{container_definitions:([{image:"pinned",environment:[]}]|tojson)},after:{container_definitions:([{image:"pinned",environment:[{name:"SERVE_HTTP_LOOPBACK_ONLY",value:"true"}]}]|tojson)}}}]}' >"$work/plan.json"
|
||||
bash .github/scripts/runtime-tls.sh check-plan "$work/plan.json" on
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/plan.json" route 2>/dev/null; then
|
||||
echo 'Loopback-only listener accepted before HTTP registrations drained' >&2
|
||||
exit 1
|
||||
fi
|
||||
jq '.resource_changes[0].change |= ({actions:.actions,before:.after,after:.before})' "$work/plan.json" >"$work/route.json"
|
||||
bash .github/scripts/runtime-tls.sh check-plan "$work/route.json" route
|
||||
jq '.resource_changes[0].change.after.container_definitions |= (fromjson | .[0].image = "changed" | tojson)' "$work/plan.json" >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/changed.json" on 2>/dev/null; then
|
||||
echo 'Changed image was accepted' >&2
|
||||
exit 1
|
||||
fi
|
||||
jq '.resource_changes[0].change.before.cpu = "512" | .resource_changes[0].change.after.cpu = "1024"' "$work/plan.json" >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/changed.json" on 2>/dev/null; then
|
||||
echo 'Changed task settings were accepted' >&2
|
||||
exit 1
|
||||
fi
|
||||
jq -n '{resource_changes:[{address:"aws_ecs_service.service[\"backend\"]",change:{actions:["update"],before:{network_configuration:[]},after:{network_configuration:[{subnets:["other"]}]}}}]}' >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-plan "$work/changed.json" 2>/dev/null; then
|
||||
echo 'Changed service network was accepted' >&2
|
||||
exit 1
|
||||
fi
|
||||
jq -n '{services:[range(4) | {loadBalancers:[{containerPort:8443,targetGroupArn:"service-tls/123"}]}],
|
||||
httpGroups:[range(4) | {LoadBalancerArns:[],targets:[]}]}' >"$work/cleanup.json"
|
||||
bash .github/scripts/runtime-tls.sh check-cleanup "$work/cleanup.json"
|
||||
for change in '.services[0].loadBalancers[0].containerPort=8080' \
|
||||
'.httpGroups[0].LoadBalancerArns=["listener"]' '.httpGroups[0].targets=[{Id:"still-draining"}]' \
|
||||
'.services=[]'; do
|
||||
jq "$change" "$work/cleanup.json" >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-cleanup "$work/changed.json" 2>/dev/null; then
|
||||
echo 'HTTP cleanup accepted before all references drained' >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
jq -n '
|
||||
["backend","forms","tracking","realtime"] as $names |
|
||||
{services:{failures:[],services:[$names[] | {serviceName:("test-"+.),taskDefinition:.,desiredCount:1,runningCount:1,pendingCount:0,
|
||||
deployments:[{rolloutState:"COMPLETED"}],loadBalancers:[{containerPort:8080,targetGroupArn:(.+"/1")},{containerPort:8443,targetGroupArn:(.+"-tls/2")}]}]},
|
||||
definitions:[$names[] | {tags:[{key:"warmbly-release",value:"v0.6.70"}],taskDefinition:{taskDefinitionArn:.,containerDefinitions:[{
|
||||
environment:[{name:"SERVE_TLS",value:"supplied"},{name:"SERVE_TLS_PORT",value:"8443"}]}]}}]}' >"$work/live.json"
|
||||
bash .github/scripts/runtime-tls.sh check-live "$work/live.json" route v0.6.70 8443 test
|
||||
for change in '.services.services[0].pendingCount=1' '.services.services[0].deployments[0].rolloutState="IN_PROGRESS"' \
|
||||
'.services.services[0].loadBalancers|=.[0:1]' '.definitions[0].tags[0].value="v0.6.69"' \
|
||||
'.definitions[0].taskDefinition.containerDefinitions[0].environment=[]' \
|
||||
'.definitions[0].taskDefinition.containerDefinitions[0].environment += [{name:"SERVE_HTTP_LOOPBACK_ONLY",value:"true"}]' \
|
||||
'.services.services|=.[0:3]'; do
|
||||
jq "$change" "$work/live.json" >"$work/changed.json"
|
||||
if bash .github/scripts/runtime-tls.sh check-live "$work/changed.json" route v0.6.70 8443 test 2>/dev/null; then
|
||||
echo 'Incompatible or unstable live services accepted' >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo 'Runtime TLS plan guards passed'
|
||||
@@ -49,6 +49,7 @@ jobs:
|
||||
filters: |
|
||||
go-services:
|
||||
- '.github/workflows/ci.yml'
|
||||
- '.github/scripts/live-tests-summary*.mjs'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- 'internal/**'
|
||||
@@ -212,6 +213,10 @@ jobs:
|
||||
if: matrix.suite == 'lint'
|
||||
run: make lint
|
||||
|
||||
- name: Check live-test reporting
|
||||
if: matrix.suite == 'lint'
|
||||
run: node --test .github/scripts/live-tests-summary.test.mjs
|
||||
|
||||
- name: Verify protobuf files are up to date
|
||||
if: matrix.suite == 'lint'
|
||||
run: make check-proto
|
||||
@@ -417,6 +422,32 @@ jobs:
|
||||
grep -q "^--- PASS: $test " monitoring-clock.log
|
||||
done
|
||||
|
||||
- name: Approved warmup content and queued source regressions (PostgreSQL)
|
||||
if: matrix.suite == 'live-2'
|
||||
env:
|
||||
WARMBLY_TEST_DB: postgres://warmbly:warmbly@127.0.0.1:5432/warmbly_test?sslmode=disable
|
||||
run: |
|
||||
set -euo pipefail
|
||||
go test -race -v ./internal/repository -run '^TestLiveContentPool' -count=1 | tee content-pool.log
|
||||
go test -race -v ./internal/tasks -run '^TestLiveWarmupDispatchRechecksOpeningSourceAndExactRecipient$' -count=1 | tee -a content-pool.log
|
||||
if grep -q -- '--- SKIP:' content-pool.log; then
|
||||
echo "Warmup content and queued source regressions must execute without skips"
|
||||
exit 1
|
||||
fi
|
||||
for test in TestLiveContentPoolRejectsDuplicateBatchContentUnderConcurrency \
|
||||
TestLiveContentPoolRetryReservesOnceAndReplenishesForExposedMailboxes \
|
||||
TestLiveContentPoolPreservesPlansForFutureDistinctMailboxes \
|
||||
TestLiveContentPoolConcurrentPairsAlwaysReceiveContent \
|
||||
TestLiveContentPoolPrefersLessUsedEligiblePlans \
|
||||
TestLiveContentPoolPrefersWhatNeitherMailboxSawRecently \
|
||||
TestLiveContentPoolExhaustedPairRepeatsTheLeastRecentlySeen \
|
||||
TestLiveContentPoolTokenCleanupKeepsExposure \
|
||||
TestLiveContentPoolStaticRowsOnlyFromTheCurrentLibrary \
|
||||
TestLiveContentPoolDemandCountsPlansRatherThanReplies \
|
||||
TestLiveWarmupDispatchRechecksOpeningSourceAndExactRecipient; do
|
||||
grep -q "^--- PASS: $test " content-pool.log
|
||||
done
|
||||
|
||||
- name: Warmup generic execution authority regressions (PostgreSQL)
|
||||
if: matrix.suite == 'live-2'
|
||||
env:
|
||||
@@ -431,7 +462,8 @@ jobs:
|
||||
TestLiveWarmupGenericCancellationPreservesOtherHolds \
|
||||
TestLiveWarmupGenericStartAndLateResult \
|
||||
TestLiveWarmupGenericStartAfterCompatibleOverwrite \
|
||||
TestLiveWarmupGenericCannotRepeatStartedWarmupClaim; do
|
||||
TestLiveWarmupGenericCannotRepeatStartedWarmupClaim \
|
||||
TestLiveWarmupGenericDeniesHistoricalDiagnosticContent; do
|
||||
grep -q "^--- PASS: $test " warmup-generic-execution.log
|
||||
done
|
||||
|
||||
@@ -594,7 +626,7 @@ jobs:
|
||||
if: matrix.suite == 'live-1'
|
||||
env:
|
||||
WARMBLY_TEST_DB: postgres://warmbly:warmbly@127.0.0.1:5432/warmbly_test?sslmode=disable
|
||||
run: go test -race -v -p 1 ./internal/repository ./internal/infrastructure/db -run '^TestLiveUnibox(Search|ReadStream|SearchUpgrade|GetBySender)' -count=1
|
||||
run: go test -race -v -p 1 ./internal/repository ./internal/infrastructure/db -run '^TestLiveUnibox(Search|ReadStream|SearchUpgrade|GetBySender|ScopeDraftsCount)' -count=1
|
||||
|
||||
- name: Notification digest authorization retries (Redis)
|
||||
if: matrix.suite == 'live-3'
|
||||
@@ -617,6 +649,70 @@ jobs:
|
||||
flags: go
|
||||
fail_ci_if_error: false
|
||||
|
||||
# Keep advisory coverage separate until #1078's failure inventory is resolved.
|
||||
go-live-advisory:
|
||||
name: PostgreSQL catch-all (advisory)
|
||||
needs: changes
|
||||
if: needs.changes.outputs.go-services == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
continue-on-error: true
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
env:
|
||||
POSTGRES_USER: warmbly
|
||||
POSTGRES_PASSWORD: warmbly
|
||||
POSTGRES_DB: warmbly_test
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U warmbly -d warmbly_test"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- 6379:6379
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
- name: Prepare isolated regression database
|
||||
env:
|
||||
PRIMARY_DB: postgres://warmbly:warmbly@127.0.0.1:5432/warmbly_test?sslmode=disable
|
||||
run: go run ./cmd/migrate
|
||||
- name: Run every TestLive test
|
||||
id: live
|
||||
timeout-minutes: 35
|
||||
env:
|
||||
WARMBLY_TEST_DB: postgres://warmbly:warmbly@127.0.0.1:5432/warmbly_test?sslmode=disable
|
||||
WARMBLY_TEST_REDIS: redis://127.0.0.1:6379/15
|
||||
run: |
|
||||
set -o pipefail
|
||||
go test -json -race -p 1 -timeout 10m -count=1 -run '^TestLive' ./... 2>&1 | tee live-tests.jsonl
|
||||
- name: Summarize advisory results
|
||||
if: always()
|
||||
env:
|
||||
LIVE_TEST_OUTCOME: ${{ steps.live.outcome }}
|
||||
run: node .github/scripts/live-tests-summary.mjs live-tests.jsonl
|
||||
- name: Retain complete live-test output
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: postgres-live-advisory-${{ github.run_attempt }}
|
||||
path: live-tests.jsonl
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
web-ci:
|
||||
name: Web CI
|
||||
needs: changes
|
||||
|
||||
@@ -22,6 +22,10 @@ on:
|
||||
description: Start a canary rollout of the workers and consumers after the services
|
||||
default: true
|
||||
type: boolean
|
||||
require_attestation:
|
||||
description: Refuse images without build provenance (only releases before provenance need false)
|
||||
default: true
|
||||
type: boolean
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
@@ -41,6 +45,10 @@ on:
|
||||
description: Seconds each service is watched against its alarms after it is stable
|
||||
default: "300"
|
||||
type: string
|
||||
fleet_bake_seconds:
|
||||
description: Healthy uptime per worker rollout stage (300 through 3600 seconds)
|
||||
default: "300"
|
||||
type: string
|
||||
fleet:
|
||||
description: Start a canary rollout of the workers and consumers after the services
|
||||
default: true
|
||||
@@ -139,6 +147,7 @@ jobs:
|
||||
DEPLOY_MODE: ${{ inputs.mode || 'deploy' }}
|
||||
DEPLOY_SERVICES: ${{ inputs.services || 'all' }}
|
||||
DEPLOY_BAKE_SECONDS: ${{ inputs.bake_seconds || vars.AWS_DEPLOY_BAKE_SECONDS || '300' }}
|
||||
DEPLOY_FLEET_BAKE_SECONDS: ${{ inputs.fleet_bake_seconds || vars.AWS_FLEET_BAKE_SECONDS || '300' }}
|
||||
DEPLOY_FLEET: ${{ inputs.fleet != false }}
|
||||
DEPLOY_ALLOW_DROPPED_SECRETS: ${{ inputs.allow_dropped_secrets == true }}
|
||||
DEPLOY_IMAGES_JSON: ${{ steps.release.outputs.images }}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
name: Deploy marketing Pages
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/marketing-pages.yml'
|
||||
- '.github/scripts/pages-*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
expected_sha:
|
||||
description: Reviewed main commit to deploy (full SHA)
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.event_name == 'workflow_dispatch' && 'release' || format('marketing-pages-check-{0}', github.ref) }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: "22"
|
||||
- run: node --test .github/scripts/pages-*.test.mjs
|
||||
|
||||
deploy:
|
||||
needs: check
|
||||
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && vars.CLOUDFLARE_PAGES_DEPLOY_ENABLED == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
environment: site-production
|
||||
env:
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
|
||||
PAGES_APP: site
|
||||
WRANGLER_SEND_METRICS: "false"
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
persist-credentials: false
|
||||
- name: Require the reviewed main commit
|
||||
env:
|
||||
EXPECTED_SHA: ${{ inputs.expected_sha }}
|
||||
run: test "$EXPECTED_SHA" = "$GITHUB_SHA"
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: "22"
|
||||
- name: Select only the configured marketing project
|
||||
env:
|
||||
CLOUDFLARE_PAGES_PROJECTS: ${{ vars.CLOUDFLARE_PAGES_PROJECTS }}
|
||||
run: |
|
||||
node --input-type=module <<'JS'
|
||||
import { appendFileSync } from 'node:fs';
|
||||
import { deploymentMatrix } from './.github/scripts/pages-projects.mjs';
|
||||
const sites = deploymentMatrix(process.env.CLOUDFLARE_PAGES_PROJECTS).include.filter(target => target.app === 'site');
|
||||
if (sites.length !== 1) throw new Error('Configure exactly one marketing Pages project');
|
||||
appendFileSync(process.env.GITHUB_ENV, `CLOUDFLARE_PAGES_PROJECT_NAME=${sites[0].project}\n`);
|
||||
JS
|
||||
- name: Load existing marketing production configuration
|
||||
id: config
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
run: |
|
||||
for name in CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID CLOUDFLARE_PAGES_PROJECT_NAME; do
|
||||
test -n "${!name}"
|
||||
done
|
||||
curl --fail --silent --show-error \
|
||||
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
||||
"https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/pages/projects/$CLOUDFLARE_PAGES_PROJECT_NAME" \
|
||||
| node .github/scripts/pages-production-config.mjs
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
|
||||
with:
|
||||
version: "11.9.0"
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: pnpm
|
||||
cache-dependency-path: site/pnpm-lock.yaml
|
||||
- name: Install marketing dependencies
|
||||
working-directory: site
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Check marketing behavior and CSP
|
||||
working-directory: site
|
||||
run: pnpm test
|
||||
- name: Build marketing with production configuration
|
||||
working-directory: site
|
||||
run: pnpm build
|
||||
- name: Deploy an isolated preview
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
PREVIEW_BRANCH: marketing-check-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
PRODUCTION_BRANCH: ${{ steps.config.outputs.production_branch }}
|
||||
WRANGLER_OUTPUT_FILE_PATH: ${{ runner.temp }}/marketing-preview-${{ github.run_id }}-${{ github.run_attempt }}.ndjson
|
||||
run: |
|
||||
test "$PREVIEW_BRANCH" != "$PRODUCTION_BRANCH"
|
||||
test ! -e "$WRANGLER_OUTPUT_FILE_PATH"
|
||||
pnpm dlx wrangler@4.45.0 pages deploy site/dist \
|
||||
--project-name "$CLOUDFLARE_PAGES_PROJECT_NAME" \
|
||||
--branch "$PREVIEW_BRANCH" --commit-hash "$GITHUB_SHA"
|
||||
- name: Verify preview responses before production
|
||||
env:
|
||||
WRANGLER_OUTPUT_FILE_PATH: ${{ runner.temp }}/marketing-preview-${{ github.run_id }}-${{ github.run_attempt }}.ndjson
|
||||
run: node .github/scripts/pages-marketing-preview.mjs
|
||||
- name: Publish the verified marketing artifact
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
PRODUCTION_BRANCH: ${{ steps.config.outputs.production_branch }}
|
||||
run: |
|
||||
pnpm dlx wrangler@4.45.0 pages deploy site/dist \
|
||||
--project-name "$CLOUDFLARE_PAGES_PROJECT_NAME" \
|
||||
--branch "$PRODUCTION_BRANCH" --commit-hash "$GITHUB_SHA" \
|
||||
--commit-message "Marketing $GITHUB_SHA"
|
||||
@@ -0,0 +1,129 @@
|
||||
name: Finalize runtime TLS
|
||||
run-name: Runtime TLS ${{ inputs.stage }} ${{ inputs.release }}
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
vars_version:
|
||||
description: S3 version ID of the reviewed runtime-tls.tfvars.json snapshot at the previous stage
|
||||
required: true
|
||||
type: string
|
||||
stage:
|
||||
description: Advance one verified stage while preserving the previous traffic path
|
||||
required: true
|
||||
default: route
|
||||
type: choice
|
||||
options: ["route", "drain", "on"]
|
||||
previous_run:
|
||||
description: Successful preceding stage workflow run ID (required for drain and on)
|
||||
required: false
|
||||
type: string
|
||||
release:
|
||||
description: Currently deployed release, retained for the service redeploy
|
||||
required: true
|
||||
type: string
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/runtime-tls.yml'
|
||||
- '.github/scripts/runtime-tls*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
AWS_REGION: us-east-1
|
||||
TF_IN_AUTOMATION: "1"
|
||||
TF_INPUT: "0"
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- run: shellcheck .github/scripts/runtime-tls.sh .github/scripts/runtime-tls.test.sh
|
||||
- run: bash .github/scripts/runtime-tls.test.sh
|
||||
|
||||
plan:
|
||||
needs: check
|
||||
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
environment: aws-infrastructure-plan
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
actions: read
|
||||
outputs:
|
||||
digest: ${{ steps.plan.outputs.digest }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "1.16.5"
|
||||
terraform_wrapper: false
|
||||
- uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
role-to-assume: ${{ vars.AWS_TERRAFORM_PLAN_ROLE_ARN }}
|
||||
aws-region: us-east-1
|
||||
- id: plan
|
||||
env:
|
||||
STATE_BUCKET: ${{ vars.AWS_TERRAFORM_STATE_BUCKET }}
|
||||
WORK: ${{ runner.temp }}/runtime-tls
|
||||
VARS_VERSION: ${{ inputs.vars_version }}
|
||||
RELEASE: ${{ inputs.release }}
|
||||
STAGE: ${{ inputs.stage }}
|
||||
PREVIOUS_RUN: ${{ inputs.previous_run }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: .github/scripts/runtime-tls.sh plan
|
||||
|
||||
apply:
|
||||
needs: plan
|
||||
runs-on: ubuntu-latest
|
||||
environment: aws-infrastructure-approval
|
||||
concurrency:
|
||||
group: aws-production
|
||||
cancel-in-progress: false
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
actions: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "1.16.5"
|
||||
terraform_wrapper: false
|
||||
- uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
role-to-assume: ${{ vars.AWS_TERRAFORM_APPLY_ROLE_ARN }}
|
||||
aws-region: us-east-1
|
||||
- env:
|
||||
STATE_BUCKET: ${{ vars.AWS_TERRAFORM_STATE_BUCKET }}
|
||||
WORK: ${{ runner.temp }}/runtime-tls
|
||||
VARS_VERSION: ${{ inputs.vars_version }}
|
||||
RELEASE: ${{ inputs.release }}
|
||||
APPROVED_DIGEST: ${{ needs.plan.outputs.digest }}
|
||||
STAGE: ${{ inputs.stage }}
|
||||
PREVIOUS_RUN: ${{ inputs.previous_run }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: .github/scripts/runtime-tls.sh apply
|
||||
|
||||
redeploy:
|
||||
needs: apply
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: read
|
||||
uses: ./.github/workflows/deploy-aws.yml
|
||||
with:
|
||||
tag: ${{ inputs.release }}
|
||||
mode: redeploy
|
||||
services: backend,forms,tracking,realtime
|
||||
fleet: false
|
||||
require_attestation: true
|
||||
secrets: inherit
|
||||
@@ -46,6 +46,8 @@ jobs:
|
||||
terraform -chdir="deploy/terraform/aws/$stack" init -backend=false -input=false >/dev/null
|
||||
terraform -chdir="deploy/terraform/aws/$stack" validate -no-color
|
||||
done
|
||||
# Mocked provider: no credentials, nothing created.
|
||||
- run: terraform -chdir=deploy/terraform/aws/runtime test -no-color
|
||||
- run: shellcheck .github/scripts/terraform-stack.sh
|
||||
|
||||
plan:
|
||||
|
||||
@@ -24,6 +24,14 @@ store lives, what is kept and for how long, how it is backed up. The script is
|
||||
|
||||
## Working In This Repo
|
||||
|
||||
### Warmup content and deliverability
|
||||
|
||||
- Warmup mail reads as ordinary correspondence and never describes itself. `generation.ValidateWarmupWording` refuses any outgoing turn that calls itself simulated, diagnostic, hypothetical, fictional, automated, generated, a test message or a warmup; generation, review and the hand-written library all have to pass it. No fixed phrases, shared subject prefixes or repeated footers.
|
||||
- Content never runs out. New threads draw from the hand-written library (`internal/tasks/warmup_library_*.go`) and the AI bank together, preferring what neither mailbox saw in `repository.WarmupContentRepeatWindow`, then the least recently seen. Do not add a path that defers sending for lack of fresh content, and do not reintroduce a lifetime per-mailbox exclusion.
|
||||
- A library thread's ID is derived from its theme and opening, so editing one retires it and threads in flight on it close. Keep the library above the floor `TestStaticLibraryReadsAsOrdinaryMail` enforces.
|
||||
- Do not add random strings, fabricated reply prefixes, invented relationships or other cosmetic variation to disguise repetition. Content variation never bypasses mailbox consent, authentication checks, provider limits, suppression or pacing.
|
||||
- Do not claim that wording or local checks guarantee inbox placement, improve reputation or prevent provider suspensions.
|
||||
|
||||
CI is strict. `go build ./...` succeeding is not enough — `golangci-lint` runs `gofmt` as part of its checks, and a single unformatted import block or mis-indented doc comment will fail the PR even when the code compiles cleanly. Before declaring any Go change done:
|
||||
|
||||
- run `gofmt -w` on every Go file you touched (or `gofmt -w internal/ cmd/` to be safe)
|
||||
|
||||
@@ -697,10 +697,16 @@ consumer:
|
||||
#
|
||||
# The worker reads encrypted DEKs through the backend's /internal/dek
|
||||
# endpoint (the prod `http` provider, no worker DB), so `make backend`
|
||||
# must be running and INTERNAL_API_TOKEN must match.
|
||||
# must be running and INTERNAL_API_TOKEN must match. The seeded dev worker
|
||||
# also presents its own NODE_CREDENTIAL (internal/seed.DevNodeCredential), so it
|
||||
# keeps working with NODE_REQUIRE_NODE_CREDENTIAL=true on the backend.
|
||||
DEV_WORKER_ID := 10c8f5e4-1c39-5b2a-9c8b-3d2f0a8b1a01
|
||||
NODE_CREDENTIAL_DEV := dev-node-credential-not-for-production
|
||||
WORKER_ID ?= $(DEV_WORKER_ID)
|
||||
worker:
|
||||
$(WORKER_DEV_ENV) \
|
||||
WORKER_ID=10c8f5e4-1c39-5b2a-9c8b-3d2f0a8b1a01 \
|
||||
WORKER_ID=$(WORKER_ID) \
|
||||
$(if $(filter $(DEV_WORKER_ID),$(WORKER_ID)),NODE_CREDENTIAL=$(NODE_CREDENTIAL_DEV),) \
|
||||
ENCRYPTED_KEYS_PROVIDER=http \
|
||||
ENCRYPTED_KEYS_BACKEND_URL=http://localhost:8080 \
|
||||
ENCRYPTED_KEYS_WORKER_TOKEN=local-dev-internal-token \
|
||||
|
||||
Generated
+116
-112
@@ -9,8 +9,8 @@ overrides:
|
||||
js-yaml: ^4.3.1
|
||||
nanoid: ^3.3.17
|
||||
dompurify: ^3.4.17
|
||||
follow-redirects: ^1.16.1
|
||||
seroval: ^1.6.3
|
||||
follow-redirects: ^1.16.2
|
||||
seroval: ^1.6.11
|
||||
source-map-js: ^1.2.2
|
||||
|
||||
importers:
|
||||
@@ -67,7 +67,7 @@ importers:
|
||||
version: 5.103.1(@tanstack/react-query@5.103.1(react@19.3.0))(@types/react@19.3.0)(csstype@3.2.3)(react@19.3.0)
|
||||
axios:
|
||||
specifier: ^1.20.0
|
||||
version: 1.20.0
|
||||
version: 1.20.0(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0)
|
||||
class-variance-authority:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
@@ -119,7 +119,7 @@ importers:
|
||||
version: 9.39.5
|
||||
'@sentry/vite-plugin':
|
||||
specifier: ^5.4.0
|
||||
version: 5.4.0(rollup@4.65.0)
|
||||
version: 5.4.0(rollup@4.65.0)(supports-color@7.2.0)
|
||||
'@types/node':
|
||||
specifier: ^24.13.5
|
||||
version: 24.13.5
|
||||
@@ -131,22 +131,22 @@ importers:
|
||||
version: 19.3.0(@types/react@19.3.0)
|
||||
'@vitejs/plugin-react':
|
||||
specifier: ^5.2.0
|
||||
version: 5.2.0(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))
|
||||
version: 5.2.0(supports-color@7.2.0)(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))
|
||||
eslint:
|
||||
specifier: ^9.39.5
|
||||
version: 9.39.5(jiti@2.7.0)
|
||||
version: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
eslint-plugin-react-hooks:
|
||||
specifier: ^5.2.0
|
||||
version: 5.2.0(eslint@9.39.5(jiti@2.7.0))
|
||||
version: 5.2.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))
|
||||
eslint-plugin-react-refresh:
|
||||
specifier: ^0.4.26
|
||||
version: 0.4.26(eslint@9.39.5(jiti@2.7.0))
|
||||
version: 0.4.26(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))
|
||||
globals:
|
||||
specifier: ^16.5.0
|
||||
version: 16.5.0
|
||||
jsdom:
|
||||
specifier: ^27.4.0
|
||||
version: 27.4.0
|
||||
version: 27.4.0(supports-color@7.2.0)
|
||||
tw-animate-css:
|
||||
specifier: ^1.4.0
|
||||
version: 1.4.0
|
||||
@@ -155,13 +155,13 @@ importers:
|
||||
version: 5.9.3
|
||||
typescript-eslint:
|
||||
specifier: ^8.70.0
|
||||
version: 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
version: 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
vite:
|
||||
specifier: ^7.3.7
|
||||
version: 7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0)
|
||||
vitest:
|
||||
specifier: ^4.1.11
|
||||
version: 4.1.11(@types/node@24.13.5)(jsdom@27.4.0)(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))
|
||||
version: 4.1.11(@types/node@24.13.5)(jsdom@27.4.0(supports-color@7.2.0))(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))
|
||||
|
||||
packages:
|
||||
|
||||
@@ -1889,8 +1889,8 @@ packages:
|
||||
flatted@3.4.4:
|
||||
resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==}
|
||||
|
||||
follow-redirects@1.16.1:
|
||||
resolution: {integrity: sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==}
|
||||
follow-redirects@1.16.2:
|
||||
resolution: {integrity: sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==}
|
||||
engines: {node: '>=4.0'}
|
||||
peerDependencies:
|
||||
debug: '*'
|
||||
@@ -2440,11 +2440,11 @@ packages:
|
||||
resolution: {integrity: sha512-HXuLAX2pu/UByPpaeo/TaMfvMIi+1QqIoPJYCcAtU8QkVNwgR6MPlGuCQTErV1JwraaMbYaWVIBX7mppzGLATQ==}
|
||||
engines: {node: '>=10'}
|
||||
peerDependencies:
|
||||
seroval: ^1.6.3
|
||||
seroval: ^1.6.11
|
||||
|
||||
seroval@1.6.8:
|
||||
resolution: {integrity: sha512-HlSgSAkTk4EqHcje1ptJjfZi1YDv5KbhVJ/d3P7T/nAXua2VmDu+AKDX5VTdFfZf48nDkWB2TKYt0DrCSa+3wg==}
|
||||
engines: {node: '>=10'}
|
||||
seroval@1.7.5:
|
||||
resolution: {integrity: sha512-UdNgpHdq0gVpme5JdQF+S3jNscnjFr4NTwUWOc1qcOa8OuWZmbV0+YX2hsqxkUZshBpHnpxDZfAKVZG2ugbrJA==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
set-cookie-parser@2.7.2:
|
||||
resolution: {integrity: sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==}
|
||||
@@ -2800,20 +2800,20 @@ snapshots:
|
||||
|
||||
'@babel/compat-data@7.29.7': {}
|
||||
|
||||
'@babel/core@7.29.7':
|
||||
'@babel/core@7.29.7(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.29.7
|
||||
'@babel/generator': 7.29.8
|
||||
'@babel/helper-compilation-targets': 7.29.7
|
||||
'@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7)
|
||||
'@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)
|
||||
'@babel/helpers': 7.29.7
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/template': 7.29.7
|
||||
'@babel/traverse': 7.29.8
|
||||
'@babel/traverse': 7.29.8(supports-color@7.2.0)
|
||||
'@babel/types': 7.29.8
|
||||
'@jridgewell/remapping': 2.3.5
|
||||
convert-source-map: 2.0.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
gensync: 1.0.0-beta.2
|
||||
json5: 2.2.3
|
||||
semver: 6.3.1
|
||||
@@ -2838,19 +2838,19 @@ snapshots:
|
||||
|
||||
'@babel/helper-globals@7.29.7': {}
|
||||
|
||||
'@babel/helper-module-imports@7.29.7':
|
||||
'@babel/helper-module-imports@7.29.7(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/traverse': 7.29.8
|
||||
'@babel/traverse': 7.29.8(supports-color@7.2.0)
|
||||
'@babel/types': 7.29.8
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)':
|
||||
'@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/helper-module-imports': 7.29.7
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-module-imports': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-validator-identifier': 7.29.7
|
||||
'@babel/traverse': 7.29.8
|
||||
'@babel/traverse': 7.29.8(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -2871,14 +2871,14 @@ snapshots:
|
||||
dependencies:
|
||||
'@babel/types': 7.29.8
|
||||
|
||||
'@babel/plugin-transform-react-jsx-self@7.29.7(@babel/core@7.29.7)':
|
||||
'@babel/plugin-transform-react-jsx-self@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-plugin-utils': 7.29.7
|
||||
|
||||
'@babel/plugin-transform-react-jsx-source@7.29.7(@babel/core@7.29.7)':
|
||||
'@babel/plugin-transform-react-jsx-source@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-plugin-utils': 7.29.7
|
||||
|
||||
'@babel/template@7.29.7':
|
||||
@@ -2887,7 +2887,7 @@ snapshots:
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/types': 7.29.8
|
||||
|
||||
'@babel/traverse@7.29.8':
|
||||
'@babel/traverse@7.29.8(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.29.7
|
||||
'@babel/generator': 7.29.8
|
||||
@@ -2895,7 +2895,7 @@ snapshots:
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/template': 7.29.7
|
||||
'@babel/types': 7.29.8
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -3011,17 +3011,17 @@ snapshots:
|
||||
'@esbuild/win32-x64@0.28.2':
|
||||
optional: true
|
||||
|
||||
'@eslint-community/eslint-utils@4.10.1(eslint@9.39.5(jiti@2.7.0))':
|
||||
'@eslint-community/eslint-utils@4.10.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
eslint-visitor-keys: 3.4.3
|
||||
|
||||
'@eslint-community/regexpp@4.12.2': {}
|
||||
|
||||
'@eslint/config-array@0.21.2':
|
||||
'@eslint/config-array@0.21.2(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@eslint/object-schema': 2.1.7
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
minimatch: 3.1.5
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -3034,10 +3034,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/json-schema': 7.0.15
|
||||
|
||||
'@eslint/eslintrc@3.3.7':
|
||||
'@eslint/eslintrc@3.3.7(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
ajv: 6.15.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
espree: 10.4.0
|
||||
globals: 14.0.0
|
||||
ignore: 5.3.2
|
||||
@@ -3656,10 +3656,10 @@ snapshots:
|
||||
'@sentry/replay': 10.75.0
|
||||
'@sentry/replay-canvas': 10.75.0
|
||||
|
||||
'@sentry/bundler-plugins@10.75.0(rollup@4.65.0)':
|
||||
'@sentry/bundler-plugins@10.75.0(rollup@4.65.0)(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@sentry/cli': 2.58.6
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@sentry/cli': 2.58.6(supports-color@7.2.0)
|
||||
'@sentry/core': 10.75.0
|
||||
dotenv: 17.4.2
|
||||
find-up: 5.0.0
|
||||
@@ -3695,9 +3695,9 @@ snapshots:
|
||||
'@sentry/cli-win32-x64@2.58.6':
|
||||
optional: true
|
||||
|
||||
'@sentry/cli@2.58.6':
|
||||
'@sentry/cli@2.58.6(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
https-proxy-agent: 5.0.1
|
||||
https-proxy-agent: 5.0.1(supports-color@7.2.0)
|
||||
node-fetch: 2.7.0
|
||||
progress: 2.0.3
|
||||
proxy-from-env: 1.1.0
|
||||
@@ -3742,9 +3742,9 @@ snapshots:
|
||||
'@sentry/browser-utils': 10.75.0
|
||||
'@sentry/core': 10.75.0
|
||||
|
||||
'@sentry/vite-plugin@5.4.0(rollup@4.65.0)':
|
||||
'@sentry/vite-plugin@5.4.0(rollup@4.65.0)(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@sentry/bundler-plugins': 10.75.0(rollup@4.65.0)
|
||||
'@sentry/bundler-plugins': 10.75.0(rollup@4.65.0)(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- rollup
|
||||
@@ -3976,15 +3976,15 @@ snapshots:
|
||||
'@types/trusted-types@2.0.7':
|
||||
optional: true
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.70.0(@typescript-eslint/parser@8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)':
|
||||
'@typescript-eslint/eslint-plugin@8.70.0(@typescript-eslint/parser@8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@typescript-eslint/parser': 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
'@typescript-eslint/parser': 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/scope-manager': 8.70.0
|
||||
'@typescript-eslint/type-utils': 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
'@typescript-eslint/type-utils': 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/visitor-keys': 8.70.0
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
ignore: 7.0.9
|
||||
natural-compare: 1.4.0
|
||||
ts-api-utils: 2.5.0(typescript@5.9.3)
|
||||
@@ -3992,23 +3992,23 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/parser@8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)':
|
||||
'@typescript-eslint/parser@8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 8.70.0
|
||||
'@typescript-eslint/types': 8.70.0
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@5.9.3)
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/visitor-keys': 8.70.0
|
||||
debug: 4.4.3
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/project-service@8.70.0(typescript@5.9.3)':
|
||||
'@typescript-eslint/project-service@8.70.0(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/tsconfig-utils': 8.70.0(typescript@5.9.3)
|
||||
'@typescript-eslint/types': 8.70.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -4022,13 +4022,13 @@ snapshots:
|
||||
dependencies:
|
||||
typescript: 5.9.3
|
||||
|
||||
'@typescript-eslint/type-utils@8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)':
|
||||
'@typescript-eslint/type-utils@8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.70.0
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
debug: 4.4.3
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
ts-api-utils: 2.5.0(typescript@5.9.3)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
@@ -4036,13 +4036,13 @@ snapshots:
|
||||
|
||||
'@typescript-eslint/types@8.70.0': {}
|
||||
|
||||
'@typescript-eslint/typescript-estree@8.70.0(typescript@5.9.3)':
|
||||
'@typescript-eslint/typescript-estree@8.70.0(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/project-service': 8.70.0(typescript@5.9.3)
|
||||
'@typescript-eslint/project-service': 8.70.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/tsconfig-utils': 8.70.0(typescript@5.9.3)
|
||||
'@typescript-eslint/types': 8.70.0
|
||||
'@typescript-eslint/visitor-keys': 8.70.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
minimatch: 10.2.6
|
||||
semver: 7.8.5
|
||||
tinyglobby: 0.2.17
|
||||
@@ -4051,13 +4051,13 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/utils@8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)':
|
||||
'@typescript-eslint/utils@8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0))
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))
|
||||
'@typescript-eslint/scope-manager': 8.70.0
|
||||
'@typescript-eslint/types': 8.70.0
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@5.9.3)
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -4067,11 +4067,11 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.70.0
|
||||
eslint-visitor-keys: 5.0.1
|
||||
|
||||
'@vitejs/plugin-react@5.2.0(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))':
|
||||
'@vitejs/plugin-react@5.2.0(supports-color@7.2.0)(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7)
|
||||
'@babel/plugin-transform-react-jsx-source': 7.29.7(@babel/core@7.29.7)
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))
|
||||
'@babel/plugin-transform-react-jsx-source': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))
|
||||
'@rolldown/pluginutils': 1.0.0-rc.3
|
||||
'@types/babel__core': 7.20.5
|
||||
react-refresh: 0.18.0
|
||||
@@ -4126,9 +4126,9 @@ snapshots:
|
||||
|
||||
acorn@8.18.0: {}
|
||||
|
||||
agent-base@6.0.2:
|
||||
agent-base@6.0.2(supports-color@7.2.0):
|
||||
dependencies:
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -4155,11 +4155,11 @@ snapshots:
|
||||
|
||||
asynckit@0.4.0: {}
|
||||
|
||||
axios@1.20.0:
|
||||
axios@1.20.0(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0):
|
||||
dependencies:
|
||||
follow-redirects: 1.16.1
|
||||
follow-redirects: 1.16.2(debug@4.4.3(supports-color@7.2.0))
|
||||
form-data: 4.0.6
|
||||
https-proxy-agent: 5.0.1
|
||||
https-proxy-agent: 5.0.1(supports-color@7.2.0)
|
||||
proxy-from-env: 2.1.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
@@ -4273,9 +4273,11 @@ snapshots:
|
||||
|
||||
date-fns@4.4.0: {}
|
||||
|
||||
debug@4.4.3:
|
||||
debug@4.4.3(supports-color@7.2.0):
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
optionalDependencies:
|
||||
supports-color: 7.2.0
|
||||
|
||||
decimal.js@10.6.0: {}
|
||||
|
||||
@@ -4358,13 +4360,13 @@ snapshots:
|
||||
|
||||
escape-string-regexp@4.0.0: {}
|
||||
|
||||
eslint-plugin-react-hooks@5.2.0(eslint@9.39.5(jiti@2.7.0)):
|
||||
eslint-plugin-react-hooks@5.2.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)):
|
||||
dependencies:
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
|
||||
eslint-plugin-react-refresh@0.4.26(eslint@9.39.5(jiti@2.7.0)):
|
||||
eslint-plugin-react-refresh@0.4.26(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)):
|
||||
dependencies:
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
|
||||
eslint-scope@8.4.0:
|
||||
dependencies:
|
||||
@@ -4377,14 +4379,14 @@ snapshots:
|
||||
|
||||
eslint-visitor-keys@5.0.1: {}
|
||||
|
||||
eslint@9.39.5(jiti@2.7.0):
|
||||
eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0):
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0))
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@eslint/config-array': 0.21.2
|
||||
'@eslint/config-array': 0.21.2(supports-color@7.2.0)
|
||||
'@eslint/config-helpers': 0.4.2
|
||||
'@eslint/core': 0.17.0
|
||||
'@eslint/eslintrc': 3.3.7
|
||||
'@eslint/eslintrc': 3.3.7(supports-color@7.2.0)
|
||||
'@eslint/js': 9.39.5
|
||||
'@eslint/plugin-kit': 0.4.1
|
||||
'@humanfs/node': 0.16.8
|
||||
@@ -4394,7 +4396,7 @@ snapshots:
|
||||
ajv: 6.15.0
|
||||
chalk: 4.1.2
|
||||
cross-spawn: 7.0.6
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
escape-string-regexp: 4.0.0
|
||||
eslint-scope: 8.4.0
|
||||
eslint-visitor-keys: 4.2.1
|
||||
@@ -4470,7 +4472,9 @@ snapshots:
|
||||
|
||||
flatted@3.4.4: {}
|
||||
|
||||
follow-redirects@1.16.1: {}
|
||||
follow-redirects@1.16.2(debug@4.4.3(supports-color@7.2.0)):
|
||||
optionalDependencies:
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
|
||||
form-data@4.0.6:
|
||||
dependencies:
|
||||
@@ -4556,24 +4560,24 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- '@noble/hashes'
|
||||
|
||||
http-proxy-agent@7.0.2:
|
||||
http-proxy-agent@7.0.2(supports-color@7.2.0):
|
||||
dependencies:
|
||||
agent-base: 7.1.4
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
https-proxy-agent@5.0.1:
|
||||
https-proxy-agent@5.0.1(supports-color@7.2.0):
|
||||
dependencies:
|
||||
agent-base: 6.0.2
|
||||
debug: 4.4.3
|
||||
agent-base: 6.0.2(supports-color@7.2.0)
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
https-proxy-agent@7.0.6:
|
||||
https-proxy-agent@7.0.6(supports-color@7.2.0):
|
||||
dependencies:
|
||||
agent-base: 7.1.4
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -4611,7 +4615,7 @@ snapshots:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
|
||||
jsdom@27.4.0:
|
||||
jsdom@27.4.0(supports-color@7.2.0):
|
||||
dependencies:
|
||||
'@acemir/cssom': 0.9.31
|
||||
'@asamuzakjp/dom-selector': 6.8.1
|
||||
@@ -4620,8 +4624,8 @@ snapshots:
|
||||
data-urls: 6.0.1
|
||||
decimal.js: 10.6.0
|
||||
html-encoding-sniffer: 6.0.0
|
||||
http-proxy-agent: 7.0.2
|
||||
https-proxy-agent: 7.0.6
|
||||
http-proxy-agent: 7.0.2(supports-color@7.2.0)
|
||||
https-proxy-agent: 7.0.6(supports-color@7.2.0)
|
||||
is-potential-custom-element-name: 1.0.1
|
||||
parse5: 8.0.1
|
||||
saxes: 6.0.0
|
||||
@@ -4956,11 +4960,11 @@ snapshots:
|
||||
|
||||
semver@7.8.5: {}
|
||||
|
||||
seroval-plugins@1.5.6(seroval@1.6.8):
|
||||
seroval-plugins@1.5.6(seroval@1.7.5):
|
||||
dependencies:
|
||||
seroval: 1.6.8
|
||||
seroval: 1.7.5
|
||||
|
||||
seroval@1.6.8: {}
|
||||
seroval@1.7.5: {}
|
||||
|
||||
set-cookie-parser@2.7.2: {}
|
||||
|
||||
@@ -4975,8 +4979,8 @@ snapshots:
|
||||
solid-js@1.9.15:
|
||||
dependencies:
|
||||
csstype: 3.2.3
|
||||
seroval: 1.6.8
|
||||
seroval-plugins: 1.5.6(seroval@1.6.8)
|
||||
seroval: 1.7.5
|
||||
seroval-plugins: 1.5.6(seroval@1.7.5)
|
||||
|
||||
solid-presence@0.2.0(solid-js@1.9.15):
|
||||
dependencies:
|
||||
@@ -5064,13 +5068,13 @@ snapshots:
|
||||
dependencies:
|
||||
prelude-ls: 1.2.1
|
||||
|
||||
typescript-eslint@8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3):
|
||||
typescript-eslint@8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3):
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.70.0(@typescript-eslint/parser@8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
'@typescript-eslint/parser': 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.70.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)
|
||||
eslint: 9.39.5(jiti@2.7.0)
|
||||
'@typescript-eslint/eslint-plugin': 8.70.0(@typescript-eslint/parser@8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/parser': 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/typescript-estree': 8.70.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.70.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -5118,7 +5122,7 @@ snapshots:
|
||||
jiti: 2.7.0
|
||||
lightningcss: 1.32.0
|
||||
|
||||
vitest@4.1.11(@types/node@24.13.5)(jsdom@27.4.0)(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0)):
|
||||
vitest@4.1.11(@types/node@24.13.5)(jsdom@27.4.0(supports-color@7.2.0))(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0)):
|
||||
dependencies:
|
||||
'@vitest/expect': 4.1.11
|
||||
'@vitest/mocker': 4.1.11(vite@7.3.7(@types/node@24.13.5)(jiti@2.7.0)(lightningcss@1.32.0))
|
||||
@@ -5142,7 +5146,7 @@ snapshots:
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@types/node': 24.13.5
|
||||
jsdom: 27.4.0
|
||||
jsdom: 27.4.0(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- msw
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ overrides:
|
||||
js-yaml: ^4.3.1
|
||||
nanoid: ^3.3.17
|
||||
dompurify: ^3.4.17
|
||||
follow-redirects: ^1.16.1
|
||||
seroval: ^1.6.3
|
||||
follow-redirects: ^1.16.2
|
||||
seroval: ^1.6.11
|
||||
source-map-js: ^1.2.2
|
||||
|
||||
@@ -3,6 +3,7 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { LoginCodeExemption } from "@/lib/api/models/admin";
|
||||
import { ConfirmProvider } from "@/components/ConfirmDialog";
|
||||
import TestersPage from "./TestersPage";
|
||||
|
||||
const access = vi.hoisted(() => ({ canManage: true }));
|
||||
@@ -15,12 +16,24 @@ function render(tester: Partial<LoginCodeExemption>) {
|
||||
client.setQueryData(["admin", "testers"], {
|
||||
data: [{ user_id: "reviewer", email: "reviewer@example.test", password_expires_at: "2100-01-01T00:00:00Z", ...tester }],
|
||||
});
|
||||
const html = renderToStaticMarkup(<QueryClientProvider client={client}><MemoryRouter initialEntries={["/testers"]}><TestersPage /></MemoryRouter></QueryClientProvider>);
|
||||
const html = renderToStaticMarkup(<QueryClientProvider client={client}><MemoryRouter initialEntries={["/testers"]}><ConfirmProvider><TestersPage /></ConfirmProvider></MemoryRouter></QueryClientProvider>);
|
||||
client.clear();
|
||||
const document = new DOMParser().parseFromString(html, "text/html");
|
||||
return document;
|
||||
}
|
||||
|
||||
describe("tester password re-issue", () => {
|
||||
beforeEach(() => { access.canManage = true; });
|
||||
|
||||
it("offers a new password only on accounts created as testers, to managers", () => {
|
||||
const selector = 'button[aria-label^="Issue new password for"]';
|
||||
expect(render({ created_as_tester: true }).querySelector(selector)).not.toBeNull();
|
||||
expect(render({ created_as_tester: false }).querySelector(selector)).toBeNull();
|
||||
access.canManage = false;
|
||||
expect(render({ created_as_tester: true }).querySelector(selector)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("tester sample-data controls", () => {
|
||||
beforeEach(() => { access.canManage = true; });
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import { useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { AlertTriangle, CopyIcon, FlaskConicalIcon, RotateCw, TrashIcon } from "lucide-react";
|
||||
import { AlertTriangle, CopyIcon, FlaskConicalIcon, KeyRoundIcon, RotateCw, TrashIcon } from "lucide-react";
|
||||
import { PageHeader } from "@/components/layout/PageHeader";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -29,10 +29,11 @@ import { Callout, EmptyState, Panel, Segmented, StatusBadge } from "@/components
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useAdminPerm } from "@/hooks/useAdminPerm";
|
||||
import { AdminPerm } from "@/lib/auth/permissions";
|
||||
import { createTester, listTesters, listOrganizationRoles, revokeTester, seedTesterWorkspace } from "@/lib/api/client/admin/testers";
|
||||
import { createTester, listTesters, listOrganizationRoles, reissueTesterPassword, revokeTester, seedTesterWorkspace } from "@/lib/api/client/admin/testers";
|
||||
import { useConfirm } from "@/components/ConfirmDialog";
|
||||
import { listOrganizations } from "@/lib/api/client/admin/organizations";
|
||||
import { DASHBOARD_URL } from "@/lib/env";
|
||||
import type { AdminOrgListItem, CreatedTester } from "@/lib/api/models/admin";
|
||||
import type { AdminOrgListItem, CreatedTester, ReissuedTesterPassword } from "@/lib/api/models/admin";
|
||||
|
||||
function fmt(ts?: string | null) {
|
||||
if (!ts) return "—";
|
||||
@@ -54,6 +55,9 @@ export default function TestersPage() {
|
||||
// Held in state, never refetched: the server returns it once and cannot
|
||||
// produce it again.
|
||||
const [created, setCreated] = useState<CreatedTester | null>(null);
|
||||
// Same rule for a re-issued password: shown once, from state only.
|
||||
const [reissued, setReissued] = useState<(ReissuedTesterPassword & { email: string }) | null>(null);
|
||||
const confirm = useConfirm();
|
||||
const [sampleTarget, setSampleTarget] = useState<{ organizationID: string; email: string } | null>(null);
|
||||
|
||||
const testers = useQuery({
|
||||
@@ -116,6 +120,27 @@ export default function TestersPage() {
|
||||
onError: (e: Error) => toast.error(e.message || "Could not revoke the exemption"),
|
||||
});
|
||||
|
||||
const reissue = useMutation({
|
||||
mutationFn: (t: { id: string; email: string }) => reissueTesterPassword(t.id),
|
||||
onSuccess: (r, t) => {
|
||||
setReissued({ ...r, email: t.email });
|
||||
qc.invalidateQueries({ queryKey: ["admin", "testers"] });
|
||||
toast.success("New initial password issued; every session was signed out");
|
||||
},
|
||||
onError: (e: Error) => toast.error(e.message || "Could not issue a new password"),
|
||||
});
|
||||
|
||||
async function onReissue(id: string, email: string) {
|
||||
const ok = await confirm({
|
||||
title: `Issue a new password for ${email}?`,
|
||||
description:
|
||||
"The account's current password stops working and every session it holds is signed out. The new password is shown once, is valid for 48 hours and must be changed at first sign-in.",
|
||||
confirmLabel: "Issue new password",
|
||||
destructive: true,
|
||||
});
|
||||
if (ok) await reissue.mutateAsync({ id, email }).catch(() => undefined);
|
||||
}
|
||||
|
||||
const seed = useMutation({
|
||||
mutationFn: (orgID: string) => seedTesterWorkspace(orgID),
|
||||
onSuccess: (result) => {
|
||||
@@ -156,8 +181,9 @@ export default function TestersPage() {
|
||||
holder cannot read this instance's mail, and arrives with onboarding complete. Authentication still requires the password,
|
||||
the captcha and the sign-in risk assessment. A tester either gets a workspace of its own
|
||||
or joins one that already exists. A new Test workspace includes paid-feature access and 100 test credits until the password expires.
|
||||
An existing workspace keeps its plan and the role you select. Its password stops working on the date you choose, and
|
||||
revoking it ends the password and signs out every session at once.
|
||||
An existing workspace keeps its plan and the role you select. The password it is issued is an initial password: valid
|
||||
for at most 48 hours, it cannot be extended, and the holder must replace it with their own at first sign-in.
|
||||
Revoking a tester ends its password, issued or chosen, and signs out every session at once.
|
||||
Use Add sample data on an active dedicated Test workspace to populate contacts, a draft campaign, templates and CRM examples.
|
||||
Mailboxes must be connected separately.
|
||||
</>
|
||||
@@ -177,6 +203,10 @@ export default function TestersPage() {
|
||||
? "This account is a member of an existing workspace and will land in it on sign-in."
|
||||
: "This account owns a new Test workspace with paid-feature access and 100 test credits until the password expires."}
|
||||
</div>
|
||||
<div className="mt-0.5 text-[12.5px] text-muted-foreground">
|
||||
This is an initial password. It is valid until {fmt(created.password_expires_at)} (48 hours at most) and
|
||||
must be changed at first sign-in, when the holder is asked to choose their own.
|
||||
</div>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" onClick={() => setCreated(null)}>
|
||||
Done
|
||||
@@ -187,7 +217,7 @@ export default function TestersPage() {
|
||||
["Sign in at", DASHBOARD_URL],
|
||||
["Email", created.email],
|
||||
["Password", created.password],
|
||||
["Expires", fmt(created.password_expires_at)],
|
||||
["Valid until", fmt(created.password_expires_at)],
|
||||
].map(([k, v]) => (
|
||||
<div key={k} className="flex min-h-10 items-center gap-3 px-4 py-1.5 text-[13px]">
|
||||
<dt className="w-24 shrink-0 text-muted-foreground">{k}</dt>
|
||||
@@ -218,6 +248,46 @@ export default function TestersPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{reissued && (
|
||||
<div className="mb-8 overflow-hidden rounded-lg border border-amber-500/25 bg-amber-500/[0.07]">
|
||||
<div className="flex items-start gap-3 px-4 py-3">
|
||||
<AlertTriangle className="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[13px] font-medium text-foreground">
|
||||
Copy this now. The password is not stored anywhere readable.
|
||||
</div>
|
||||
<div className="mt-0.5 text-[12.5px] text-muted-foreground">
|
||||
A new initial password for {reissued.email}. It is valid until {fmt(reissued.password_expires_at)} (48
|
||||
hours) and must be changed at first sign-in. The previous password no longer works.
|
||||
</div>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" onClick={() => setReissued(null)}>
|
||||
Done
|
||||
</Button>
|
||||
</div>
|
||||
<dl className="divide-y divide-border/70 border-t border-amber-500/20 bg-card">
|
||||
{[
|
||||
["Email", reissued.email],
|
||||
["Password", reissued.password],
|
||||
["Valid until", fmt(reissued.password_expires_at)],
|
||||
].map(([k, v]) => (
|
||||
<div key={k} className="flex min-h-10 items-center gap-3 px-4 py-1.5 text-[13px]">
|
||||
<dt className="w-24 shrink-0 text-muted-foreground">{k}</dt>
|
||||
<dd
|
||||
className="min-w-0 flex-1 font-mono text-[12.5px] break-all text-foreground"
|
||||
data-ph-mask={k === "Password" ? "" : undefined}
|
||||
>
|
||||
{v}
|
||||
</dd>
|
||||
<Button size="icon-xs" variant="ghost" onClick={() => copy(String(v))} aria-label={`Copy ${k}`}>
|
||||
<CopyIcon className="size-3" />
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={cn("grid items-start gap-8", canManage && "lg:grid-cols-[minmax(0,1fr)_380px]")}>
|
||||
<section className="min-w-0">
|
||||
<h2 className="mb-3 text-[13px] font-semibold text-foreground">
|
||||
@@ -292,7 +362,7 @@ export default function TestersPage() {
|
||||
dot={expired}
|
||||
className="hidden sm:inline-flex"
|
||||
>
|
||||
Password {expired ? "expired" : "expires"} {fmt(t.password_expires_at)}
|
||||
Initial password {expired ? "expired" : "valid until"} {fmt(t.password_expires_at)}
|
||||
</StatusBadge>
|
||||
)}
|
||||
{canManage && (
|
||||
@@ -308,6 +378,17 @@ export default function TestersPage() {
|
||||
{t.sample_data_seeded_at ? "Sample data added" : "Add sample data"}
|
||||
</Button>
|
||||
)}
|
||||
{t.created_as_tester && (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
disabled={reissue.isPending || revoke.isPending || seed.isPending}
|
||||
aria-label={`Issue new password for ${t.email}`}
|
||||
onClick={() => void onReissue(t.user_id, t.email)}
|
||||
>
|
||||
<KeyRoundIcon className="size-3" /> Issue new password
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
@@ -462,6 +543,9 @@ export default function TestersPage() {
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p className="mt-1.5 text-xs text-muted-foreground">
|
||||
Valid 48 hours at most and never extendable. The holder must change it at first sign-in.
|
||||
</p>
|
||||
</Field>
|
||||
|
||||
<div className="flex justify-end border-t border-border pt-4">
|
||||
|
||||
@@ -71,7 +71,7 @@ export function UserLoginCodeCard({ user }: { user: AdminUserDetail }) {
|
||||
title: `Require the emailed sign-in code for ${user.email} again?`,
|
||||
description: user.password_expires_at
|
||||
? "Every session this account holds is signed out, and the password handed out with it stops working."
|
||||
: "Every session this account holds is signed out. Its password is kept.",
|
||||
: "Every session this account holds is signed out. An account created under Testers also loses the password its holder chose; any other keeps its password.",
|
||||
confirmLabel: "Remove exemption",
|
||||
destructive: true,
|
||||
});
|
||||
|
||||
@@ -63,22 +63,22 @@ function pipelineSteps(d: WarmupContentOverview): PipelineStep[] {
|
||||
label: "AI content enabled",
|
||||
ok: d.ai_enabled,
|
||||
detail: d.ai_enabled
|
||||
? `${d.ai_selection_share}% of warmup sends draw AI content`
|
||||
: "Static fallback is active",
|
||||
? "Approved pool reuses plans without mailbox repeats"
|
||||
: "New conversations wait for fresh approved content",
|
||||
},
|
||||
{
|
||||
label: "Scheduled top-up",
|
||||
ok: d.schedule_enabled,
|
||||
detail: d.schedule_enabled
|
||||
? `Tops the library up every ${d.cadence_hours}h`
|
||||
: "Static fallback is active",
|
||||
: "Automatic replenishment off; eligible pooled plans remain available",
|
||||
},
|
||||
{
|
||||
label: "Library stocked",
|
||||
ok: stocked,
|
||||
detail:
|
||||
totalTarget > 0
|
||||
? `${totalStock.toLocaleString()} of ${totalTarget.toLocaleString()} target threads active`
|
||||
? `${totalStock.toLocaleString()} of ${totalTarget.toLocaleString()} target eligible plans ready`
|
||||
: "Waiting for demand history",
|
||||
},
|
||||
];
|
||||
@@ -121,7 +121,7 @@ function AutomationPanel({ data }: { data: WarmupContentOverview }) {
|
||||
{allOk
|
||||
? data.refresh_enabled
|
||||
? "Scheduled generation preserves canonical content and reviews complete rendered diagnostic threads before activating them."
|
||||
: "The library tops itself up to the target. Continuous refresh is off, so generation pauses once the target is reached."
|
||||
: "The library tops itself up to the target. Consumed threads trigger automatic replenishment even when refresh is off."
|
||||
: "Not fully automatic yet. Fix the first amber step below and the library will keep itself stocked without manual runs."}
|
||||
</p>
|
||||
|
||||
@@ -166,18 +166,18 @@ function AutomationPanel({ data }: { data: WarmupContentOverview }) {
|
||||
<Property label="Continuous refresh">
|
||||
{data.refresh_enabled ? (
|
||||
<span>
|
||||
On, recycles the <span className="tabular-nums">{data.refresh_per_run}</span> most-used threads
|
||||
On, recycles the <span className="tabular-nums">{data.refresh_per_run}</span> unused plans
|
||||
each run
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">Static fallback active</span>
|
||||
<span className="text-muted-foreground">Optional refresh off</span>
|
||||
)}
|
||||
</Property>
|
||||
</PropertyList>
|
||||
|
||||
<p className="border-t border-border px-4 py-3 text-xs leading-relaxed text-muted-foreground">
|
||||
Generated threads are humanized, lint-gated, and any send that fails the gate falls back to the static
|
||||
library. Threads with a meaningful sample and unsafe spam placement are archived automatically.
|
||||
Generated plans pass structural checks and a separate content review. Plans remain reusable with other mailboxes,
|
||||
without repeating for either participant. Sending waits when no eligible plan is available.
|
||||
</p>
|
||||
</Panel>
|
||||
);
|
||||
@@ -226,14 +226,14 @@ function StockTable({ data }: { data: WarmupContentOverview }) {
|
||||
return (
|
||||
<Section
|
||||
title="Stock vs target"
|
||||
description="The target is calculated from the last seven days of total warmup sends. The controller keeps at least 200 shared threads, expands the bank automatically, and submits at most 250 new threads in one batch."
|
||||
description="Ready stock accounts for mailbox history. The busiest mailbox’s demand over the last seven days adjusts the target, with a default floor of 200 eligible plans and at most 250 new plans per batch."
|
||||
>
|
||||
<TableShell>
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
<Th>Segment</Th>
|
||||
<Th right>Daily demand</Th>
|
||||
<Th right>Active</Th>
|
||||
<Th right>Ready</Th>
|
||||
<Th right>Target</Th>
|
||||
<Th>Fill</Th>
|
||||
</tr>
|
||||
@@ -411,7 +411,7 @@ export default function OverviewPage() {
|
||||
<EmptyRow
|
||||
cols={4}
|
||||
title="No generated content yet"
|
||||
hint="The controller will submit a batch automatically; static content is active meanwhile."
|
||||
hint="The controller submits batches automatically; new sending waits for eligible approved content."
|
||||
/>
|
||||
)}
|
||||
</tbody>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// exemptions are the same query.
|
||||
|
||||
import { Request } from "@/lib/api/client";
|
||||
import type { LoginCodeExemption, CreatedTester, AdminOrgRole } from "@/lib/api/models/admin";
|
||||
import type { LoginCodeExemption, CreatedTester, AdminOrgRole, ReissuedTesterPassword } from "@/lib/api/models/admin";
|
||||
|
||||
export function listTesters(): Promise<{ data: LoginCodeExemption[] }> {
|
||||
return Request({ method: "GET", url: "/admin/testers", authorization: true });
|
||||
@@ -38,3 +38,8 @@ export function revokeTester(id: string): Promise<{ revoked: boolean; password_c
|
||||
export function seedTesterWorkspace(orgID: string): Promise<{ organization_id: string; created: boolean; seeded_at: string }> {
|
||||
return Request({ method: "POST", url: `/admin/organizations/${orgID}/sample-data`, authorization: true });
|
||||
}
|
||||
|
||||
/** Issues a tester a fresh 48-hour initial password and signs out its sessions. Needs a recent confirmation. */
|
||||
export function reissueTesterPassword(id: string): Promise<ReissuedTesterPassword> {
|
||||
return Request({ method: "POST", url: `/admin/testers/${id}/password`, authorization: true });
|
||||
}
|
||||
|
||||
@@ -1010,11 +1010,22 @@ export interface LoginCodeExemption {
|
||||
email: string;
|
||||
reason?: string | null;
|
||||
granted_at?: string | null;
|
||||
/** When the handed-out password stops working; absent for an account
|
||||
* exempted without one. */
|
||||
/** When the issued initial password stops working; absent once the holder
|
||||
* has chosen their own, or for an account exempted without one. */
|
||||
password_expires_at?: string | null;
|
||||
test_workspace_id?: string | null;
|
||||
sample_data_seeded_at?: string | null;
|
||||
/** Created through the tester flow, so it can be issued a new password. */
|
||||
created_as_tester?: boolean;
|
||||
}
|
||||
|
||||
/** A fresh initial password for an existing tester, readable this once. */
|
||||
export interface ReissuedTesterPassword {
|
||||
user_id: string;
|
||||
password: string;
|
||||
/** 48 hours after issuance. */
|
||||
password_expires_at: string;
|
||||
password_change_required: boolean;
|
||||
}
|
||||
|
||||
/** The one time the password is readable. It is not stored in a form anyone
|
||||
@@ -1024,8 +1035,10 @@ export interface CreatedTester {
|
||||
email: string;
|
||||
organization_id: string;
|
||||
password: string;
|
||||
/** When the password stops working. */
|
||||
/** When the password stops working, 48 hours after issuance at most. */
|
||||
password_expires_at: string;
|
||||
/** Always true: the holder replaces this initial password at first sign-in. */
|
||||
password_change_required?: boolean;
|
||||
/** True when the tester joined a workspace that already existed rather
|
||||
* than one minted for it. */
|
||||
joined_existing: boolean;
|
||||
|
||||
+37
-15
@@ -87,6 +87,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/app/monitoring"
|
||||
"github.com/warmbly/warmbly/internal/app/nativeactions"
|
||||
"github.com/warmbly/warmbly/internal/app/nodelogs"
|
||||
"github.com/warmbly/warmbly/internal/app/nodescope"
|
||||
"github.com/warmbly/warmbly/internal/app/notification"
|
||||
"github.com/warmbly/warmbly/internal/app/oauth"
|
||||
"github.com/warmbly/warmbly/internal/app/oidcauth"
|
||||
@@ -162,6 +163,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/pkg/idtoken"
|
||||
"github.com/warmbly/warmbly/internal/pkg/mailhost"
|
||||
"github.com/warmbly/warmbly/internal/pkg/mailvendor"
|
||||
"github.com/warmbly/warmbly/internal/pkg/servetls"
|
||||
"github.com/warmbly/warmbly/internal/pkg/typesafe"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
"github.com/warmbly/warmbly/internal/scheduler"
|
||||
@@ -226,6 +228,7 @@ func main() {
|
||||
var fleetNodeRepo repository.FleetNodeRepository
|
||||
var fleetSettingsRepo repository.FleetSettingsRepository
|
||||
var fleetNodeService *fleetnode.Service
|
||||
var nodeScopeService *nodescope.Service
|
||||
var keyStatusDB keystatus.DB
|
||||
var tasksService tasks.TasksService
|
||||
var advancedService advanced.Service
|
||||
@@ -796,8 +799,7 @@ func main() {
|
||||
|
||||
// Warmup content bank + offline AI generator. The generator rides OpenAI's
|
||||
// Batch API specifically, so it only runs when the selected provider is
|
||||
// OpenAI itself; otherwise the live send path keeps using the static
|
||||
// library and admin generation returns "not configured".
|
||||
// OpenAI itself; otherwise new threads wait for fresh approved content.
|
||||
var generationClient *generation.GenerationClient
|
||||
if (aiProviderName == "" || aiProviderName == "openai") && aiKey != "" {
|
||||
generationClient = generation.NewClient(aiKey)
|
||||
@@ -1212,6 +1214,7 @@ func main() {
|
||||
fleetNodeRepo = repository.NewFleetNodeRepository(primaryDB)
|
||||
fleetSettingsRepo = repository.NewFleetSettingsRepository(primaryDB)
|
||||
fleetNodeService = fleetnode.New(fleetNodeRepo, workerRepository, fleetSettingsRepo)
|
||||
nodeScopeService = nodescope.New(repository.NewNodeScopeRepository(primaryDB), cache.Client)
|
||||
// Idle unless a staged rollout was started; every replica may run it.
|
||||
go fleetNodeService.RunRolloutLoop(ctx, 30*time.Second)
|
||||
settingsRegistrar := settings.NewRegistrar(storageBackendRepo)
|
||||
@@ -1976,6 +1979,8 @@ func main() {
|
||||
// Sending domains: tracking host per domain and the bare-domain redirect.
|
||||
sendingDomainService = sendingdomain.NewService(repository.NewDomainRedirectRepository(primaryDB), emailRepostory, nil, domainProver)
|
||||
sendingDomainService.WireAuditor(auditService)
|
||||
// A website the workspace proves with its TXT record becomes one of its own domains too.
|
||||
ownDomains.WireWebsites(repository.NewWebsiteDomainRepository(primaryDB), domainProver, nil)
|
||||
sendingDomainService.WireOwnDomains(ownDomains)
|
||||
sendingDomainService.WireCustomHosts(customHosts)
|
||||
// A linked self-hosted instance can have Warmbly Cloud serve a redirect instead.
|
||||
@@ -2640,6 +2645,7 @@ func main() {
|
||||
FleetNodeRepo: fleetNodeRepo,
|
||||
FleetSettingsRepo: fleetSettingsRepo,
|
||||
FleetNodes: fleetNodeService,
|
||||
NodeScope: nodeScopeService,
|
||||
KeyStatusDB: keyStatusDB,
|
||||
|
||||
// Danger zone
|
||||
@@ -2672,6 +2678,9 @@ func main() {
|
||||
Cache: authCache,
|
||||
PoolLinkService: poolLinkService,
|
||||
}
|
||||
if fleetNodeService != nil {
|
||||
m.NodeCredentials = fleetNodeService
|
||||
}
|
||||
|
||||
oidcH := &middleware.OidcHandler{
|
||||
ServiceAccount: serviceAccount,
|
||||
@@ -2684,19 +2693,30 @@ func main() {
|
||||
|
||||
router := api.Run(h, m, oidcH, addr, ginMode, allowedOrigins)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: router,
|
||||
tlsListen, err := servetls.FromEnv(os.Getenv)
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid TLS listener setting: %v", err)
|
||||
}
|
||||
srv, tlsSrv, err := tlsListen.Servers(addr, router)
|
||||
if err != nil {
|
||||
log.Fatalf("TLS listener: %v", err)
|
||||
}
|
||||
servers := []*http.Server{srv}
|
||||
if tlsSrv != nil {
|
||||
servers = append(servers, tlsSrv)
|
||||
if exp := servetls.Expiry(tlsSrv.TLSConfig); time.Until(exp) < 30*24*time.Hour {
|
||||
log.Printf("TLS listener certificate expires %s; replace it before then", exp.Format(time.RFC3339))
|
||||
}
|
||||
}
|
||||
|
||||
// Start server in a goroutine
|
||||
go func() {
|
||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatalf("Server error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Println("Backend started on", addr)
|
||||
for _, s := range servers {
|
||||
go func(s *http.Server) {
|
||||
if err := servetls.ListenAndServe(s); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatalf("Server error: %v", err)
|
||||
}
|
||||
}(s)
|
||||
log.Println("Backend started on", s.Addr)
|
||||
}
|
||||
|
||||
// Wait for interrupt signal for graceful shutdown
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
@@ -2723,8 +2743,10 @@ func main() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
if err := srv.Shutdown(shutdownCtx); err != nil {
|
||||
log.Printf("Server shutdown error: %v", err)
|
||||
for _, s := range servers {
|
||||
if err := s.Shutdown(shutdownCtx); err != nil {
|
||||
log.Printf("Server shutdown error: %v", err)
|
||||
}
|
||||
}
|
||||
drained.Wait()
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/pkg/generation"
|
||||
"github.com/warmbly/warmbly/internal/pkg/geo"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeagent"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
"github.com/warmbly/warmbly/internal/pkg/typesafe"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
"github.com/warmbly/warmbly/internal/tasks"
|
||||
@@ -543,6 +544,7 @@ func main() {
|
||||
}
|
||||
|
||||
jobsService := &jobs.JobsService{
|
||||
CampaignIsolationEnabled: config.CampaignSendIsolationEnabled(),
|
||||
Bus: consumerBus,
|
||||
Codec: consumerCodec,
|
||||
UniboxRepository: uniboxRepo,
|
||||
@@ -767,6 +769,7 @@ func newConsumerAgent() *nodeagent.Agent {
|
||||
Version: os.Getenv("WARMBLY_VERSION"),
|
||||
BaseURL: consumerBackendURL(),
|
||||
Token: config.NodeAPIToken(),
|
||||
Credential: nodeauth.FromEnv().Credential,
|
||||
TargetVersionPath: os.Getenv("WARMBLY_TARGET_VERSION_PATH"),
|
||||
})
|
||||
}
|
||||
|
||||
+29
-7
@@ -8,6 +8,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/formserver"
|
||||
"github.com/warmbly/warmbly/internal/observability"
|
||||
"github.com/warmbly/warmbly/internal/observability/errs"
|
||||
"github.com/warmbly/warmbly/internal/pkg/servetls"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -37,6 +39,11 @@ func main() {
|
||||
log.Fatal("INTERNAL_API_TOKEN is required (must match the backend's)")
|
||||
}
|
||||
|
||||
backendRoots, err := servetls.ClientRoots(strings.TrimSpace(os.Getenv("BACKEND_INTERNAL_CA")), strings.TrimSpace(os.Getenv("BACKEND_INTERNAL_CA_FILE")))
|
||||
if err != nil {
|
||||
log.Fatalf("invalid BACKEND_INTERNAL_CA or BACKEND_INTERNAL_CA_FILE: %v", err)
|
||||
}
|
||||
|
||||
submitLimit := 0
|
||||
if v := os.Getenv("FORM_IP_RATE_LIMIT"); v != "" {
|
||||
parsed, err := strconv.Atoi(v)
|
||||
@@ -56,6 +63,7 @@ func main() {
|
||||
srv, err := formserver.New(formserver.Config{
|
||||
BackendURL: backendURL,
|
||||
InternalToken: token,
|
||||
BackendRoots: backendRoots,
|
||||
StaticDir: staticDir,
|
||||
SubmitLimit: submitLimit,
|
||||
// The browser half of analytics and error reporting, separate from
|
||||
@@ -82,14 +90,28 @@ func main() {
|
||||
if port == "" {
|
||||
port = "8090"
|
||||
}
|
||||
log.Printf("forms service listening on :%s (backend %s)", port, backendURL)
|
||||
if err := r.Run(":" + port); err != nil {
|
||||
// The listener dying is the one failure here worth reporting: the
|
||||
// boot-time checks above are operator configuration, not a bug.
|
||||
errs.CaptureException(err)
|
||||
errs.Flush(2 * time.Second)
|
||||
log.Fatal(err)
|
||||
tlsListen, err := servetls.FromEnv(os.Getenv)
|
||||
if err != nil {
|
||||
log.Fatalf("invalid TLS listener setting: %v", err)
|
||||
}
|
||||
plain, secure, err := tlsListen.Servers(":"+port, r)
|
||||
if err != nil {
|
||||
log.Fatalf("TLS listener: %v", err)
|
||||
}
|
||||
failed := make(chan error, 2)
|
||||
for _, s := range []*http.Server{plain, secure} {
|
||||
if s == nil {
|
||||
continue
|
||||
}
|
||||
log.Printf("forms service listening on %s (backend %s)", s.Addr, backendURL)
|
||||
go func(s *http.Server) { failed <- servetls.ListenAndServe(s) }(s)
|
||||
}
|
||||
// The listener dying is the one failure here worth reporting: the
|
||||
// boot-time checks above are operator configuration, not a bug.
|
||||
err = <-failed
|
||||
errs.CaptureException(err)
|
||||
errs.Flush(2 * time.Second)
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// browserPostHogErrorTracking is the WARMBLY_POSTHOG_ERROR_TRACKING switch the
|
||||
|
||||
@@ -47,6 +47,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/infrastructure/db"
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/pkg/argon2"
|
||||
"github.com/warmbly/warmbly/internal/pkg/crypt"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
"github.com/warmbly/warmbly/internal/seed"
|
||||
)
|
||||
@@ -153,6 +154,11 @@ func seedBaseline(ctx context.Context, pool *pgxpool.Pool) error {
|
||||
if err := upsertWorker(ctx, pool, workerShared, "worker-1", "10.0.0.11", "", true); err != nil {
|
||||
return fmt.Errorf("dev worker: %w", err)
|
||||
}
|
||||
// Its own node credential, so `make worker` also runs with NODE_REQUIRE_NODE_CREDENTIAL=true.
|
||||
if _, err := pool.Exec(ctx, `UPDATE fleet_nodes SET credential_hash = $2, updated_at = now() WHERE id = $1`,
|
||||
workerShared, crypt.SHA256(seed.DevNodeCredential)); err != nil {
|
||||
return fmt.Errorf("dev worker credential: %w", err)
|
||||
}
|
||||
|
||||
// Connect two email accounts on the dev org. Without these a fresh
|
||||
// stack has no mailboxes to test campaigns or warmup against, which
|
||||
|
||||
@@ -18,6 +18,7 @@ var remoteAdminRoutes = []remoteAdminRoute{
|
||||
{"POST", "/admin/testers", []string{"ManageTesters"}, false, "Credential issuance is intentionally not exposed through diagnostic output"},
|
||||
{"POST", "/admin/organizations/:id/sample-data", []string{"ManageTesters"}, false, ""},
|
||||
{"DELETE", "/admin/testers/:id", []string{"ManageTesters"}, false, ""},
|
||||
{"POST", "/admin/testers/:id/password", []string{"ManageTesters"}, true, "Credential issuance is intentionally not exposed through diagnostic output"},
|
||||
{"PUT", "/admin/users/:id/login-code-exempt", []string{"ManageTesters"}, true, ""},
|
||||
{"POST", "/admin/users/:id/ban", []string{"BanUsers"}, false, ""},
|
||||
{"POST", "/admin/users/:id/unban", []string{"BanUsers"}, false, ""},
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/observability"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeagent"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
)
|
||||
|
||||
@@ -259,6 +260,7 @@ func newNodeAgent(workerID uuid.UUID, bindIP string) *nodeagent.Agent {
|
||||
Version: buildVersion(),
|
||||
BaseURL: os.Getenv("ENCRYPTED_KEYS_BACKEND_URL"),
|
||||
Token: config.NodeAPIToken(),
|
||||
Credential: nodeauth.FromEnv().Credential,
|
||||
// Written for the host-side updater installed by `warmbly join`.
|
||||
TargetVersionPath: os.Getenv("WARMBLY_TARGET_VERSION_PATH"),
|
||||
Condition: wsmtp.EgressCondition,
|
||||
|
||||
@@ -86,6 +86,7 @@ USER warmbly
|
||||
EXPOSE 8080
|
||||
|
||||
# 127.0.0.1, not localhost: busybox wget tries ::1 first but the server binds IPv4.
|
||||
# SERVE_TLS adds a TLS listener and keeps this plain one, on loopback at least.
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
||||
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/health || exit 1
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ USER warmbly
|
||||
EXPOSE 8090
|
||||
|
||||
# 127.0.0.1, not localhost: busybox wget tries ::1 first but the server binds IPv4.
|
||||
# SERVE_TLS adds a TLS listener and keeps this plain one, on loopback at least.
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
||||
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8090/health || exit 1
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ ARG COMMIT=""
|
||||
ENV WARMBLY_RELEASE=${VERSION:-${COMMIT}}
|
||||
|
||||
# 127.0.0.1, not localhost: busybox wget tries ::1 first but the server binds IPv4.
|
||||
# SERVE_TLS adds a TLS listener and keeps this plain one, on loopback at least.
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
|
||||
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:4000/health || exit 1
|
||||
|
||||
|
||||
@@ -68,6 +68,19 @@ earlier revisions remain active for rollback. Retain their referenced images and
|
||||
secret versions throughout the rollback window; retire them separately after it
|
||||
closes.
|
||||
|
||||
## TLS behind the load balancer
|
||||
|
||||
`target_tls` moves the load balancer's target groups and the forms and tracking
|
||||
services' internal calls to the backend onto TLS, in six stages (`off`,
|
||||
`serve`, `both`, `route`, `drain`, `on`) advanced one apply at a time. Route keeps
|
||||
the healthy HTTP path while HTTPS bakes; drain removes references and waits for
|
||||
registrations to empty before a separately approved cleanup. The backend serves the
|
||||
certificate in `backend_internal_certificate` with `SERVE_TLS_KEY` from its
|
||||
secret, and its callers trust only that certificate. Prerequisites, the stages
|
||||
and what each one changes are in `aws-fargate.mdx` under "Encrypt traffic inside
|
||||
the VPC". `terraform test` in this directory exercises every stage against a
|
||||
mocked provider.
|
||||
|
||||
## Rotate keys
|
||||
|
||||
`rotation.tf` registers a rotator task that generates replacement values with
|
||||
|
||||
@@ -75,7 +75,7 @@ variable "services" {
|
||||
service.desired_count >= 0 && service.desired_count == floor(service.desired_count) &&
|
||||
!contains(service.secret_keys, "AWS_ACCESS_KEY_ID") && !contains(service.secret_keys, "AWS_SECRET_ACCESS_KEY") &&
|
||||
alltrue([for key, value in service.environment :
|
||||
!can(regex("(?i)(passwords?|secrets?|tokens?|private_keys?|access_keys?|master_keys?|encryption_keys?|read_keys|primary_db(_direct)?|database_url|redis_url)$", key)) &&
|
||||
!can(regex("(?i)(passwords?|secrets?|tokens?|private_keys?|access_keys?|master_keys?|encryption_keys?|tls_keys?|read_keys|primary_db(_direct)?|database_url|redis_url)$", key)) &&
|
||||
!can(regex("://[^/@]+:[^/@]+@", value))
|
||||
])
|
||||
])
|
||||
@@ -83,6 +83,34 @@ variable "services" {
|
||||
}
|
||||
}
|
||||
|
||||
variable "target_tls" {
|
||||
description = "Stage of the move to TLS behind the load balancer: off, serve, both, route, drain, on. Advance one stage per apply and let each redeploy finish"
|
||||
type = string
|
||||
default = "off"
|
||||
validation {
|
||||
condition = contains(["off", "serve", "both", "route", "drain", "on"], var.target_tls)
|
||||
error_message = "target_tls is off, serve, both, route, drain or on."
|
||||
}
|
||||
}
|
||||
variable "target_tls_port" {
|
||||
description = "Port every load-balanced task serves TLS on"
|
||||
type = number
|
||||
default = 8443
|
||||
validation {
|
||||
condition = var.target_tls_port >= 1024 && var.target_tls_port <= 65535 && floor(var.target_tls_port) == var.target_tls_port && alltrue([for service in var.services : service.port != var.target_tls_port])
|
||||
error_message = "target_tls_port is an unprivileged port no service already listens on."
|
||||
}
|
||||
}
|
||||
variable "backend_internal_certificate" {
|
||||
description = "PEM certificate the backend presents on its TLS port, naming backend.<namespace>; its key is SERVE_TLS_KEY in the backend secret"
|
||||
type = string
|
||||
default = null
|
||||
validation {
|
||||
condition = var.backend_internal_certificate == null || can(regex("^-----BEGIN CERTIFICATE-----", trimspace(var.backend_internal_certificate)))
|
||||
error_message = "backend_internal_certificate is one PEM certificate."
|
||||
}
|
||||
}
|
||||
|
||||
data "terraform_remote_state" "foundation" {
|
||||
backend = "s3"
|
||||
config = {
|
||||
@@ -98,8 +126,30 @@ locals {
|
||||
public_services = {
|
||||
for name, service in var.services : name => service if service.port != null && service.host != null
|
||||
}
|
||||
# Each stage keeps the previous one's listeners, so a rolling deploy never meets a task that cannot answer.
|
||||
tls_serving = var.target_tls != "off"
|
||||
http_targets = var.target_tls != "on"
|
||||
tls_targets = contains(["both", "route", "drain", "on"], var.target_tls)
|
||||
tls_services = {
|
||||
for name, service in var.services : name => service if service.port != null && (contains(keys(local.public_services), name) || name == "backend")
|
||||
}
|
||||
backend_internal_url = local.tls_targets ? "https://backend.${var.namespace}:${var.target_tls_port}" : "http://backend.${var.namespace}:8080"
|
||||
tls_environment = {
|
||||
for name, service in var.services : name => merge(
|
||||
local.tls_serving && contains(keys(local.tls_services), name) ? {
|
||||
SERVE_TLS = name == "backend" ? "supplied" : "self-signed"
|
||||
SERVE_TLS_PORT = tostring(var.target_tls_port)
|
||||
} : {},
|
||||
local.tls_serving && name == "backend" ? { SERVE_TLS_CERT = var.backend_internal_certificate } : {},
|
||||
var.target_tls == "on" && contains(keys(local.tls_services), name) ? { SERVE_HTTP_LOOPBACK_ONLY = "true" } : {},
|
||||
local.tls_targets && contains(["forms", "tracking"], name) ? {
|
||||
BACKEND_INTERNAL_URL = local.backend_internal_url
|
||||
BACKEND_INTERNAL_CA = var.backend_internal_certificate
|
||||
} : {},
|
||||
)
|
||||
}
|
||||
service_environment = {
|
||||
for name, service in var.services : name => merge(service.environment, name == "backend" ? { DB_MIGRATIONS_ON_START = "false" } : {})
|
||||
for name, service in var.services : name => merge(service.environment, name == "backend" ? { DB_MIGRATIONS_ON_START = "false" } : {}, local.tls_environment[name])
|
||||
}
|
||||
parameter_secrets = {
|
||||
for name, service in var.services : name => [
|
||||
@@ -204,20 +254,41 @@ resource "aws_vpc_security_group_egress_rule" "ingress" {
|
||||
to_port = 65535
|
||||
}
|
||||
resource "aws_vpc_security_group_ingress_rule" "service" {
|
||||
for_each = local.public_services
|
||||
for_each = local.http_targets ? local.public_services : {}
|
||||
security_group_id = local.foundation.tasks_sg_id
|
||||
referenced_security_group_id = aws_security_group.ingress.id
|
||||
ip_protocol = "tcp"
|
||||
from_port = each.value.port
|
||||
to_port = each.value.port
|
||||
}
|
||||
resource "aws_vpc_security_group_ingress_rule" "service_tls" {
|
||||
count = local.tls_serving && length(local.public_services) > 0 ? 1 : 0
|
||||
security_group_id = local.foundation.tasks_sg_id
|
||||
referenced_security_group_id = aws_security_group.ingress.id
|
||||
ip_protocol = "tcp"
|
||||
from_port = var.target_tls_port
|
||||
to_port = var.target_tls_port
|
||||
}
|
||||
moved {
|
||||
from = aws_vpc_security_group_ingress_rule.internal_backend
|
||||
to = aws_vpc_security_group_ingress_rule.internal_backend[0]
|
||||
}
|
||||
resource "aws_vpc_security_group_ingress_rule" "internal_backend" {
|
||||
count = local.http_targets ? 1 : 0
|
||||
security_group_id = local.foundation.tasks_sg_id
|
||||
referenced_security_group_id = local.foundation.tasks_sg_id
|
||||
ip_protocol = "tcp"
|
||||
from_port = 8080
|
||||
to_port = 8080
|
||||
}
|
||||
resource "aws_vpc_security_group_ingress_rule" "internal_backend_tls" {
|
||||
count = local.tls_serving ? 1 : 0
|
||||
security_group_id = local.foundation.tasks_sg_id
|
||||
referenced_security_group_id = local.foundation.tasks_sg_id
|
||||
ip_protocol = "tcp"
|
||||
from_port = var.target_tls_port
|
||||
to_port = var.target_tls_port
|
||||
}
|
||||
resource "aws_lb" "main" {
|
||||
name = "${var.name}-ingress"
|
||||
load_balancer_type = "application"
|
||||
@@ -228,7 +299,7 @@ resource "aws_lb" "main" {
|
||||
drop_invalid_header_fields = true
|
||||
}
|
||||
resource "aws_lb_target_group" "service" {
|
||||
for_each = local.public_services
|
||||
for_each = local.http_targets ? local.public_services : {}
|
||||
name = "${var.name}-${each.key}"
|
||||
port = each.value.port
|
||||
protocol = "HTTP"
|
||||
@@ -244,6 +315,35 @@ resource "aws_lb_target_group" "service" {
|
||||
unhealthy_threshold = 3
|
||||
}
|
||||
}
|
||||
# A separate group per protocol, so traffic moves between two populated groups and never to an empty one.
|
||||
resource "aws_lb_target_group" "service_tls" {
|
||||
for_each = local.tls_targets ? local.public_services : {}
|
||||
name = "${var.name}-${each.key}-tls"
|
||||
port = var.target_tls_port
|
||||
protocol = "HTTPS"
|
||||
target_type = "ip"
|
||||
vpc_id = local.foundation.vpc_id
|
||||
deregistration_delay = 60
|
||||
health_check {
|
||||
protocol = "HTTPS"
|
||||
path = each.value.health_path
|
||||
matcher = "200"
|
||||
interval = 30
|
||||
timeout = 5
|
||||
healthy_threshold = 2
|
||||
unhealthy_threshold = 3
|
||||
}
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = length("${var.name}-${each.key}-tls") <= 32
|
||||
error_message = "Target group names are at most 32 characters; shorten name."
|
||||
}
|
||||
}
|
||||
}
|
||||
locals {
|
||||
# The group the listener sends traffic to; in both, the TLS group is attached at weight 0 while it fills.
|
||||
serving_target_groups = contains(["route", "drain", "on"], var.target_tls) ? aws_lb_target_group.service_tls : aws_lb_target_group.service
|
||||
}
|
||||
resource "aws_lb_listener" "https" {
|
||||
load_balancer_arn = aws_lb.main.arn
|
||||
port = 443
|
||||
@@ -273,8 +373,23 @@ resource "aws_lb_listener_rule" "service" {
|
||||
}
|
||||
action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.service[each.key].arn
|
||||
target_group_arn = contains(["both", "route"], var.target_tls) ? null : local.serving_target_groups[each.key].arn
|
||||
dynamic "forward" {
|
||||
for_each = contains(["both", "route"], var.target_tls) ? [each.key] : []
|
||||
content {
|
||||
target_group {
|
||||
arn = aws_lb_target_group.service[forward.value].arn
|
||||
weight = var.target_tls == "both" ? 1 : 0
|
||||
}
|
||||
target_group {
|
||||
arn = aws_lb_target_group.service_tls[forward.value].arn
|
||||
weight = var.target_tls == "route" ? 1 : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# A port's security group rule is removed only after no rule forwards to it.
|
||||
depends_on = [aws_vpc_security_group_ingress_rule.service, aws_vpc_security_group_ingress_rule.service_tls]
|
||||
}
|
||||
|
||||
resource "aws_service_discovery_private_dns_namespace" "main" {
|
||||
@@ -319,7 +434,7 @@ locals {
|
||||
}
|
||||
}
|
||||
}, jsondecode(service.port == null ? "{}" : jsonencode({
|
||||
portMappings = [{ containerPort = service.port, protocol = "tcp" }]
|
||||
portMappings = concat([{ containerPort = service.port, protocol = "tcp" }], local.tls_serving && contains(keys(local.tls_services), name) ? [{ containerPort = var.target_tls_port, protocol = "tcp" }] : [])
|
||||
healthCheck = {
|
||||
command = ["CMD-SHELL", "wget -q --spider http://127.0.0.1:${service.port}${service.health_path} || exit 1"]
|
||||
interval = 30
|
||||
@@ -348,6 +463,16 @@ resource "aws_ecs_task_definition" "service" {
|
||||
container_definitions = jsonencode([local.service_containers[each.key]])
|
||||
tags = { "warmbly-image-variant" = each.value.image_variant }
|
||||
depends_on = [aws_iam_role_policy.execution, aws_iam_role_policy.application]
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = each.key != "backend" || !local.tls_serving || (var.backend_internal_certificate != null && contains(each.value.secret_keys, "SERVE_TLS_KEY"))
|
||||
error_message = "target_tls needs backend_internal_certificate and SERVE_TLS_KEY in the backend secret_keys."
|
||||
}
|
||||
precondition {
|
||||
condition = !local.tls_serving || length(setintersection(each.value.secret_keys, ["BACKEND_INTERNAL_URL", "BACKEND_INTERNAL_CA", "SERVE_TLS", "SERVE_TLS_PORT", "SERVE_TLS_CERT"])) == 0
|
||||
error_message = "target_tls sets BACKEND_INTERNAL_URL, BACKEND_INTERNAL_CA and the SERVE_TLS settings itself; remove them from secret_keys."
|
||||
}
|
||||
}
|
||||
}
|
||||
resource "aws_ecs_service" "service" {
|
||||
for_each = var.services
|
||||
@@ -360,8 +485,10 @@ resource "aws_ecs_service" "service" {
|
||||
deployment_minimum_healthy_percent = 100
|
||||
deployment_maximum_percent = 200
|
||||
health_check_grace_period_seconds = contains(keys(local.public_services), each.key) ? 120 : null
|
||||
enable_ecs_managed_tags = true
|
||||
propagate_tags = "SERVICE"
|
||||
# A target group change finishes rolling before the next resource relies on it.
|
||||
wait_for_steady_state = local.tls_targets
|
||||
enable_ecs_managed_tags = true
|
||||
propagate_tags = "SERVICE"
|
||||
lifecycle {
|
||||
ignore_changes = [task_definition, desired_count]
|
||||
}
|
||||
@@ -383,13 +510,21 @@ resource "aws_ecs_service" "service" {
|
||||
assign_public_ip = true
|
||||
}
|
||||
dynamic "load_balancer" {
|
||||
for_each = contains(keys(local.public_services), each.key) ? [each.value.port] : []
|
||||
for_each = contains(keys(local.public_services), each.key) && local.http_targets && var.target_tls != "drain" ? [each.value.port] : []
|
||||
content {
|
||||
target_group_arn = aws_lb_target_group.service[each.key].arn
|
||||
container_name = each.key
|
||||
container_port = load_balancer.value
|
||||
}
|
||||
}
|
||||
dynamic "load_balancer" {
|
||||
for_each = contains(keys(local.public_services), each.key) && local.tls_targets ? [var.target_tls_port] : []
|
||||
content {
|
||||
target_group_arn = aws_lb_target_group.service_tls[each.key].arn
|
||||
container_name = each.key
|
||||
container_port = load_balancer.value
|
||||
}
|
||||
}
|
||||
dynamic "service_registries" {
|
||||
for_each = each.key == "backend" ? [1] : []
|
||||
content { registry_arn = aws_service_discovery_service.backend.arn }
|
||||
@@ -420,7 +555,7 @@ resource "aws_cloudwatch_metric_alarm" "target_5xx" {
|
||||
metric_name = "HTTPCode_Target_5XX_Count"
|
||||
period = 60
|
||||
stat = "Sum"
|
||||
dimensions = { LoadBalancer = aws_lb.main.arn_suffix, TargetGroup = aws_lb_target_group.service[each.key].arn_suffix }
|
||||
dimensions = { LoadBalancer = aws_lb.main.arn_suffix, TargetGroup = local.serving_target_groups[each.key].arn_suffix }
|
||||
}
|
||||
}
|
||||
metric_query {
|
||||
@@ -430,7 +565,7 @@ resource "aws_cloudwatch_metric_alarm" "target_5xx" {
|
||||
metric_name = "RequestCount"
|
||||
period = 60
|
||||
stat = "Sum"
|
||||
dimensions = { LoadBalancer = aws_lb.main.arn_suffix, TargetGroup = aws_lb_target_group.service[each.key].arn_suffix }
|
||||
dimensions = { LoadBalancer = aws_lb.main.arn_suffix, TargetGroup = local.serving_target_groups[each.key].arn_suffix }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,7 +575,7 @@ resource "aws_cloudwatch_metric_alarm" "unhealthy_hosts" {
|
||||
alarm_description = "A ${each.key} target has failed its load balancer health check for three minutes"
|
||||
namespace = "AWS/ApplicationELB"
|
||||
metric_name = "UnHealthyHostCount"
|
||||
dimensions = { LoadBalancer = aws_lb.main.arn_suffix, TargetGroup = aws_lb_target_group.service[each.key].arn_suffix }
|
||||
dimensions = { LoadBalancer = aws_lb.main.arn_suffix, TargetGroup = local.serving_target_groups[each.key].arn_suffix }
|
||||
statistic = "Maximum"
|
||||
period = 60
|
||||
evaluation_periods = 3
|
||||
@@ -454,10 +589,10 @@ output "runtime" {
|
||||
cluster_arn = local.foundation.cluster_arn
|
||||
load_balancer_dns = aws_lb.main.dns_name
|
||||
load_balancer_arn = aws_lb.main.arn
|
||||
target_group_arns = { for name, group in aws_lb_target_group.service : name => group.arn }
|
||||
target_group_arns = { for name, group in local.serving_target_groups : name => group.arn }
|
||||
task_definitions = { for name, task in aws_ecs_task_definition.service : name => task.arn }
|
||||
task_roles = { for name, role in aws_iam_role.application : name => role.arn }
|
||||
execution_roles = { for name, role in aws_iam_role.execution : name => role.arn }
|
||||
backend_internal = "http://backend.${var.namespace}:8080"
|
||||
backend_internal = local.backend_internal_url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
mock_provider "aws" {
|
||||
mock_data "aws_iam_policy_document" {
|
||||
defaults = { json = "{}" }
|
||||
}
|
||||
mock_resource "aws_iam_role" {
|
||||
defaults = { arn = "arn:aws:iam::123456789012:role/mock" }
|
||||
}
|
||||
mock_resource "aws_lb" {
|
||||
defaults = { arn = "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/mock/1", arn_suffix = "app/mock/1" }
|
||||
}
|
||||
mock_resource "aws_lb_listener" {
|
||||
defaults = { arn = "arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/mock/1/1" }
|
||||
}
|
||||
mock_resource "aws_lb_target_group" {
|
||||
defaults = { arn = "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/mock/1", arn_suffix = "targetgroup/mock/1" }
|
||||
}
|
||||
mock_resource "aws_ecs_task_definition" {
|
||||
defaults = { arn = "arn:aws:ecs:us-east-1:123456789012:task-definition/mock:1" }
|
||||
}
|
||||
mock_resource "aws_service_discovery_service" {
|
||||
defaults = { arn = "arn:aws:servicediscovery:us-east-1:123456789012:service/srv-1" }
|
||||
}
|
||||
mock_resource "aws_cloudwatch_log_group" {
|
||||
defaults = { arn = "arn:aws:logs:us-east-1:123456789012:log-group:mock" }
|
||||
}
|
||||
mock_data "aws_caller_identity" {
|
||||
defaults = { account_id = "123456789012" }
|
||||
}
|
||||
}
|
||||
|
||||
override_resource {
|
||||
target = aws_lb_target_group.service["tracking"]
|
||||
values = {
|
||||
arn = "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/http/1"
|
||||
arn_suffix = "targetgroup/http/1"
|
||||
}
|
||||
}
|
||||
|
||||
override_data {
|
||||
target = data.terraform_remote_state.foundation
|
||||
values = {
|
||||
outputs = {
|
||||
runtime = {
|
||||
vpc_id = "vpc-1"
|
||||
tasks_sg_id = "sg-tasks"
|
||||
public_subnet_ids = ["subnet-1"]
|
||||
cluster_arn = "arn:aws:ecs:us-east-1:123456789012:cluster/warmbly-production"
|
||||
rotation_secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:rotation"
|
||||
certificate_arns = { "warmbly.com" = "arn:aws:acm:us-east-1:123456789012:certificate/1" }
|
||||
secret_arns = { for name in ["backend", "consumer", "forms", "realtime", "tracking"] : name => "arn:aws:secretsmanager:us-east-1:123456789012:secret:${name}" }
|
||||
repository_urls = { for name in ["backend", "consumer", "forms", "realtime", "tracking"] : name => "123456789012.dkr.ecr.us-east-1.amazonaws.com/warmbly/${name}" }
|
||||
}
|
||||
configuration_parameter_arns = {
|
||||
"backend/KAFKA_BOOTSTRAP_SERVERS" = "arn:aws:ssm:us-east-1:123456789012:parameter/a"
|
||||
"backend/SCHEMA_REGISTRY_URL" = "arn:aws:ssm:us-east-1:123456789012:parameter/b"
|
||||
"backend/BLOB_BUCKET" = "arn:aws:ssm:us-east-1:123456789012:parameter/c"
|
||||
}
|
||||
cache = { credential_secret = "arn:aws:secretsmanager:us-east-1:123456789012:secret:cache", endpoint = "cache" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variables {
|
||||
state_bucket = "state"
|
||||
certificate_primary_domain = "warmbly.com"
|
||||
origin_ipv4_cidrs = ["173.245.48.0/20"]
|
||||
tracking_additional_hosts = ["link.example.com"]
|
||||
backend_internal_certificate = "-----BEGIN CERTIFICATE-----\nMIIB\n-----END CERTIFICATE-----\n"
|
||||
services = {
|
||||
backend = { image = "r/backend@sha256:0000000000000000000000000000000000000000000000000000000000000000", cpu = 256, memory = 512, port = 8080, host = "api.warmbly.com", secret_version_id = "v", secret_keys = ["SERVE_TLS_KEY"] }
|
||||
consumer = { image = "r/consumer@sha256:0000000000000000000000000000000000000000000000000000000000000000", cpu = 256, memory = 512, secret_version_id = "v", secret_keys = [] }
|
||||
tracking = { image = "r/tracking@sha256:0000000000000000000000000000000000000000000000000000000000000000", cpu = 256, memory = 512, port = 3000, host = "t.warmbly.com", secret_version_id = "v", secret_keys = [], environment = { BACKEND_INTERNAL_URL = "http://backend.warmbly.internal:8080" } }
|
||||
forms = { image = "r/forms@sha256:0000000000000000000000000000000000000000000000000000000000000000", cpu = 256, memory = 512, port = 8090, host = "f.warmbly.com", secret_version_id = "v", secret_keys = [] }
|
||||
realtime = { image = "r/realtime@sha256:0000000000000000000000000000000000000000000000000000000000000000", cpu = 256, memory = 512, port = 4000, host = "ws.warmbly.com", secret_version_id = "v", secret_keys = [] }
|
||||
}
|
||||
}
|
||||
|
||||
run "off_is_unchanged" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "off"
|
||||
}
|
||||
assert {
|
||||
condition = aws_lb_target_group.service["backend"].protocol == "HTTP" && length(aws_lb_target_group.service_tls) == 0
|
||||
error_message = "off keeps the HTTP target groups only"
|
||||
}
|
||||
assert {
|
||||
condition = !strcontains(aws_ecs_task_definition.service["backend"].container_definitions, "\"SERVE_TLS\"")
|
||||
error_message = "off sets no TLS listener"
|
||||
}
|
||||
assert {
|
||||
condition = strcontains(aws_ecs_task_definition.service["tracking"].container_definitions, "http://backend.warmbly.internal:8080")
|
||||
error_message = "off leaves the internal hop as configured"
|
||||
}
|
||||
}
|
||||
|
||||
run "serve_adds_listeners_only" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "serve"
|
||||
}
|
||||
assert {
|
||||
condition = strcontains(aws_ecs_task_definition.service["backend"].container_definitions, "\"supplied\"") && strcontains(aws_ecs_task_definition.service["tracking"].container_definitions, "\"self-signed\"")
|
||||
error_message = "serve turns the TLS listeners on"
|
||||
}
|
||||
assert {
|
||||
condition = strcontains(aws_ecs_task_definition.service["tracking"].container_definitions, "http://backend.warmbly.internal:8080")
|
||||
error_message = "serve leaves callers on the plain hop"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_lb_target_group.service_tls) == 0 && aws_lb_listener_rule.service["tracking"].action[0].target_group_arn != null
|
||||
error_message = "serve does not touch load balancing"
|
||||
}
|
||||
}
|
||||
|
||||
run "both_attaches_the_tls_group_at_weight_zero" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "both"
|
||||
}
|
||||
assert {
|
||||
condition = aws_lb_target_group.service_tls["tracking"].protocol == "HTTPS" && aws_lb_target_group.service_tls["tracking"].health_check[0].protocol == "HTTPS"
|
||||
error_message = "both creates HTTPS target groups with HTTPS health checks"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_ecs_service.service["tracking"].load_balancer) == 2
|
||||
error_message = "both registers tasks in both groups"
|
||||
}
|
||||
assert {
|
||||
condition = [for group in aws_lb_listener_rule.service["tracking"].action[0].forward[0].target_group : group.weight] == [1, 0] || [for group in aws_lb_listener_rule.service["tracking"].action[0].forward[0].target_group : group.weight] == [0, 1]
|
||||
error_message = "both keeps the TLS group attached with no traffic"
|
||||
}
|
||||
assert {
|
||||
condition = strcontains(aws_ecs_task_definition.service["tracking"].container_definitions, "https://backend.warmbly.internal:8443")
|
||||
error_message = "both moves the internal hop to TLS"
|
||||
}
|
||||
}
|
||||
|
||||
run "route_preserves_healthy_http_fallback" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "route"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_lb_target_group.service) == 4 && length(aws_vpc_security_group_ingress_rule.service) == 4 && length(aws_vpc_security_group_ingress_rule.internal_backend) == 1
|
||||
error_message = "route retains every HTTP target group and network rule"
|
||||
}
|
||||
assert {
|
||||
condition = alltrue([for service in aws_ecs_service.service : length(service.load_balancer) == 0 || length(service.load_balancer) == 2])
|
||||
error_message = "route keeps both target registrations ready"
|
||||
}
|
||||
assert {
|
||||
condition = alltrue([for group in aws_lb_listener_rule.service["tracking"].action[0].forward[0].target_group : group.arn == aws_lb_target_group.service_tls["tracking"].arn ? group.weight == 1 : group.weight == 0])
|
||||
error_message = "route sends traffic to HTTPS only"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_lb_listener_rule.tracking_alias["0"].action[0].forward[0].target_group) == 2 && !strcontains(aws_ecs_task_definition.service["backend"].container_definitions, "SERVE_HTTP_LOOPBACK_ONLY")
|
||||
error_message = "aliases retain fallback and HTTP remains available during route bake"
|
||||
}
|
||||
}
|
||||
|
||||
run "route_can_return_to_healthy_http" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "both"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_ecs_service.service["tracking"].load_balancer) == 2 && alltrue([for group in aws_lb_listener_rule.service["tracking"].action[0].forward[0].target_group : group.arn == aws_lb_target_group.service["tracking"].arn ? group.weight == 1 : group.weight == 0])
|
||||
error_message = "returning to both routes to the retained HTTP registrations"
|
||||
}
|
||||
}
|
||||
|
||||
run "restore_route_before_drain" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "route"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_ecs_service.service["tracking"].load_balancer) == 2 && length(aws_lb_target_group.service) == 4
|
||||
error_message = "restoring route retains the HTTP fallback"
|
||||
}
|
||||
}
|
||||
|
||||
run "drain_removes_registrations_before_resources" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "drain"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_lb_target_group.service) == 4 && length(aws_vpc_security_group_ingress_rule.service) == 4 && length(aws_vpc_security_group_ingress_rule.internal_backend) == 1
|
||||
error_message = "drain retains HTTP resources until registrations have drained"
|
||||
}
|
||||
assert {
|
||||
condition = alltrue([for service in aws_ecs_service.service : length(service.load_balancer) == 0 || alltrue([for lb in service.load_balancer : lb.container_port == 8443])])
|
||||
error_message = "drain registers only HTTPS targets"
|
||||
}
|
||||
assert {
|
||||
condition = aws_lb_listener_rule.service["tracking"].action[0].target_group_arn == aws_lb_target_group.service_tls["tracking"].arn && aws_lb_listener_rule.tracking_alias["0"].action[0].target_group_arn == aws_lb_target_group.service_tls["tracking"].arn
|
||||
error_message = "primary and alias listeners have only HTTPS references before cleanup"
|
||||
}
|
||||
}
|
||||
|
||||
run "on_forwards_tls_and_drops_plain" {
|
||||
command = apply
|
||||
variables {
|
||||
target_tls = "on"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_lb_target_group.service) == 0 && length(aws_vpc_security_group_ingress_rule.service) == 0 && length(aws_vpc_security_group_ingress_rule.internal_backend) == 0
|
||||
error_message = "on removes the plain path"
|
||||
}
|
||||
assert {
|
||||
condition = length(aws_ecs_service.service["backend"].load_balancer) == 1 && strcontains(aws_ecs_task_definition.service["backend"].container_definitions, "SERVE_HTTP_LOOPBACK_ONLY")
|
||||
error_message = "on keeps only the TLS group and confines plain to loopback"
|
||||
}
|
||||
}
|
||||
|
||||
run "tls_needs_the_backend_key" {
|
||||
command = plan
|
||||
variables {
|
||||
target_tls = "serve"
|
||||
services = merge(var.services, {
|
||||
backend = { image = "r/backend@sha256:0000000000000000000000000000000000000000000000000000000000000000", cpu = 256, memory = 512, port = 8080, host = "api.warmbly.com", secret_version_id = "v", secret_keys = [] }
|
||||
})
|
||||
}
|
||||
expect_failures = [aws_ecs_task_definition.service]
|
||||
}
|
||||
@@ -21,6 +21,20 @@ resource "aws_lb_listener_rule" "tracking_alias" {
|
||||
}
|
||||
action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.service["tracking"].arn
|
||||
target_group_arn = contains(["both", "route"], var.target_tls) ? null : local.serving_target_groups["tracking"].arn
|
||||
dynamic "forward" {
|
||||
for_each = contains(["both", "route"], var.target_tls) ? ["tracking"] : []
|
||||
content {
|
||||
target_group {
|
||||
arn = aws_lb_target_group.service[forward.value].arn
|
||||
weight = var.target_tls == "both" ? 1 : 0
|
||||
}
|
||||
target_group {
|
||||
arn = aws_lb_target_group.service_tls[forward.value].arn
|
||||
weight = var.target_tls == "route" ? 1 : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depends_on = [aws_vpc_security_group_ingress_rule.service, aws_vpc_security_group_ingress_rule.service_tls]
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ All paths below are relative to the versioned base URL `https://api.warmbly.com/
|
||||
- `GET /analytics/dashboard` intersects campaign and folder filters with grants before returning `scope.campaign_count`.
|
||||
- `GET /campaigns/:id/logs` keeps pagination and campaign activity, but restricted responses use safe messages and explicitly selected metadata. Mailbox addresses, caps, cross-campaign sending state, warmup health and account IDs outside mailbox grants are removed. Tracking domains, raw provider errors, unknown fields and nested metadata are not exposed. Granting a campaign alone does not grant its senders.
|
||||
- `GET /auth/me` and `/unibox/overview` include only categories applied to messages in accessible mailboxes for restricted members. Unrestricted members keep the workspace category registry. Inbox access is mailbox-based: granting a shared mailbox exposes its conversations from other campaigns too.
|
||||
- `GET /unibox/overview` includes `drafts`, the distinct conversation count across mailbox drafts and visible pending inbox-agent replies, scoped to accessible mailboxes. Older servers omit this field; during rolling upgrades the dashboard uses their mailbox-only Drafts count until it is available.
|
||||
- `GET /unibox/thread/labels` checks for a message in the selected organization and effective mailbox allowlist before listing labels. Unknown, cross-workspace and inaccessible threads have the same `404`. An accessible thread with no labels returns an empty list.
|
||||
- `GET /emails` resolves a pagination cursor only inside the selected organization and effective mailbox allowlist. A cursor outside either boundary does not supply a timestamp for pagination.
|
||||
|
||||
@@ -562,7 +563,7 @@ These changes require the session to have confirmed the account holder within th
|
||||
| Start a checkout, open the billing portal, change or cancel the plan, buy AI credits or change AI spend controls | `POST /subscription/checkout`, `POST /subscription/portal`, `POST /subscription/change-plan`, `POST /subscription/cancel`, `POST /subscription/credits/checkout`, `PATCH /subscription/credits/settings`, `POST /pool-link/checkout`, `POST /subscription/offers/:planId/checkout` |
|
||||
| Reveal or rotate a signing secret | `POST /webhooks/:id/rotate-secret`, `GET /integrations/connections/:id/webhook-secret`, `POST /oauth/applications/:id/rotate-secret`, `GET /oauth/applications/:id/webhook-secret`, `POST /oauth/applications/:id/webhook-secret/rotate` |
|
||||
| Record, use or remove an admin grant over a whole domain | `POST /emails/grants/google/finish`, `POST /emails/grants/microsoft/finish`, `POST /emails/grants/:id/connect`, `DELETE /emails/grants/:id` |
|
||||
| Admin panel: issue a fleet join token, grant admin permissions, export or import any workspace | `POST /admin/fleet/join-token`, `POST /admin/admins/:userId/grant`, `POST /admin/organizations/:id/exports`, `POST /admin/organizations/:id/imports` |
|
||||
| Admin panel: issue a fleet join token, grant admin permissions, export or import any workspace, issue a tester a new password, change a login-code exemption | `POST /admin/fleet/join-token`, `POST /admin/admins/:userId/grant`, `POST /admin/organizations/:id/exports`, `POST /admin/organizations/:id/imports`, `POST /admin/testers/:id/password`, `PUT /admin/users/:id/login-code-exempt` |
|
||||
|
||||
Each either hands out a credential that outlives the session that created it, reveals a secret, changes who can get in, moves money, cannot be reversed by the person it was done to, or reaches a whole domain's mail. Without a confirmation they answer `403` with code `reauth_required`; confirm and retry. See [error codes](/api/error-codes/#confirmation-required).
|
||||
|
||||
@@ -608,10 +609,13 @@ Alongside them, `api_url` is this API's own public base (for a copyable example
|
||||
- `POST /auth/oidc/begin`, `GET /auth/oidc/callback` (generic OpenID Connect sign-in)
|
||||
- `POST /auth/google/begin`, `GET /auth/google/callback`, `POST /auth/apple/begin`, `POST /auth/apple/callback` (browser Sign in with Google and Sign in with Apple)
|
||||
- `POST /auth/sso/exchange` (swaps the single-use handoff code from any of those callbacks for the session; `POST /auth/oidc/exchange` is the older name for the same endpoint)
|
||||
- `POST /auth/sso/link` (completes a provider sign-in that resolved to an existing password account: takes that account's password, attaches the identity and returns the session)
|
||||
- `POST /auth/sso/link` (completes a provider sign-in that resolved to an existing password account: takes that account's password, attaches the identity and returns the session. An issued initial password is refused here with `password_change_required`)
|
||||
- `POST /auth/login/initial-password` (answers a `/auth/login` result with `password_change_required`: takes its single-use `pending_token` and the holder's own password, replaces the issued initial password, signs out other sessions and continues the sign-in in the `/auth/login` response shape. Retrying is safe: the token is spent once, and a repeat answers `password_change_expired`)
|
||||
- `POST /auth/logout`, `POST /auth/logout-all`, `GET /auth/me`, `PATCH /auth/me/onboarding`
|
||||
- `PUT /auth/me/product-tour` (records that the signed-in user finished or skipped the dashboard's product tour, answering `product_tour_completed_at`, which `GET /auth/me` also carries. Naturally retry-safe: a repeat keeps the first time, so it takes no `Idempotency-Key`)
|
||||
- `POST /auth/me/avatar`, `DELETE /auth/me/avatar`
|
||||
- `GET /auth/me/identities`, `DELETE /auth/me/identities/:provider` (the Google, Apple and single sign-on identities linked to the signed-in user, and removing one. Removal requires a [fresh confirmation](/guides/security/), ends the other sessions that signed in through that provider, and is refused with `last_sign_in_method` when it would leave no way to sign in. No `Idempotency-Key`: a repeat converges and answers `204`)
|
||||
- `POST /auth/me/password/link` (emails the signed-in user a single-use link to set a password, on the same budget as `/auth/reset-password`. No `Idempotency-Key`: a repeat mails another link and spends the budget, which is the cap on retries)
|
||||
- `POST /emails/onboarding/oauth/start`, `POST /emails/onboarding/oauth/finish`, `POST /emails/onboarding/smtp-imap`. `oauth/start` accepts an optional `login_hint` (an email address) that preselects that mailbox in the provider's sign-in, which is how an import's **Sign in** rows open. For Google and Microsoft dashboard flows (`return: "web"`), the browser's `Origin` is validated against exact configured dashboard origins and bound to the OAuth state; an untrusted origin answers `400` `mailbox_oauth_return_origin`. Requests without an `Origin` retain primary-dashboard routing while their state is live
|
||||
- `POST /emails/onboarding/smtp-imap/bulk` (up to `50` SMTP/IMAP rows in `accounts`, answered `200` with a per-row `status` of `connected`, `skipped` or `failed` and a `code`; rows past the workspace's [mailbox allowance](/guides/mailboxes/#mailbox-allowance) fail with `mailbox_allowance_reached` before any credential is dialled. Naturally retry-safe: an already connected mailbox is `skipped`, so it takes no `Idempotency-Key`)
|
||||
- The [mailbox import](/guides/mailbox-import/) routes under `/emails/imports`, all with JWT permission `MANAGE_EMAILS`. They carry passwords, so like onboarding they never accept an API key:
|
||||
@@ -652,8 +656,9 @@ Alongside them, `api_url` is this API's own public base (for a copyable example
|
||||
- `POST /emails/domains/bulk`: `domains` (1 to 100), `tracking_label` (one DNS label, such as `link`; each domain gets `<label>.<domain>`) and/or `redirect_url`, plus optional `tracking_hosts` and `redirect_urls` objects keyed by domain that give a listed domain its own host or website in place of the shared one. Each domain takes its vendor's path when the vendor's API can (writing the `CNAME`, forwarding the root) and is saved to wait for DNS otherwise. Optional `served_by` (`instance` or `cloud`) picks where a redirect no vendor forwards is served from; omitted keeps each domain's current choice. Answers `data`, one row per domain with `tracking` (`host`, `via` of `vendor` or `dns`, `verified`, `mailboxes`, `cname_target`, `note` when the vendor refused the record) and `redirect` (`target_url`, `via` of `vendor`, `dns` or `cloud`, `verified`, `reviewed`); a refused domain carries `error` and `code` on its row and never stops the others. Safe to retry: each setting is set, not added
|
||||
- `GET /emails/domains/:domain/tracking-suggestion`: the tracking `host` to offer, its `status` (`active`, `found` or `suggested`), the `cname_target`, and `vendor_domain` when a connected vendor account holds the domain
|
||||
- `PUT /emails/domains/:domain/tracking`: `host` for every mailbox on the domain (empty clears it); answers the verification result and the number of `mailboxes` changed. Idempotent
|
||||
- `PUT /emails/domains/:domain/redirect`: `target_url`, optional `include_www` (default `true`) and optional `served_by` (`instance`, or `cloud` on a self-hosted instance [linked to Warmbly Cloud](/guides/sending-domains/#serve-it-from-warmbly-cloud); omitted keeps the current choice, and a new redirect is served by this instance). `target_url` must be on one of the workspace's own domains (`redirect_target_not_own_domain` otherwise; see [redirect destination refusals](/api/error-codes/#redirect-destination-refusals)). Checks it once and answers the redirect with its `records`, `served_by`, `serve_host` (the tracking host that answers, which a proxy routes the domain to) and, once DNS verifies, `reach`: the last visit to the domain, with `status` (`ok`, `not_reaching`, `https_error` or `unreachable`), `hint` (`not_routed`, `host_header`, `wrong_target`, `certificate`, `no_listener`, or `settling` while the tracking service picks up a redirect that has just verified), a `detail` sentence, the `proxy` that answered when it named itself, and `checked_at`. A redirect served by this instance or Cloud for it also carries `target_active`, `false` with a `target_inactive_reason` when the saved `target_url` is no longer on the workspace's own domains and the domain answers as if it had no redirect. Idempotent: a repeat keeps the same ownership value, so the `TXT` record stays valid
|
||||
- `POST /emails/domains/:domain/redirect/verify`: check DNS and visit the domain now; for a redirect Warmbly Cloud serves, Cloud checks and the answer is its verdict. Safe to repeat
|
||||
- `PUT /emails/domains/:domain/redirect`: `target_url`, optional `include_www` (default `true`) and optional `served_by` (`instance`, or `cloud` on a self-hosted instance [linked to Warmbly Cloud](/guides/sending-domains/#serve-it-from-warmbly-cloud); omitted keeps the current choice, and a new redirect is served by this instance). `target_url` must be on one of the workspace's own domains, a confirmed website included (`redirect_target_not_own_domain` otherwise; see [redirect destination refusals](/api/error-codes/#redirect-destination-refusals)). Checks it once and answers the redirect with its `records`, `served_by`, `serve_host` (the tracking host that answers, which a proxy routes the domain to) and, once DNS verifies, `reach`: the last visit to the domain, with `status` (`ok`, `not_reaching`, `https_error` or `unreachable`), `hint` (`not_routed`, `host_header`, `wrong_target`, `certificate`, `no_listener`, or `settling` while the tracking service picks up a redirect that has just verified), a `detail` sentence, the `proxy` that answered when it named itself, and `checked_at`. A redirect served by this instance or Cloud for it also carries `target_active`, `false` with a `target_inactive_reason` when the saved `target_url` is no longer on the workspace's own domains and the domain answers as if it had no redirect. When the destination is the workspace's only through a [confirmed website](/guides/sending-domains/#confirm-your-website), the redirect carries `website` with `domain`, `verified` and `record` (the `TXT` record to publish at the website's DNS); while it is not verified, `reach` is absent because the domain is not served. Idempotent: a repeat keeps the same ownership value, so the `TXT` record stays valid
|
||||
- `POST /emails/domains/:domain/redirect/verify`: check DNS and visit the domain now; for a redirect Warmbly Cloud serves, Cloud checks and the answer is its verdict. A destination's website is looked at too. Safe to repeat
|
||||
- `POST /emails/domains/:domain/redirect/website`: `target_url`. Looks for the workspace's `TXT` record on the destination's website now and answers `domain`, `verified` and, when the website is not already one of the workspace's mailbox, tracking or forms domains, `record` (`type`, `name`, `value`, `ok`). A found record confirms the website for the workspace. Safe to repeat
|
||||
- `DELETE /emails/domains/:domain/redirect`: stop serving it, on Warmbly Cloud too when Cloud serves it. A repeat is a `404`
|
||||
- `PUT /emails/domains/:domain/vendor-forwarding`: `url`; the vendor account holding the domain forwards its root there. An empty `url` removes the forwarding where `can_unforward`. Answers the updated `vendor_domain`. Idempotent
|
||||
- `POST /emails/domains/:domain/vendor-tracking`: `host`, a subdomain of the domain; the vendor writes its `CNAME` to this instance's tracking host, then every mailbox on the domain uses the host. Answers like `PUT .../tracking`. Safe to retry: the record is replaced, not added
|
||||
@@ -690,8 +695,9 @@ Alongside them, `api_url` is this API's own public base (for a copyable example
|
||||
- `GET /admin/organizations` and `GET /admin/organizations/:id` require `view_organizations`. Their acquisition fields include the nullable `referrer_host` saved at signup, alongside UTM source, medium, campaign and landing path. The list accepts an exact `referrer_host` filter as well as its existing acquisition filters. An absent source is unknown, not proof of a direct visit. See [signup source attribution](/guides/analytics/#signup-source-attribution-platform-admins).
|
||||
- `GET /admin/warmup-content/overview` includes effective generation controls and requires `view_warmup_pool`; `PUT /admin/warmup-content/settings` writes effective controls with `manage_settings`. These are platform-admin routes, not organization API-key scopes. See [effective generation policy and stopping](/development/warmup-generation/).
|
||||
- `POST /admin/organizations/:id/sample-data`: `manage_testers` and an MFA-verified admin session. Adds the [reviewer sample dataset](/development/accounts-and-access/#adding-sample-data) only to an active dedicated Test workspace. No request body. Returns `200` with `organization_id`, `created` (false when already seeded) and `seeded_at`; retries preserve edits and deletions. An ordinary workspace, revoked or expired tester, or missing/expired managed Test grant returns `400`. Inserts and the admin audit marker commit together. No mailbox connection, email delivery, external request or credit spend occurs.
|
||||
- `GET /admin/testers`: `view_users` and an MFA-verified admin session. Each tester in `data` may include `test_workspace_id` for its owned dedicated Test workspace and `sample_data_seeded_at` when populated. These fields are absent for a tester merely attached to an ordinary workspace.
|
||||
- `PUT /admin/users/:id/login-code-exempt`: `manage_testers`, an MFA-verified admin session and a recent confirmation. Body `{"exempt": true, "reason": "..."}` excuses that account from the [emailed login code](/development/accounts-and-access/#excusing-one-account); the reason is required (at most 500 characters) and the acting admin is recorded as the grantor. `{"exempt": false}` ends the exemption, clears a handed-out tester password and signs out every session the account holds. Both write the admin audit log, and setting the same state again is safe. An unknown account returns `404`. `GET /admin/users/:id` and `/preview` carry `login_code_exempt`, `login_code_exempt_reason` and `login_code_exempt_at`
|
||||
- `GET /admin/testers`: `view_users` and an MFA-verified admin session. Each tester in `data` may include `test_workspace_id` for its owned dedicated Test workspace and `sample_data_seeded_at` when populated. These fields are absent for a tester merely attached to an ordinary workspace. Every tester carries `created_as_tester`, true for an account the tester flow created.
|
||||
- `POST /admin/testers/:id/password`: `manage_testers`, an MFA-verified admin session and a recent confirmation. No request body. Gives an account created as a tester a newly generated [initial password](/development/accounts-and-access/#initial-passwords), valid 48 hours and to be changed at first sign-in. It replaces whatever password the account held and signs out its sessions and remembered devices first. Returns `200` with `user_id`, `password` (shown only in this response), `password_expires_at` and `password_change_required: true`, and writes `reissue_tester_password` to the admin audit log. An account that does not exist or was not created as a tester returns `404` and nothing changes. Not idempotent by design: every call issues a different password, and only the last one works.
|
||||
- `PUT /admin/users/:id/login-code-exempt`: `manage_testers`, an MFA-verified admin session and a recent confirmation. Body `{"exempt": true, "reason": "..."}` excuses that account from the [emailed login code](/development/accounts-and-access/#excusing-one-account); the reason is required (at most 500 characters) and the acting admin is recorded as the grantor. `{"exempt": false}` ends the exemption, clears the password of an account created as a tester and signs out every session the account holds. Both write the admin audit log, and setting the same state again is safe. An unknown account returns `404`. `GET /admin/users/:id` and `/preview` carry `login_code_exempt`, `login_code_exempt_reason` and `login_code_exempt_at`
|
||||
- `GET /admin/sends/holds`: `view_campaigns` and an MFA-verified admin session. Lists mailboxes held from sending (up to `limit`, default 100, at most 500), switched-on first, with a `summary` of `total`, `active`, `inactive` and `by_reason`. Each row carries the held send's `held_task_id`, `recipients`, `message_id` and timestamps, and `resolvable` with a `blocker` when it is not. An unknown hold younger than ten minutes is a send in progress and is not listed.
|
||||
- `POST /admin/sends/holds/:id/resolve` (`:id` is the mailbox): `stop_campaigns` and an MFA-verified admin session. Body `held_task_id`, `held_reason`, `outcome` (`sent` or `not_sent` for an `unknown` hold, `provider_confirmed` for `authentication`, `permanent` or `conflict`), `message_id` (required for `sent`), optional `provider_msg_id`, and a one-line `confirmation_reference`. It applies the [mailbox resolution](/development/send-safety/#from-the-admin-panel) in the mailbox's own organization and writes the admin audit log. An unknown verdict answers `applied_by_consumer: true` and lifts once the result consumer applies it. A repeat is refused rather than applied twice, so retrying is safe. Errors are `send_hold_not_found`, `send_hold_changed` and `send_hold_not_resolvable`.
|
||||
- `GET /admin/mailboxes`: `view_users` and an MFA-verified admin session. Optional `mailbox_id` filters by exact UUID; `status=all` includes inactive mailboxes. Node evidence links use `/mailboxes?mailbox_id=UUID`, regardless of loaded worker assignments or earlier browse filters. Deleted identities return an empty result, not a substitute mailbox.
|
||||
|
||||
@@ -198,9 +198,15 @@ Avatars, OAuth app logos, form logos, covers and backgrounds, and images placed
|
||||
|--------|--------|---------|
|
||||
| `password_breached` | 400 | The password appears in a public list of breached passwords and was refused. Choose one that does not |
|
||||
| `sso_link_expired` | 400 | The pending token from a `link_required` sign-in is unknown, expired (ten minutes), already used, or has had three wrong passwords. Start the provider sign-in again |
|
||||
| `password_reused` | 400 | `POST /auth/login/initial-password` was given the issued initial password itself. Choose a password of your own |
|
||||
| `password_change_expired` | 400 | The pending token from a `password_change_required` sign-in is unknown, expired (ten minutes) or already used, or the issued password it was for has run out. Sign in again; an issued password past its 48 hours is refused like a wrong password, so ask whoever issued it for a new one |
|
||||
| `password_change_required` | 403 | `POST /auth/sso/link` was given an issued initial password. Sign in with email and password first, which asks you to choose your own, then link the provider |
|
||||
| `reset_link_invalid` | 401 | `POST /auth/reset-password/session` or `/confirm` was given a reset link or reset session that expired, was already used, or was issued before the password last changed. Request a new link |
|
||||
| `api_credentials_revoke_unsupported` | 400 | `POST /auth/reset-password/confirm` or `POST /auth/me/password` asked to end connected apps and API keys (`revoke_api_credentials`) on a server that cannot. The password was not changed. Send it again without that option, then remove apps and keys from Settings |
|
||||
| `sessions_not_ended` | 503 | The same two routes could not sign out every device on the account, so the password was not changed. The response carries `Retry-After`; retry after it |
|
||||
| `sessions_not_ended` | 503 | The same two routes could not sign out every device on the account, so the password was not changed. From `DELETE /auth/me/identities/:provider` it means the provider was removed but not every device that signed in with it was signed out; repeating the request finishes it. The response carries `Retry-After`; retry after it |
|
||||
| `identity_not_found` | 404 | `DELETE /auth/me/identities/:provider` named something other than `google`, `apple` or `oidc` |
|
||||
| `last_sign_in_method` | 409 | `DELETE /auth/me/identities/:provider` or `DELETE /auth/passkey/credentials/:id` would leave the account with no password, no passkey and no other provider. Nothing was removed. Set a password (`POST /auth/me/password/link`) or add a passkey first |
|
||||
| `password_login_disabled` | 403 | `POST /auth/me/password/link` was called on a server that turned password sign-in off (`DISABLE_PASSWORD_LOGIN`), so a password could never be used. No link was sent |
|
||||
|
||||
A password must be 8 to 128 characters. There is no composition rule, but it is checked against the 100,000 most commonly breached passwords published by the UK National Cyber Security Centre, case-insensitively.
|
||||
|
||||
@@ -357,13 +363,14 @@ A redirect may only send visitors to a page on one of the workspace's own domain
|
||||
- a domain the workspace has a mailbox on, other than a shared email provider such as `gmail.com`
|
||||
- a verified tracking host of one of its mailboxes
|
||||
- the workspace's custom forms domain, once it is verified
|
||||
- a website the workspace confirmed by publishing its `_warmbly` `TXT` record on the website's registrable domain. Saving looks for the record before refusing, and `POST /emails/domains/:domain/redirect/website` returns the record to publish. See [confirm your website](/guides/sending-domains/#confirm-your-website)
|
||||
|
||||
Hosts are compared in lowercase, without a trailing dot and in their ASCII form, so `bücher.de` and `xn--bcher-kva.de` are the same domain. A subdomain matches its parent (`shop.acme.com` is on `acme.com`), but a name that only starts or ends the same way does not (`acme.com.example.net` and `notacme.com` are not on `acme.com`). An empty value still means no redirect.
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "Bad Request",
|
||||
"message": "The redirect has to go to a page on one of this workspace's own domains: a domain it has a mailbox on (not a shared provider such as gmail.com), its verified tracking domain, its verified forms domain, or a subdomain of one of them. Use an address on one of those, or connect a mailbox or verify a domain first.",
|
||||
"message": "The redirect has to go to a page on one of this workspace's own domains: a domain it has a mailbox on (not a shared provider such as gmail.com), its verified tracking domain, its verified forms domain, a website it verified with its TXT record, or a subdomain of one of them. Verify the website under Sending domains > Redirect, or use an address on one of those.",
|
||||
"code": "redirect_target_not_own_domain",
|
||||
"request_id": "4bbbd1b2-8f86-47dd-8a7f-9476501ad20e"
|
||||
}
|
||||
|
||||
@@ -46,6 +46,33 @@ Auth: public (not available to API keys).
|
||||
}
|
||||
```
|
||||
|
||||
When the password is an [issued initial password](/development/accounts-and-access/#initial-passwords), no code is sent and no session exists yet. The response asks for a new password instead:
|
||||
|
||||
```json
|
||||
{
|
||||
"code_required": false,
|
||||
"password_change_required": true,
|
||||
"pending_token": "eyJhbGciOiJIUzI1NiIs...",
|
||||
"expires_in": 600
|
||||
}
|
||||
```
|
||||
|
||||
### Choose a password after an issued one
|
||||
|
||||
`POST /auth/login/initial-password`
|
||||
|
||||
Replaces an issued initial password with the holder's own, then continues the sign-in exactly as `/auth/login` would: the response has the same shape, so it can carry `code_required` with a `session` for `/auth/login/confirm`, a `two_fa_required` challenge, or the `token` pair. Every other session the account holds is signed out first. The `pending_token` is single use and lasts ten minutes; it is accepted nowhere else, and no other token is accepted here.
|
||||
|
||||
Auth: public (not available to API keys).
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `pending_token` | string | yes | The `pending_token` from a `password_change_required` response. |
|
||||
| `password` | string | yes | The new password. The usual rules apply (8 to 128 characters, not on the breached list), and the issued password itself is refused with `password_reused`. |
|
||||
| `device_token` | string | no | The remembered-browser token, as sent to `/auth/login`. |
|
||||
|
||||
A token that is unknown, expired or already used, or whose issued password has run out, answers `password_change_expired`. See [password refusals](/api/error-codes/#password-refusals).
|
||||
|
||||
### Confirm login
|
||||
|
||||
`POST /auth/login/confirm`
|
||||
@@ -205,7 +232,7 @@ Auth: public (not available to API keys).
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `token` | string | yes | The `session` value from the emailed reset link, carried in its fragment (`#session=`); a link from older mail carries it in the query. |
|
||||
| `token` | string | yes | The `session` value from the emailed reset link, carried in its fragment (`#session=`), which a browser never sends to a server. |
|
||||
|
||||
#### Response
|
||||
|
||||
@@ -387,6 +414,12 @@ Self-service session management for the signed-in user. Revoking by id can only
|
||||
|
||||
Revokes the current session and closes the user's open realtime connections. Returns `204 No Content`.
|
||||
|
||||
The body is optional. `device_tokens` (an array of up to 16 strings) names the remembered-device tokens the signing-out browser holds; each one that belongs to this account is forgotten, so the next sign-in from that browser asks for the emailed code. A token of another account changes nothing.
|
||||
|
||||
```json
|
||||
{ "device_tokens": ["<token>"] }
|
||||
```
|
||||
|
||||
Auth: Session only (not available to API keys).
|
||||
|
||||
### Sign out everywhere
|
||||
@@ -593,6 +626,50 @@ Auth: Session only (not available to API keys).
|
||||
}
|
||||
```
|
||||
|
||||
### Send a set-password link
|
||||
|
||||
`POST /auth/me/password/link`
|
||||
|
||||
Emails the signed-in user a single-use link to set a password, to the address on the account. It is how an account created through Google, Apple or single sign-on adds email and password sign-in without a second account; it also works for an account that already has a password. The link is the same one **Forgot password** sends: it expires after one hour, setting the password through it ends every session (this one included), and it shares that flow's budget of 2 links per address per 4 hours. No request body. Returns `200 OK`.
|
||||
|
||||
The server refuses with `403` `password_login_disabled` when password sign-in is turned off, and with `400` when the budget is spent.
|
||||
|
||||
Auth: Session only (not available to API keys).
|
||||
|
||||
### List sign-in methods
|
||||
|
||||
`GET /auth/me/identities`
|
||||
|
||||
The providers linked to the signed-in user: Google, Apple or the deployment's single sign-on. `provider` is `google`, `apple` or `oidc`; `email` is the address the provider reported, which for Apple can be a Hide My Email relay address. A password and passkeys are not listed here.
|
||||
|
||||
Auth: Session only (not available to API keys).
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"provider": "apple",
|
||||
"label": "Apple",
|
||||
"email": "[EMAIL]",
|
||||
"created_at": "2026-03-02T09:14:00Z",
|
||||
"last_login_at": "2026-10-20T08:01:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Remove a sign-in method
|
||||
|
||||
`DELETE /auth/me/identities/:provider`
|
||||
|
||||
Stops the provider signing in to this account and ends every other session that signed in through it; the session making the request stays signed in. The account, its address, workspaces, roles, plan and connected mailboxes are unchanged. Signing in with the same provider and address again later links it back, after asking for the account's password when it has one. Requires a fresh confirmation (`reauth_required` otherwise). Returns `204 No Content`, also when the provider was already removed, so a repeat is safe.
|
||||
|
||||
Refused with `409` `last_sign_in_method` when the account would be left with no password, no passkey and no other provider, and with `404` `identity_not_found` when `:provider` is not `google`, `apple` or `oidc`. If the provider was removed but its sessions could not all be ended, the answer is `503` `sessions_not_ended` with `Retry-After`; repeat the request to finish.
|
||||
|
||||
Auth: Session only (not available to API keys).
|
||||
|
||||
## Notification preferences and feed
|
||||
|
||||
User-scoped, no organization gate. Preferences are a single per-user object; the feed is the in-app notification list.
|
||||
@@ -967,7 +1044,7 @@ Auth: Session only (not available to API keys).
|
||||
|
||||
`DELETE /auth/passkey/credentials/:id`
|
||||
|
||||
Removes a stored passkey. Returns `204 No Content`.
|
||||
Removes a stored passkey. Returns `204 No Content`. Refused with `409` `last_sign_in_method` when it is the account's only way to sign in (no password and no linked provider); set a password or link a provider first.
|
||||
|
||||
Auth: Session only (not available to API keys).
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ Set `new_device` to require one only from a device the user has not asked to rem
|
||||
|
||||
### Remembered devices
|
||||
|
||||
Under `new_device` the code step offers **Remember this device for 30 days**. Ticking it returns a random 256-bit token that the browser keeps. The server stores only its SHA-256, bound to that account, and the next password sign-in that sends it skips the emailed code. Nothing else changes for that sign-in: the password, the captcha and two-factor authentication still apply, and a sign-in the risk assessment flags (a new country, impossible travel) gets the code anyway. The 30 days are counted from when the box was ticked and are not extended by later sign-ins. Every remembered device is forgotten when the password is reset or changed, and when the user signs out everywhere or signs out their other sessions. `always` ignores remembered devices.
|
||||
Under `new_device` the code step offers **Remember this device for 30 days**. Ticking it returns a random 256-bit token that the browser keeps. The server stores only its SHA-256, bound to that account, and the next password sign-in that sends it skips the emailed code. Nothing else changes for that sign-in: the password, the captcha and two-factor authentication still apply, and a sign-in the risk assessment flags (a new country, impossible travel) gets the code anyway. The 30 days are counted from when the box was ticked and are not extended by later sign-ins. Signing out forgets the device it happens on: the dashboard sends the tokens that browser holds with the sign-out, the server deletes them, and the browser drops its copy, so the next sign-in there asks for a code. Every remembered device is forgotten when the password is reset or changed, and when the user signs out everywhere or signs out their other sessions. `always` ignores remembered devices.
|
||||
|
||||
### Excusing one account
|
||||
|
||||
@@ -119,7 +119,17 @@ A reason is required, and so is `--by`: this command talks to Postgres directly
|
||||
|
||||
Turning the switch off ends the exemption and signs out every session the account holds, exactly like revoking it under **Testers**.
|
||||
|
||||
The admin panel has the same thing under **Testers**: create one, see the password once, and revoke an exemption when the reason no longer holds. The password a tester is created with works for a period you choose, 1 to 48 hours (48 by default), and stops working then; the list shows when. Revoking a tester ends the exemption, clears that password and signs out every session the account holds. The account itself survives a revoke, so anything it did stays attributable, and so does any workspace membership it was given: remove the member from the workspace, or ban the account, to end its access entirely. An account exempted with `warmblyctl` has no handed-out password, so revoking it from the panel ends the exemption and its sessions and leaves its own password alone.
|
||||
The admin panel has the same thing under **Testers**: create one, see the password once, and revoke an exemption when the reason no longer holds. The password a tester is created with is an [initial password](#initial-passwords): it works for a period you choose, 1 to 48 hours (48 by default), and has to be replaced by the holder at their first sign-in. Revoking a tester ends the exemption, clears its password (the issued one, or the one the holder chose to replace it) and signs out every session the account holds. The account itself survives a revoke, so anything it did stays attributable, and so does any workspace membership it was given: remove the member from the workspace, or ban the account, to end its access entirely. An account only exempted with `warmblyctl` was never issued a password, so revoking it from the panel ends the exemption and its sessions and leaves its own password alone.
|
||||
|
||||
#### Initial passwords
|
||||
|
||||
A password Warmbly generates for somebody else is an initial password: a way in for the first sign-in, not a credential to keep. Today the only one is the password **Testers** issues; `warmblyctl user create`, `user reset-password --password-stdin` and the bootstrap owner all take a password the operator chose, and those do not expire.
|
||||
|
||||
- **It lasts at most 48 hours from issuance.** The database caps the expiry on every write, so no path can store a longer one, and an expiry can never be moved later or cleared without writing a new password. Upgrading to the release that introduced this shortens any issued password that had longer left to 48 hours from the upgrade. Extending an issued password is not possible: issue a new one instead, which starts its own 48 hours.
|
||||
- **Issuing a new one.** A tester's address cannot be used for a second tester, so when a password ran out before it was used, or the holder lost it, select **Issue new password** on that tester's row under **Testers**. It is offered only for accounts created there. It needs the platform `manage_testers` permission, an MFA-verified admin session and a recent confirmation of your own identity, and it asks you to confirm. The account gets a newly generated password valid for 48 hours, which has to be changed at first sign-in like the first one. Whatever password the account held before stops working, including one the holder chose, and every session and remembered device it had is signed out. The password is shown once, and the action is recorded in the admin audit log as `reissue_tester_password`. It does not extend the tester's Test workspace grant.
|
||||
- **It never opens a session.** Signing in with it, while it is still valid, asks the holder to choose their own password. That step needs the captcha the sign-in already passed, refuses a password on the breached list or the issued password itself, signs out every other session, and then continues the sign-in as usual: the emailed code where the account needs one, and two-factor authentication where it is enrolled. From then on the account works with the password the holder chose, which does not expire.
|
||||
- **Once it runs out, it is refused exactly like a wrong password.**
|
||||
- A provider sign-in (Google, Apple, single sign-on) cannot be linked by presenting an initial password; sign in with the password first.
|
||||
|
||||
#### Which workspace a tester lands in
|
||||
|
||||
@@ -127,11 +137,11 @@ A tester either gets a workspace of its own or joins one that already exists, an
|
||||
|
||||
Its own is the default and the safer one. The reviewer connects their own mailbox and exercises the app without reaching anything of yours, which is usually all an OAuth verification needs to see. The workspace is categorized as **Test** in the admin organization list and gets a private managed Test plan: paid-product features, including mailbox OAuth, campaigns, warmup, Unibox and AI, with 100 test credits. The dashboard header reads **Test**, not a customer plan name, and the credit gauge labels its allowance **Test credits**. Its allowance includes 10,000 contacts, 100 campaigns (20 active), 10 team members and a workspace send budget of 1,000 emails per day. Mailbox send spacing, reputation checks, captcha, authentication and abuse controls still apply. The category is informational, not an authorization bypass.
|
||||
|
||||
The managed plan expires when the handed-out password expires, and revoking the tester ends that grant immediately. Credits do not bypass feature gating after the grant ends. Existing dedicated reviewer workspaces recorded by tester creation are categorized on upgrade; still-active reviewers receive the grant and credits unless the workspace already has a Stripe subscription or an operator-managed plan. Legacy admin-created reviewers without a password expiry get the default 30-day lifetime measured from their original creation, not from the upgrade. Expired or revoked reviewers receive no renewed access. Existing memberships and data are not deleted.
|
||||
The managed plan expires when the issued password would have expired, whether or not the holder has replaced it, and revoking the tester ends that grant immediately. Credits do not bypass feature gating after the grant ends. Existing dedicated reviewer workspaces recorded by tester creation are categorized on upgrade; still-active reviewers receive the grant and credits unless the workspace already has a Stripe subscription or an operator-managed plan. Legacy admin-created reviewers without a password expiry get the default 30-day lifetime measured from their original creation, not from the upgrade. Expired or revoked reviewers receive no renewed access. Existing memberships and data are not deleted.
|
||||
|
||||
### Adding sample data
|
||||
|
||||
In **Admins > Testers**, select **Add sample data** beside an active tester who owns a dedicated **Test** workspace, then confirm. This works for both newly created workspaces and existing dedicated Test workspaces after upgrading. Nothing is added automatically during deployment or account creation. The action requires the platform `manage_testers` permission and an MFA-verified admin session. The backend checks the Test category, the owner's current exemption and password expiry, and an unexpired managed Test grant. Testers attached to ordinary customer workspaces cannot use it.
|
||||
In **Admins > Testers**, select **Add sample data** beside an active tester who owns a dedicated **Test** workspace, then confirm. This works for both newly created workspaces and existing dedicated Test workspaces after upgrading. Nothing is added automatically during deployment or account creation. The action requires the platform `manage_testers` permission and an MFA-verified admin session. The backend checks the Test category, the owner's current exemption, that the owner's issued password is still outstanding (not yet expired or replaced), and an unexpired managed Test grant. Testers attached to ordinary customer workspaces cannot use it.
|
||||
|
||||
The dataset contains:
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ Relative ages use your browser's current clock when a snapshot arrives, with per
|
||||
| **Sync** | The platform copy of each mailbox's backfill progress and fair-use throttle, with clear-throttle and restart-backfill. The budgets it enforces are the four `sync.*` values under [Configuration > Settings](/development/configuration/#settings-stored-in-the-database); the worker-side engine is the sync governor described under [anti-abuse layers](/development/architecture/#anti-abuse-layers) |
|
||||
| **Warmup** | The pools, the blocked list, and the block and unblock history |
|
||||
| **Warmup appeals** | Appeals from blocked mailboxes, to approve or reject |
|
||||
| **Warmup content** | The generated and reviewed [diagnostic conversation bank](/development/warmup-generation/), effective generation controls, library and generation jobs. Changing effective controls requires `manage_settings`; existing library reads still require `view_warmup_pool` |
|
||||
| **Warmup content** | The generated and reviewed [warmup conversation bank](/development/warmup-generation/), effective generation controls, library and generation jobs. Changing effective controls requires `manage_settings`; existing library reads still require `view_warmup_pool` |
|
||||
| **Seed panel** | The instance's placement seed inboxes by provider, adding and removing them, every workspace's recent [placement tests](/guides/placement-tests/) with their results, and an operator test that counts against no allowance |
|
||||
| **Campaigns** | Every campaign on the instance with its state and owner |
|
||||
| **Sends** | In-flight reservations no worker has answered, and the reclaimer that resolves them after 30 minutes; mailboxes held from sending, with a [resolve action](/development/send-safety/#from-the-admin-panel); dead letters with replay limited to non-sending campaign wakeups; task failures; customer webhook delivery health, with reclaim |
|
||||
@@ -186,7 +186,7 @@ Detail pages need the same bit as the list they open from. Actions inside a page
|
||||
|
||||
On a user's detail page, `manage_testers` also allows turning **Skip emailed sign-in code** on or off for that account, for an App Store or OAuth reviewer; see [excusing one account](/development/accounts-and-access/#excusing-one-account).
|
||||
|
||||
On **Admins > Testers**, `manage_testers` allows creating or revoking reviewer accounts and adding [sample data](/development/accounts-and-access/#adding-sample-data) to active dedicated Test workspaces. The confirmation lists what will be added; a seeded row shows its timestamp. It never creates a mailbox or sends email, and it cannot populate a customer workspace that a tester joined.
|
||||
On **Admins > Testers**, `manage_testers` allows creating or revoking reviewer accounts, and **Issue new password** on a tester row (which also needs a recent confirmation of your identity). An issued password is valid for at most 48 hours, cannot be extended, is shown once and must be changed at first sign-in; see [initial passwords](/development/accounts-and-access/#initial-passwords). The same permission allows adding [sample data](/development/accounts-and-access/#adding-sample-data) to active dedicated Test workspaces. The confirmation lists what will be added; a seeded row shows its timestamp. It never creates a mailbox or sends email, and it cannot populate a customer workspace that a tester joined.
|
||||
|
||||
## See also
|
||||
|
||||
|
||||
@@ -160,6 +160,10 @@ Nodes never carry hardcoded credentials, and there is nothing to keep in sync by
|
||||
|
||||
`PRIMARY_DB` is deliberately excluded for a worker, and so are `CREDENTIALS_ENCRYPTION_KEY`, its read keys and `KMS_LOCAL_MASTER_KEY`. A worker reaches relational data through the internal API and nothing else, opens workspace keys through the decrypt broker, and shipping a DSN or a root key here would quietly undo that boundary. A consumer is control plane and receives them.
|
||||
|
||||
Each node also proves which node it is. Join issues it a `NODE_CREDENTIAL`, stored only as a hash on its `fleet_nodes` row, and the node sends that credential with its id on every internal route only a node calls. The backend admits the call as that node, names it in the broker access log, and lets it heartbeat and fetch an env only as itself; deleting the node revokes it. The shared node token is still accepted alongside until the control plane sets `NODE_REQUIRE_NODE_CREDENTIAL=true`, so a fleet can upgrade one node at a time (see [configuration](/development/configuration/#secrets)).
|
||||
|
||||
A worker that proves itself this way acts only on its own assignment. A call naming a worker must name that worker; one naming a mailbox, an organization, a sealed data key or a blob key that encodes a mailbox or campaign must name one with a mailbox assigned to that worker, or one it was moved off less than `config.WorkerReleaseGraceMinutes` (30 minutes) ago, so sends and syncs in flight during a move finish. That grace equals the window after which the stuck-send reclaimer has resolved any send the old worker left unanswered, and every move is recorded by a trigger on `email_accounts.worker_id` (`previous_worker_id`, `worker_released_at`), whichever path makes it. An organization the control plane hands a worker for a credential check before any of its mailboxes is placed there is in scope for ten minutes. Anything else is answered 404 (403 on the routes that already refuse with it) and logged once per node and route. A consumer serves every organization and is not bound, and a call admitted on the shared node token is not bound either. The assignment is cached per node for 30 seconds and a miss is checked against the database directly, so a mailbox placed a moment ago is in scope at once and a hot data-key check is a map lookup (`internal/app/nodescope`).
|
||||
|
||||
Schema: `fleet_nodes` is the registry every role shares, and `workers` is the placement extension over it (`internal/infrastructure/db/migrations/000141_fleet_nodes.up.sql`); `000142_drop_push_provisioning.up.sql` removed the push path it replaced.
|
||||
|
||||
## Auto-update from GitHub releases
|
||||
@@ -177,7 +181,7 @@ The backend is deliberately excluded from this. It is what tells everyone else t
|
||||
|
||||
A staged rollout (`warmblyctl fleet rollout`) changes who gets the new version, not how it arrives. It is held in `fleet.release` next to the tag and lists the nodes admitted so far: an admitted node is told the target, everyone else the tag, which stays at the old version until the rollout finishes. A backend that predates rollouts reads only the tag and holds every node where it is. Every backend replica advances the rollout on a 30-second tick, and each change is a compare-and-swap on the settings row, so replicas never admit the same wave twice. A canary goes first, then cumulative waves, each only after every admitted node has reported the target and stayed up on it for the bake. A node that goes silent, misses the deadline, keeps restarting or rolls back halts the rollout, and a halted rollout sends the admitted nodes back to where they came from. See `internal/app/fleetnode/rollout.go`.
|
||||
|
||||
The updater checks its own work. After restarting onto a new version or env it watches the container for two minutes; one that stops or restarts in that time is put back on the previous image, or the previous `node.env`. A failed version is reported as `update_failed` so it is not tried again and a rollout halts on it. With `WARMBLY_ENV_REFRESH=true` it also replaces `node.env` when `env_revision` changes, fetching it from `GET /api/v1/internal/fleet/node-env` with the node's broker token and its own `NODE_CREDENTIAL`. That route renders exactly what join hands out, only for an enrolled node asking as its own role and proving it is that node (a worker whose updater predates node credentials is still answered, since a worker's env carries only fleet-wide values), so a configuration change or a key rotation reaches the fleet without anyone signing in to a machine. `node.local.env` is never touched.
|
||||
The updater checks its own work. After restarting onto a new version or env it watches the container for two minutes; one that stops or restarts in that time is put back on the previous image, or the previous `node.env`. A failed version is reported as `update_failed` so it is not tried again and a rollout halts on it. With `WARMBLY_ENV_REFRESH=true` it also replaces `node.env` when `env_revision` changes, fetching it from `GET /api/v1/internal/fleet/node-env` with the node's broker token, its id and its own `NODE_CREDENTIAL`. That route renders exactly what join hands out, only for an enrolled node asking as its own role and proving it is that node (a worker whose updater predates node credentials is still answered while `NODE_REQUIRE_NODE_CREDENTIAL` is off, since a worker's env carries only fleet-wide values), so a configuration change or a key rotation reaches the fleet without anyone signing in to a machine. `node.local.env` is never touched.
|
||||
|
||||
On an instance that encodes the bus with Avro, the fleet also waits for the backend. A booting backend registers every schema its release publishes, and the fleet only moves to a release once the backend runs it and the Schema Registry has accepted those schemas. A refusal holds the fleet on the release it has and shows in the Fleet section, instead of reaching a worker that would then fail every event it reports.
|
||||
|
||||
|
||||
@@ -220,7 +220,18 @@ references, sizes, health checks) and the workflow owns only the image. A deploy
|
||||
stable.
|
||||
5. Starts a [canary rollout](/development/warmblyctl/#fleet) of the worker and
|
||||
consumer hosts from the `ops` task. The first host moves alone and the rest
|
||||
follow after it has stayed healthy for 30 minutes.
|
||||
follow after it has stayed healthy for five minutes by default. Every host
|
||||
must then finish the same healthy-uptime bake before the rollout completes.
|
||||
Two stages therefore need at least ten minutes, plus image pulls, restarts
|
||||
and heartbeat delivery. Missing heartbeats, host rollback and repeated
|
||||
restarts still stop admission. Self-hosted CLI rollout defaults remain
|
||||
unchanged at 30 minutes per stage.
|
||||
|
||||
The fleet-start task retries an image-pull failure at most twice, after 30 and
|
||||
60 seconds, only when ECS confirms the task stopped before its command ran.
|
||||
It reuses the exact task definition and command with an idempotent token per
|
||||
attempt. An executed command failure or unresolved task requires inspection;
|
||||
migration tasks are never automatically retried by this recovery path.
|
||||
|
||||
During the bake, a service fails when one of its alarms fires or ECS rolls it
|
||||
back. Each public service has two alarms, which ECS also uses to roll back on
|
||||
@@ -250,7 +261,11 @@ change to a value they hold once their env refreshes
|
||||
([keeping a node's env current](/development/configuration/#keeping-a-nodes-env-current)).
|
||||
|
||||
`services` limits a run to some of the five services, and `bake_seconds` changes
|
||||
the bake. Releases published before build provenance existed fail the provenance
|
||||
the ECS service bake. `fleet_bake_seconds` sets the healthy uptime required per
|
||||
worker stage, from 300 through 3600 seconds. Automatic releases use the
|
||||
`AWS_FLEET_BAKE_SECONDS` repository variable, defaulting to 300. Set it to 1800
|
||||
for a longer observation window. This changes future rollouts; the policy of an
|
||||
active rollout stays fixed. Releases published before build provenance existed fail the provenance
|
||||
check; dispatch those once with `require_attestation` off. The automatic
|
||||
redeploy after a Terraform apply cannot turn it off, so until a release with
|
||||
provenance is running it stops at that check and changes nothing.
|
||||
@@ -329,6 +344,109 @@ The bootstrap stack stays manual. So does any change to the CI roles themselves:
|
||||
change its own permissions or trust, or the plan role's, so an administrator
|
||||
applies those by hand.
|
||||
|
||||
## Encrypt traffic inside the VPC
|
||||
|
||||
The load balancer terminates the public TLS connection. With `target_tls` set,
|
||||
the hops behind it are TLS too: the load balancer reaches each task over HTTPS
|
||||
with HTTPS health checks, and the forms and tracking services reach the
|
||||
backend's internal API at `https://backend.<namespace>:<target_tls_port>`,
|
||||
verifying its certificate. The services read the settings described under
|
||||
[TLS listeners](/development/configuration/#tls-listeners).
|
||||
|
||||
The two hops trust different things. A load balancer does not validate its
|
||||
targets' certificates, so forms, tracking and realtime serve a certificate
|
||||
generated in memory at boot. The forms and tracking services do verify the
|
||||
backend, so it serves a certificate you supply, and they trust exactly that
|
||||
certificate (`BACKEND_INTERNAL_CA`) rather than any public authority. The
|
||||
internal hop stays on the private service-discovery name, so the internal API
|
||||
token never leaves the VPC.
|
||||
|
||||
### Prepare the backend certificate
|
||||
|
||||
Create a key pair naming the private host. Use the runtime `namespace`
|
||||
(`warmbly.internal` by default):
|
||||
|
||||
```bash
|
||||
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days 825 \
|
||||
-subj "/CN=backend.warmbly.internal" \
|
||||
-addext "subjectAltName=DNS:backend.warmbly.internal" \
|
||||
-addext "basicConstraints=critical,CA:FALSE" \
|
||||
-addext "keyUsage=critical,digitalSignature" \
|
||||
-addext "extendedKeyUsage=serverAuth" \
|
||||
-keyout key.pem -out cert.pem
|
||||
```
|
||||
|
||||
Add the contents of `key.pem` to a new version of the backend secret as
|
||||
`SERVE_TLS_KEY`, add `SERVE_TLS_KEY` to the backend's `secret_keys` and point
|
||||
its `secret_version_id` at that version. Put the contents of `cert.pem` in the
|
||||
runtime var file as `backend_internal_certificate`; it is public. The plan
|
||||
refuses `target_tls` without both. Replace the pair before it expires: the
|
||||
backend logs a line at boot inside the last 30 days, and an expired certificate
|
||||
stops click tracking and hosted forms.
|
||||
|
||||
### Move through the stages
|
||||
|
||||
`target_tls` takes six values. Change it one stage at a time, and let each
|
||||
merge finish its apply and redeploy before the next:
|
||||
|
||||
| Stage | What changes |
|
||||
|---|---|
|
||||
| `off` | Nothing; tasks serve plain HTTP only |
|
||||
| `serve` | Every load-balanced task also serves TLS on `target_tls_port` (default `8443`), and the security groups open that port to the load balancer and between tasks. Traffic is unchanged |
|
||||
| `both` | An HTTPS target group per service is attached to its listener rule at weight 0 and the tasks register in both groups. The forms and tracking services move to the backend's TLS port |
|
||||
| `route` | Listener rules forward to HTTPS and alarms watch the HTTPS groups. The HTTP groups, healthy registrations and network rules remain ready while the new path bakes |
|
||||
| `drain` | After the route deployment and bakes pass, ECS stops registering HTTP targets and listeners drop their HTTP references. The groups and network rules remain while connections drain |
|
||||
| `on` | After the drain deployment and bakes pass, the empty HTTP groups, the plain-port security group rules and the internal `8080` rule are removed. Every plain listener is bound to loopback for the container health check only |
|
||||
|
||||
Each stage keeps the listeners the previous one used, so a rolling deploy never
|
||||
meets a task that cannot answer. `serve` and `both` only add task definition
|
||||
revisions and resources, so they apply on their own. `route` performs the traffic
|
||||
switch without deleting network rules or target groups. It must finish its normal
|
||||
release redeploy and bakes before a separately approved `drain` run. Cleanup checks
|
||||
that the HTTP groups have no load balancer references or registered targets and
|
||||
that every public service uses only its HTTPS target group. ECS waits for a steady
|
||||
state during these stages.
|
||||
|
||||
Before `serve`, the running release has to support `SERVE_TLS`. An older image
|
||||
ignores the setting and keeps working in `serve`, but not in `both` or `on`, so
|
||||
advance past `serve` only once rolling back to a release without it is no longer
|
||||
needed. A stage can be undone by setting the previous one while the current
|
||||
one is `serve` or `both`. From `route`, returning to `both` sends traffic to the
|
||||
still-registered HTTP targets. From `drain`, return to `route` first and wait for
|
||||
healthy HTTP registrations before returning to `both`. Stepping back from `on` is not supported, because it
|
||||
would forward to an HTTP target group that has no tasks yet; roll back images
|
||||
among releases that support `SERVE_TLS` instead.
|
||||
|
||||
### Finalize TLS independently
|
||||
|
||||
The manual **Finalize runtime TLS** workflow advances `both` to `route`, then
|
||||
`drain` and `on` in separate approved runs without applying other infrastructure
|
||||
changes. After verifying the pinned backend hop
|
||||
and every HTTPS target, upload the reviewed `both` runtime var file to
|
||||
`warmbly/production/vars/runtime-tls.tfvars.json` in the private state bucket.
|
||||
Keep its S3 version ID: the workflow reads that exact version in both jobs.
|
||||
|
||||
Dispatch the workflow from `main` with stage `route`, that version ID and the
|
||||
currently deployed release tag. It prints resource addresses and actions for review and
|
||||
waits in `aws-infrastructure-approval`. After approval it rechecks HTTPS target
|
||||
health, replans and requires the complete resource changes to match the approved
|
||||
digest. Each job first requires all four services to be stable on the selected
|
||||
release with compatible TLS listeners and registrations. Route also requires
|
||||
healthy HTTP fallback targets. Route and drain plans refuse target-group and security-rule deletions. The scope
|
||||
guard refuses changes to other task definitions or infrastructure.
|
||||
|
||||
After applying, it redeploys the same release to backend, forms, tracking and
|
||||
realtime through the normal attestation, secret comparison, alarm and bake gates.
|
||||
It does not start a worker rollout. After that run succeeds, persist
|
||||
`target_tls=route`, verify HTTPS health and routes, and upload a new versioned
|
||||
snapshot. Dispatch stage `drain` with that snapshot and the successful route run ID
|
||||
as `previous_run`. After the drain run succeeds, persist `target_tls=drain`, upload
|
||||
a new snapshot, and dispatch `on` with the successful drain run ID. Each stage
|
||||
verifies the preceding workflow completed all bakes. Cleanup is refused until
|
||||
HTTP references and registrations have drained. Review and approve each
|
||||
plan separately. Persist `target_tls=on` only after it succeeds, then verify the
|
||||
effective loopback listeners and HTTPS routes.
|
||||
|
||||
## One-time GitHub setup
|
||||
|
||||
1. On the `aws-production` environment, allow the `v*.*.*` tag pattern next to
|
||||
|
||||
@@ -60,10 +60,11 @@ Five values protect the whole instance. Compose ships a working default for each
|
||||
|---|---|---|---|
|
||||
| `AUTH_SECRET` | 32 characters or more, enforced at boot | JWT and session signing. The realtime service reads the same value as `JWT_SECRET` and applies the same floor. Both refuse to start below it: a shorter HS256 key can be recovered offline from any token the service has issued. By default it also supplies the MFA sealing, unsubscribe signing and DNS ownership-proof keys. Configure the separate purpose keys below before rotating sessions when those values must remain stable | yes |
|
||||
| `INTERNAL_API_TOKEN` | any random string | The backend's `/api/v1/internal/` routes the tracking and forms services call (click tickets, root redirects, page views, hosted forms). Fleet nodes authenticate with it too when `NODE_BROKER_TOKEN` is unset | yes |
|
||||
| `NODE_BROKER_TOKEN` | any random string | Every internal route only a fleet node calls: organization data keys (read, store and open), blob signing, provider access tokens for a mailbox Warmbly Cloud manages, the message map and sync lookups, worker config and the node heartbeat. Optional, and falls back to `INTERNAL_API_TOKEN`. The same value has to be set on the control plane and on every node, or those routes answer 401; a node joined after it is set receives it in `node.env` in place of `INTERNAL_API_TOKEN`, and a node joined before has to join again. The installer generates one for a new install; an existing install keeps the shared token until you set one | yes |
|
||||
| `NODE_BROKER_TOKEN` | any random string | Every internal route only a fleet node calls: organization data keys (read, store and open), blob signing, provider access tokens for a mailbox Warmbly Cloud manages, the message map and sync lookups, worker config and the node heartbeat. Optional, and falls back to `INTERNAL_API_TOKEN`. The same value has to be set on the control plane and on every node, or those routes answer 401; a node joined after it is set receives it in `node.env` in place of `INTERNAL_API_TOKEN`, and a node joined before has to join again. The installer generates one for a new install; an existing install keeps the shared token until you set one. Each node also sends its own `NODE_CREDENTIAL`, and with `NODE_REQUIRE_NODE_CREDENTIAL=true` only that is accepted | yes |
|
||||
| `NODE_ACCEPT_INTERNAL_TOKEN` | `true` or unset | While `true`, the node-only routes other than the key and blob brokers also accept `INTERNAL_API_TOKEN`. An upgrade does not need it: a heartbeat sent with `INTERNAL_API_TOKEN` is always answered with the node's version and nothing is recorded, so an older node updates itself. Set it only to keep older nodes syncing until they have updated, then remove it: while it is on, the tracking and forms services' token reaches those routes | no |
|
||||
| `NODE_LOG_TOKEN` | enrollment-issued 43-character base64url secret, different per node | Only node-specific log ingestion. Issued in the protected fleet join environment, hashed in primary Redis, never derived/exchanged from the fleet-wide broker/internal credential. Rejoin rotates only this evidence credential; deletion revokes it. Deploy backend before upgrading nodes, then rerun authenticated join using the same config directory and UUID, keeping local overrides. No fleet deletion, mailbox reassignment or manual secret copying is required; the script restarts the service. Upgrade alone does not fill unavailable coverage and no historical logs are backfilled. Never share one value fleet-wide | yes |
|
||||
| `NODE_CREDENTIAL` | join-issued 43-character base64url secret, different per node | Proves which node is asking when the host updater fetches that node's env. Issued in the protected fleet join environment; only its SHA-256 is stored, in the `fleet_nodes` table, so nothing a node can reach can rewrite it. A rejoin replaces it and deleting the node revokes it. A node joined before this setting existed holds none: a worker keeps refreshing its env without it, and a consumer's env is handed out only against it, so join a consumer again (same config directory, so it keeps its id and `node.local.env`) to resume env refresh. Kept across an env refresh; never copy it to another machine | yes |
|
||||
| `NODE_CREDENTIAL` | join-issued 43-character base64url secret, different per node | Proves which node is asking. A node sends it with its id (`X-Warmbly-Node-Id` and `X-Warmbly-Node-Credential`) on every internal route only a node calls: the key and blob brokers, data keys, the message map, sync lookups, worker config, the heartbeat and its env. The backend checks it against the node's enrolled row, names that node in the broker access log, and lets a node heartbeat and fetch an env only as itself. A worker admitted this way acts only on what it is assigned: its own worker id, and the mailboxes, organizations, data keys and mailbox or campaign blobs of the mailboxes placed on it, plus those moved off it within the last 30 minutes so in-flight work finishes ([architecture](/development/architecture/#node-configuration)). A consumer serves every organization. Issued in the protected fleet join environment; only its SHA-256 is stored, in the `fleet_nodes` table, so nothing a node can reach can rewrite it. A rejoin replaces it and deleting the node revokes it. A node joined before this setting existed holds none and falls back to the fleet token until it joins again (same config directory, so it keeps its id and `node.local.env`); a consumer's env is handed out only against it. Kept across an env refresh; never copy it to another machine | yes |
|
||||
| `NODE_REQUIRE_NODE_CREDENTIAL` | `true` or unset | Backend only. While `true`, the node-only internal routes accept only a node's own `NODE_CREDENTIAL`: `NODE_BROKER_TOKEN`, `INTERNAL_API_TOKEN` and the update-only heartbeat are refused with 401. Unset keeps today's behaviour, where a node without a credential is still admitted on the fleet token. Turn it on only after every node runs a release that sends its credential and none was joined before node credentials existed: the backend logs `node heartbeats without its own node credential` once per node still on the fleet token, so an empty log after a full beat interval is the signal. Turning it off again restores fleet-token access at once | no |
|
||||
| `SECRET_KEY_BASE` | 64 characters or more | Phoenix session signing in the realtime service | yes |
|
||||
| `KMS_LOCAL_MASTER_KEY` | base64, exactly 32 bytes | The root key that seals every per-organization data key | yes |
|
||||
| `CREDENTIALS_ENCRYPTION_KEY` | exactly 64 hex characters | Mailbox credentials at rest: SMTP and IMAP passwords, and Gmail and Outlook OAuth access and refresh tokens | yes |
|
||||
@@ -178,6 +179,22 @@ Empty is correct for a directly exposed backend. Behind a reverse proxy it is no
|
||||
TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12
|
||||
```
|
||||
|
||||
### TLS listeners
|
||||
|
||||
The backend, forms, tracking and realtime services listen on plain HTTP, and that stays the default everywhere: Compose, the installer and local development need nothing from this table. Set `SERVE_TLS` on a service and it also listens with TLS 1.2 or later on `SERVE_TLS_PORT`, for a load balancer or an internal caller that should reach it encrypted. The plain listener stays up beside it, so the container health check and any caller not yet moved keep working.
|
||||
|
||||
| Variable | What it does | Default | Restart needed |
|
||||
|---|---|---|---|
|
||||
| `SERVE_TLS` | `self-signed` generates an ECDSA P-256 certificate in memory at boot, for a load balancer that does not validate its targets (an AWS Application Load Balancer does not). `supplied` serves the certificate and key below, for a caller that verifies the server. Unset or `off` adds no TLS listener | unset | yes |
|
||||
| `SERVE_TLS_PORT` | The TLS listener's port. Required with `SERVE_TLS` | none | yes |
|
||||
| `SERVE_TLS_CERT`, `SERVE_TLS_CERT_FILE` | With `supplied`, the PEM certificate, given inline or as a file path. Set exactly one | none | yes |
|
||||
| `SERVE_TLS_KEY`, `SERVE_TLS_KEY_FILE` | With `supplied`, the PEM private key, given inline or as a file path. Set exactly one, and keep it with your other secrets | none | yes |
|
||||
| `SERVE_HTTP_LOOPBACK_ONLY` | `true` binds the plain listener to `127.0.0.1`, so from outside the container the TLS port is the only way in while the health check still reaches the plain one. Needs `SERVE_TLS` | `false` | yes |
|
||||
|
||||
A service refuses to start on an incomplete combination rather than serving something other than what was asked for. The backend logs a line at boot when the certificate it serves expires within 30 days.
|
||||
|
||||
The forms and tracking services verify the backend's certificate whenever `BACKEND_INTERNAL_URL` is `https://`. `BACKEND_INTERNAL_CA` (PEM) or `BACKEND_INTERNAL_CA_FILE` replaces the system roots with exactly the certificates given, which is how they trust a backend serving a private certificate through `SERVE_TLS=supplied`. That certificate has to name the host in `BACKEND_INTERNAL_URL`.
|
||||
|
||||
## Authentication
|
||||
|
||||
| Variable | What it does | Default | Restart needed |
|
||||
@@ -293,6 +310,12 @@ docker compose -p warmbly logs backend | grep -B2 -A12 "MAIL_TRANSPORT=log"
|
||||
The backend refuses to start without `EMAIL_ADDRESS` and `EMAIL_NAME`. The consumer logs a warning and silently disables all notification and digest email, so an instance can look healthy while sending nothing. Set both on every process.
|
||||
</Callout>
|
||||
|
||||
## Automatic campaign send recovery
|
||||
|
||||
| Variable | What it does | Default | Restart needed |
|
||||
|---|---|---|---|
|
||||
| `CAMPAIGN_SEND_ISOLATION_ENABLED` | Automatic isolation of authorized campaign sends with unknown outcomes after ten minutes. On unless set to `false`; set it on backends and consumers alike. See [activation and rollback](/development/send-safety/#automatic-campaign-isolation) | `true` | yes |
|
||||
|
||||
## Pre-send verification
|
||||
|
||||
Before a campaign sends to an address, the backend can check it: syntax, then `MX`, then an `SMTP` `RCPT` probe against the recipient's mail server. An address that comes back `invalid` is skipped rather than sent to, which turns a would-be hard bounce into a silent drop. The probe runs from the backend, never from a worker, because workers are your sending IPs.
|
||||
@@ -737,7 +760,7 @@ Salesforce reads `SALESFORCE_OAUTH_CLIENT_ID` and `SALESFORCE_OAUTH_CLIENT_SECRE
|
||||
|
||||
| Variable | What it does | Default |
|
||||
|---|---|---|
|
||||
| `AI_PROVIDER` | `openai`, `openrouter`, `groq`, `ollama`, `anthropic` or `custom`. Omit every AI variable to run with AI off, in which case AI endpoints return a clean `503` | unset |
|
||||
| `AI_PROVIDER` | `openai`, `openrouter`, `groq`, `ollama`, `anthropic` or `custom`. Omit every AI variable to run with AI off, in which case AI endpoints return a clean `503` and warmup uses only its built-in conversation library. Warmup batch generation requires `openai` or an unset provider with an OpenAI key | unset |
|
||||
| `AI_API_KEY` | Provider key. Not needed for `ollama` | unset |
|
||||
| `AI_MODEL`, `AI_MODEL_TRIAL`, `AI_MODEL_PAID` | Model selection, optionally split by plan | provider preset |
|
||||
| `AI_BASE_URL` | Required for `custom`. Any OpenAI compatible endpoint | unset |
|
||||
@@ -745,7 +768,7 @@ Salesforce reads `SALESFORCE_OAUTH_CLIENT_ID` and `SALESFORCE_OAUTH_CLIENT_SECRE
|
||||
| `SEARCH_PROVIDER`, `SEARCH_API_URL`, `SEARCH_API_KEY` | Web search for the assistant (`serper` or `searxng`) | unset |
|
||||
| `MAILHOST_ISPDB` | `true` lets mailbox server detection ask Mozilla's Thunderbird ISPDB (`autoconfig.thunderbird.net`) about a domain whose MX records and own autoconfig file name no known provider. Only the domain name is sent. See [data control](/development/data-control/#outbound-calls) | `false` on a self-host, `true` on Warmbly Cloud |
|
||||
| `MAILVENDOR_SANDBOX_URL` | Development only. Points every inbox vendor client at the [sandbox's mock vendor API](/development/sandbox/#mock-inbox-vendors) (`<url>/inboxkit`, `<url>/mailforge`) instead of the real vendors. Ignored unless `APP_ENV` is `dev` | unset |
|
||||
| `TYPESAFE_API_KEY` | TypeSafe API key. Turns on the typed judgments: reply classification, the copy judgment in the Advisor and the editor, warmup content lint, bounce classification, import column mapping and per-form triage. Inbox tagging needs the switch below as well. See [data control](/development/data-control/#typesafe-judgments) for what each one sends | unset |
|
||||
| `TYPESAFE_API_KEY` | TypeSafe API key. Turns on the typed judgments: reply classification, the copy judgment in the Advisor and the editor, warmup content review (otherwise performed by OpenAI when its generator is configured), bounce classification, import column mapping and per-form triage. Inbox tagging needs the switch below as well. See [data control](/development/data-control/#typesafe-judgments) for what each one sends | unset |
|
||||
| `INBOX_TAGGING_ENABLED` | `true` enables automatic inbox tagging when `TYPESAFE_API_KEY` is also set. Message subject, current body, and the previous outbound body are sent to TypeSafe | `false` |
|
||||
|
||||
<Callout type="warn" title="An unset provider still uses a key">
|
||||
@@ -920,6 +943,7 @@ The public face of hosted forms (`cmd/forms`): it serves the React (TanStack) fo
|
||||
| `FORMS_PORT` | Listen port | `8090` |
|
||||
| `FORMS_STATIC_DIR` | The built forms app (`pnpm build` output). The service exits at boot when `index.html` is missing there | `forms/dist` |
|
||||
| `BACKEND_INTERNAL_URL` | Where the service resolves forms and forwards submissions, the same variable the tracking service uses. **Required**: the service exits at boot without it | none |
|
||||
| `BACKEND_INTERNAL_CA`, `BACKEND_INTERNAL_CA_FILE` | PEM certificates that replace the system roots when verifying an `https://` `BACKEND_INTERNAL_URL`. See [TLS listeners](/development/configuration/#tls-listeners) | unset (system roots) |
|
||||
| `INTERNAL_API_TOKEN` | Bearer token for those calls, matching the backend's. **Required**: the service exits at boot on an empty value | none |
|
||||
| `FORM_IP_RATE_LIMIT` | Public form submissions allowed per source IP per 10 minutes, per forms-service instance | `30` |
|
||||
| `POSTHOG_KEY`, `POSTHOG_HOST`, `POSTHOG_ERROR_TRACKING` | The service's own error tracking. Unset means none | unset |
|
||||
@@ -938,6 +962,7 @@ Run a single copy of it. Its event deduplication, its per-source rate limits and
|
||||
|---|---|---|
|
||||
| `TRACKING_HOST`, `TRACKING_PORT` | Listen address | `0.0.0.0`, `3000` |
|
||||
| `BACKEND_INTERNAL_URL` | Where tracking resolves opaque `/c/<id>` click tickets. **Required**: the service exits at boot without it | none |
|
||||
| `BACKEND_INTERNAL_CA`, `BACKEND_INTERNAL_CA_FILE` | PEM certificates that replace the system roots when verifying an `https://` `BACKEND_INTERNAL_URL`. See [TLS listeners](/development/configuration/#tls-listeners) | unset (system roots) |
|
||||
| `INTERNAL_API_TOKEN` | Bearer token for that lookup. **Required**: the service exits at boot on an empty value | none |
|
||||
| `TRACKING_RATE_LIMIT_PER_MIN` | Counted pixel and click requests per source per minute. Over budget, pixels are still served but not counted, and click redirects get `429` | `300` |
|
||||
| `TRACKING_PAGEHIT_RATE_LIMIT_PER_MIN` | Website page views accepted per source per minute, on top of the shared budget above. Over budget, the snippet gets `429` | `60` |
|
||||
@@ -1029,7 +1054,7 @@ These are the only settings a browser can change, and no environment variable ow
|
||||
| `tracking.machine_window_probable_seconds` | integer, 1 to 86400 | `600` | The window used instead of the two above when the tracking service recognised the source as a mail-security network that also renders clicked pages for people, which Proofpoint, Mimecast and Cisco do through browser isolation. Such a match cannot settle whether a person is behind the request, so it widens the window rather than deciding: inside it the event is the delivery-time scan, past it the recipient who got to the mail later. Never applied shorter than the window for the kind of event in hand, so naming a network can only ever catch more scans. Its ceiling reaches a day because how long a vendor takes to detonate a link is the vendor's property, not the instance's |
|
||||
| `deliverability.enforce_domain_auth` | boolean | `true` | Whether a sending domain that fails SPF or DMARC stops cold campaign sending and warmup sending from every mailbox on it. Off keeps the check running and still shows the state and the Advisor card, it just never blocks |
|
||||
| `deliverability.auth_grace_hours` | integer, 1 to 720 | `72` | How long a domain must stay failing before the gate applies. The clock starts when the background check first sees the failure, so this is also how much warning the owner gets |
|
||||
| `warmup_generation` | object | Existing saved provider/model configuration, with generation enabled and bounded control defaults | Effective provider, cadence, stop, daily reservation cap, AI selection share, pools and canonical reply-count controls. See [all supported fields and defaults](/development/warmup-generation/) before editing; do not remove credentials while batches drain |
|
||||
| `warmup_generation` | object | Existing saved model and generation policy, with generation enabled and bounded control defaults | Effective model, cadence, stop, daily reservation cap, available-capacity targets and canonical reply-count controls. Provider selection uses `AI_PROVIDER` and `AI_API_KEY` from the AI environment variables above. A mailbox does not see the same conversation again within 30 days in either role while unseen ones remain; optional refresh defaults off to preserve usable stock; legacy AI selection share is retained for rollback. See [all supported fields and defaults](/development/warmup-generation/) before editing; do not remove credentials while batches drain |
|
||||
| `placement.tests_per_month_trial` | integer, 1 to 100000 | `3` | How many free [placement tests](/guides/placement-tests/) a workspace on a free trial may run per calendar month on the instance seed panel. Only an instance running with `DEPLOYMENT_MODE=cloud` meters; a self-hosted instance never counts its own tests. Tests on a workspace's own seed inboxes are never counted |
|
||||
| `placement.tests_per_month_paid` | integer, 1 to 100000 | `40` | The same free allowance for a workspace on a paid plan. Past it, a test costs `placement.credits_per_test` credits |
|
||||
| `placement.seeds_per_test` | integer, 1 to 100 | `20` | The most seed inboxes one test sends to. Every copy is a send from the sending mailbox's daily limit, so this is also how much of that limit one test takes. A test is sized down to what the mailbox has left that day, and refused below five seeds |
|
||||
@@ -1068,6 +1093,12 @@ Changing them is audited, and every value is validated and clamped server side o
|
||||
|
||||
## See also
|
||||
|
||||
Hosted AWS deployment automation accepts `DEPLOY_FLEET_BAKE_SECONDS` (300 through
|
||||
3600, default 300) in its deployment client. The workflow supplies it from
|
||||
`fleet_bake_seconds` or the `AWS_FLEET_BAKE_SECONDS` GitHub repository variable.
|
||||
It controls healthy uptime per stage for future worker rollouts, not application
|
||||
startup or existing self-host settings. See [AWS deployment](/development/aws-fargate/).
|
||||
|
||||
- [Install](/development/install/) for the one-command install that writes all of this for you
|
||||
- [Data control](/development/data-control/) for where each store lives and what each retention window governs
|
||||
- [First run](/development/first-run/) for claiming a fresh instance
|
||||
|
||||
@@ -74,20 +74,22 @@ Mail over a daily budget is deferred, never dropped: the provider cursor is held
|
||||
|
||||
### TypeSafe judgments
|
||||
|
||||
`TYPESAFE_API_KEY` turns on a family of typed judgments, each of which sends a bounded piece of text to TypeSafe and stores a verdict. Without the key none of them runs and no content leaves the instance. What each one sends:
|
||||
`TYPESAFE_API_KEY` turns on a family of typed judgments, each of which sends a bounded piece of text to TypeSafe and stores a verdict. Without the key none of these TypeSafe calls runs. A separately configured OpenAI warmup generator still performs generation and review as described below. What each one sends:
|
||||
|
||||
| Judgment | On by | What is sent | Where the verdict lives |
|
||||
|---|---|---|---|
|
||||
| Automatic inbox tagging | `INBOX_TAGGING_ENABLED=true` | The inbound subject and bounded plain-text body (for a notification recognised offline by its sender, only while the workspace asks notifications whether they need action, or asks one of its own questions of them), plus the previous outbound message in the thread and the name of the campaign it belongs to when one exists, the workspace's own tagging questions, and the names of its tagging languages when any are chosen | `inbox_tag_results`, with the raw probabilities and the actions taken. Completed results travel with the Inbox group in a workspace export; processing claims do not |
|
||||
| Reply classification | The key alone | The subject and body of a reply to a campaign, only when no tagging verdict exists for it and the offline layers could not decide | `campaign_contact_progress.reply_class` and `reply_intent` |
|
||||
| Copy judgment | The key alone | The subject and body of a campaign step, at Advisor evaluation and on the editor's re-check | `copy_judgments`, keyed by a hash of the copy and never exported |
|
||||
| Warmup content lint | The key alone | A generated warmup thread before it enters the bank | Rejected threads are counted on the generation job; nothing else is kept |
|
||||
| Warmup content lint | The key alone | A generated warmup thread before it enters the bank | Review state is stored with the generated thread; rejected threads stay archived and are counted on the generation job |
|
||||
| Bounce classification | The key alone | The bounce reason text, only when it does not name the recipient | `deliverability_events.metadata` |
|
||||
| Import column mapping | The key alone | For an import or Google Sheets preview with columns no header matched: every column header, the kind of value each column holds (email addresses, dates, short text and so on, worked out on the instance), and the workspace's custom field names. Never a cell value, and nothing at all unless the first row is clearly headers: none of its cells may be an address, a date or a number, and the Email column must have a header of its own. A contact's row fails that, since its Email cell is the address or blank | Nothing is stored; the answer only fills in the suggested mapping |
|
||||
| Form triage | A per-form switch | The submitted answers, labelled by field; never the visitor's address, agent or URL | `form_submissions.triage`, which travels with the Contacts group |
|
||||
| Mailbox import columns | The key alone | For a column of an import file that no header name or value pattern placed: the column's header text and a description of its values (such as "16 lowercase letters" or "hostnames"), never a value | Nowhere; the answer only sets that column's suggested field, which can be changed before importing |
|
||||
| Mailbox import failures | The key alone | For a connect refusal the import does not recognise: the server's reply with addresses, IP addresses, usernames and long tokens scrubbed out, and the mail host family (such as `google_workspace` or `other`) | `mailbox_import_rows.cause`, as the cause the row is grouped under |
|
||||
|
||||
Warmup generation sends theme instructions to the configured OpenAI Batch generator. When TypeSafe is absent, a separate OpenAI completion receives the complete generated thread with placeholder sender names for semantic review. It receives generated content, not customer mailbox messages or credentials. Approved and rejected generated content and review status are stored in the shared content bank. Without a compatible OpenAI generator, nothing is sent to a provider and warmup uses the built-in conversation library, which never leaves the instance. See [generation configuration and limits](/development/warmup-generation/).
|
||||
|
||||
See [Automatic inbox tagging](/guides/inbox-tagging/), [Advisor](/guides/advisor/), [Warmup](/guides/warmup/), [Deliverability](/guides/deliverability/), [Contacts](/guides/contacts-crm/#mapping-into-your-custom-fields), [Forms](/guides/forms/) and [Import mailboxes](/guides/mailbox-import/).
|
||||
|
||||
### Event history
|
||||
@@ -130,6 +132,10 @@ A [tracking comparison](/guides/placement-tests/#tracking) renders each seed's c
|
||||
|
||||
The iOS app proves it is a genuine copy with [App Attest](/api/reference/account-org/#app-attest-native-apps), and each install registers one key in the `app_attest_keys` Postgres table: the key id, its public key, the app ID and environment it was attested under, its counter, Apple's receipt, and when it was created and last used. A row names no user and no workspace. It has no retention window, is included in instance backups, and does not travel in workspace exports, because it belongs to the instance the app verified against.
|
||||
|
||||
### Warmup content reservations
|
||||
|
||||
`warmup_conversation_mailboxes` records when each mailbox last saw each shared conversation, as sender or recipient, so selection can avoid repeats within 30 days. It survives task and warmup-token cleanup. Rows remain until the conversation or mailbox is deleted. Instance backups preserve them; workspace exports exclude these instance-local reservations because the shared content library does not travel. Imported mailboxes join the destination’s content pool.
|
||||
|
||||
### Warmup reconnect recovery
|
||||
|
||||
`warmup_recovery_identifiers` holds SHA-256 fingerprints of a mailbox address and exact warmup message IDs or verification tokens, scoped to a workspace. They survive removing a mailbox so adding the same address again can recognize recent warmup mail without retaining its content or credentials. Each expires 90 days after its source record, expired identifiers are swept every minute in bounded batches, and deleting the workspace removes them immediately. They travel in the Warmup group of a [workspace export](/guides/workspace-export-import/).
|
||||
@@ -334,7 +340,7 @@ These are made only when a workspace uses the feature behind them, so an instanc
|
||||
| Inbox vendor APIs (`api.inboxkit.com`, `api.zapmail.ai`, `api.mailforge.ai`, `api.infraforge.ai`, `api.maildoso.com`, `api.cheapinboxes.com`, `server.scaledmail.com`) | A workspace connects a vendor account, lists its mailboxes, imports them (each row's credentials are read as it connects), or has a vendor mailbox stopped on a connection error (checked every 15 minutes, at most once every 6 hours per mailbox). Also when the workspace opens its sending domains (the domain list of each active vendor account, at most once every five minutes per account), forwards a domain through its vendor, or has a tracking `CNAME` written there. Only that workspace's key is sent, to that vendor |
|
||||
| Google (`accounts.google.com`, `oauth2.googleapis.com`, `admin.googleapis.com`, `gmail.googleapis.com`) | A workspace creates, checks or uses a Google Workspace grant: the administrator's sign-in when that is how the domain is proved, token minting for the grant's addresses, the admin's directory entry and the domain's directory when picking mailboxes, and a Gmail profile read when a grant or mailbox is verified. Grants are re-checked hourly |
|
||||
| Microsoft (`login.microsoftonline.com`, `graph.microsoft.com`) | A workspace creates, checks or uses a Microsoft 365 grant: the administrator's consent sign-in, application token minting for the tenant, the organization's users, and a mailbox read when one connects. Grants are re-checked hourly |
|
||||
| DNS lookups | A workspace sets up a root redirect or a domain-wide tracking host, or proves a Google Workspace domain by DNS: `TXT`, address and `CNAME` lookups for that domain, through the host's resolver. Pending redirects are re-checked every 10 minutes, verified ones every 6 hours. The sending-domain authentication check (about once a day per domain, and on demand) reads SPF, DKIM and DMARC the same way, and when the host's resolver does not return a record it asks that domain's own nameservers directly on port 53 (never one on a private or loopback address) |
|
||||
| DNS lookups | A workspace sets up a root redirect or a domain-wide tracking host, or proves a Google Workspace domain by DNS: `TXT`, address and `CNAME` lookups for that domain, through the host's resolver. Pending redirects are re-checked every 10 minutes, verified ones every 6 hours. A redirect or form redirect to a website the workspace does not send from also reads the website's `_warmbly` `TXT` record, on save and on each check; a [confirmed website](/guides/sending-domains/#confirm-your-website) is kept in `website_domains` while the record stays published, read again every 6 hours, and deleted once the record is definitively gone or with the workspace. The sending-domain authentication check (about once a day per domain, and on demand) reads SPF, DKIM and DMARC the same way, and when the host's resolver does not return a record it asks that domain's own nameservers directly on port 53 (never one on a private or loopback address) |
|
||||
| The redirect's own domain | Once a root redirect's DNS verifies, the backend opens `http://<domain>/` and `https://<domain>/` like a visitor, without following it off the domain, to see whether the redirect answers. Only public addresses on ports 80 and 443 are opened. Repeated with the DNS check: every 10 minutes while visitors do not get the redirect (for two weeks after it verified), every 6 hours otherwise |
|
||||
| Warmbly Cloud (`api.warmbly.com`, or `WARMBLY_CLOUD_URL`) | A linked instance has a root redirect [served from Warmbly Cloud](/guides/sending-domains/#serve-it-from-warmbly-cloud): the domain, the website and the `www` setting, with the instance's link token, when it is saved, moved, checked or removed, and whenever the instance re-reads Cloud's verdict (on the same schedule as its own redirects) |
|
||||
|
||||
|
||||
@@ -237,6 +237,12 @@ does, and `deploy/config/env.example` for the bare-binary template). Saving a Go
|
||||
re-running the target recompiles in a second or two against the warm build
|
||||
cache.
|
||||
|
||||
The dev worker presents its own node credential, a published dev value that the
|
||||
seed fixtures register for its id, so it keeps working when you start the backend
|
||||
with `NODE_REQUIRE_NODE_CREDENTIAL=true` to try the strict mode. A second worker
|
||||
started with `make worker WORKER_ID=<uuid>` has no credential and needs that
|
||||
setting off. The dev consumer reads keys from Postgres and calls no node route.
|
||||
|
||||
### Tracking (Rust) and realtime (Elixir)
|
||||
|
||||
`make dev` runs both as containers; `make run` does not include them. The native
|
||||
|
||||
@@ -78,10 +78,32 @@ Warmup-only unknown sends have an automatic alternative to confirming the old ou
|
||||
|
||||
Retirement records `tasks.warmup_send_retired_at`, cancels execution permanently, preserves `send_result_state='unknown'`, and keeps all original reservation, charge, message ID, nonce, worker and result evidence. It neither refunds nor reconstructs charges, marks the message sent or failed, nor retries it. Late results cannot apply accounting, reauthorize the retired task or change a later task's hold. Other unresolved sends and conflict, authentication or permanent holds remain restrictive. The normal scheduler respects all existing warmup eligibility, cooldown and volume limits.
|
||||
|
||||
This recovery includes eligible historical holds after upgrade. Legacy sends without execution fencing, messages with confirmed receipt/provider evidence, and tasks with a definitive result or operator confirmation awaiting reconciliation are not retired. Campaign and other non-warmup sends keep the provider-confirmation-only policy below. No additional customer action or configuration is required for eligible warmup sends.
|
||||
This recovery includes eligible historical holds after upgrade. Legacy sends without execution fencing, messages with confirmed receipt/provider evidence, and tasks with a definitive result or operator confirmation awaiting reconciliation are not retired. Authorized campaign sends use the automatic isolation policy below. Other sends keep the provider-confirmation-only policy. No additional customer action or configuration is required for eligible warmup sends.
|
||||
|
||||
Apply migration 315 before running the updated backend, consumer and scheduler. Upgrade all control-plane replicas before relying on the new policy. An old replica may temporarily reassert a retired task's unknown hold; the updated scheduler repairs that hold without replaying the task or touching a newer restrictive hold. Whole-instance backups and organization send-history exports retain the retirement marker. The down migration refuses to remove recorded retirements; retain the schema and roll forward rather than discarding the replay fence.
|
||||
|
||||
#### Automatic campaign isolation
|
||||
|
||||
After ten minutes, the result-recovery loop isolates a durably authorized, started campaign send whose outcome remains unknown. It permanently cancels the original command and releases only its matching unknown mailbox hold. Other contacts can use the mailbox while the affected campaign contact waits for confirmation. The recovery pause is independent of manual or automatic lead pauses, and ordinary resume cannot clear it.
|
||||
|
||||
Isolation preserves the unknown outcome, original reservation, attempt history, and capacity charge. It never retries the uncertain email or infers failure from age or a missing Sent copy. A late definitive result is stored durably and applies the normal result effects once. That confirmed result removes the recovery pause while preserving an independent manual pause. A confirmed failure can permit a fresh task, but the original command remains permanently blocked.
|
||||
|
||||
Migration 331 adds task execution protection and a portable campaign-membership recovery timestamp. It shipped in v0.6.68 with isolation off, so that release already reads recovery pauses. From the release after it, `CAMPAIGN_SEND_ISOLATION_ENABLED` defaults to on and only `false` turns it off. Roll back no further than v0.6.68 once isolation has run. An instance upgrading straight from a release older than v0.6.68 should stop its old control-plane replicas before starting new ones (the default Compose upgrade does), or set the variable to `false` until the old replicas have drained. Customers do not need to change anything on the hosted service.
|
||||
|
||||
Database guards prevent replacement email reservations and executor starts, including alternate email branches. They cannot stop an older scheduler from executing a non-email action before writing progress, so activating while older replicas can run is unsupported. After activation, roll back only to a recovery-aware release and retain the expanded schema. No event or worker protocol changes are required. Self-hosts get the same recovery loop by default, with no cloud services.
|
||||
|
||||
The campaign-membership protection travels with **Campaigns**, even without **Send history**. Imported task execution handles reset, and uncertain commands remain blocked. If the source result history is omitted, the destination retains the contact's protection rather than assuming delivery. The down migration refuses to discard isolation history or pending contact protection. Retain the expanded schema during rollback.
|
||||
|
||||
#### Other held sends
|
||||
|
||||
The same result-recovery loop frees a mailbox held by a send that can never run again or never started:
|
||||
|
||||
- **Never started.** A campaign, Unibox or placement-test send reserved over 30 minutes ago with no executor start, attempt or result is released through the ordinary unstarted-release path under the send lock, so the worker's start check refuses it afterwards. A campaign step is handed back and sent as a fresh task.
|
||||
- **Started, outcome unknown.** A Unibox, placement-test or Warmbly Cloud send started over ten minutes ago gets `tasks.send_hold_lifted_at` (migrations 334 and 335) and stops holding its mailbox. It already cannot start a second time. Its unknown state, reservation, charge and attempt history are kept, and a late definitive result still applies once. A repeated unknown report does not hold the mailbox again.
|
||||
- **Gone.** An unknown hold whose task no longer exists is recomputed from the sends that are still unresolved. A hold left by an applied result stays until that result is resolved.
|
||||
|
||||
Campaign and warmup sends that started keep the isolation and retirement rules above. An older replica may re-hold a lifted send during a rolling upgrade or rollback; the loop lifts it again on its next pass and keeps the first lift time. One mailbox that cannot be recovered does not hold up the others. The down migration refuses to remove recorded lifts.
|
||||
|
||||
#### Provider-confirmed resolution
|
||||
|
||||
Unknown means the provider outcome is unproven, not that sending failed. Neither an expired timeout nor the absence of a synced Sent copy is proof that nothing was sent. Obtain explicit provider evidence for the exact task before using the mailbox PATCH:
|
||||
|
||||
@@ -79,6 +79,15 @@ That credential is `NODE_BROKER_TOKEN`, and it covers every internal route only
|
||||
|
||||
Upgrading a fleet that already sets `NODE_BROKER_TOKEN` needs no extra step. A node on an older release may still send `INTERNAL_API_TOKEN`; its heartbeat is answered with the version it should run and nothing else, so it updates itself and comes back on `NODE_BROKER_TOKEN`, which its join already wrote to `node.env`. Until then its sync lookups are refused for the few minutes the update takes. A worker stays live meanwhile, because its Redis heartbeat needs no token, so its mailboxes are not moved. A node joined before `NODE_BROKER_TOKEN` was set has no copy of it and is only ever told its version, which the backend logs with the node's id: join it again. To keep older nodes syncing through the upgrade, set `NODE_ACCEPT_INTERNAL_TOKEN=true` on the control plane first and remove it once every node has updated.
|
||||
|
||||
Each node also holds its own `NODE_CREDENTIAL`, issued at join, and sends it with its id next to `NODE_BROKER_TOKEN`; the control plane admits the call as that node. To stop accepting the shared token on these routes, in this order:
|
||||
|
||||
1. Deploy the backend release that checks node credentials. Nothing changes for any node yet.
|
||||
2. Let every node update to that release; the release sends the credential.
|
||||
3. Join again any node the backend still logs as `node heartbeats without its own node credential` (one that predates node credentials holds none). A re-join keeps the node's id and `node.local.env`.
|
||||
4. Once a full heartbeat interval passes with no such line, set `NODE_REQUIRE_NODE_CREDENTIAL=true` on the control plane and restart it. A node that is then refused shows as not live in the Fleet section; join it again, or unset the setting to restore the shared token at once.
|
||||
|
||||
A rollback of the backend to a release before this check simply ignores the credential headers, and a node rolled back to an older release sends only the shared token, so keep the setting off until no node can be rolled back that far.
|
||||
|
||||
## Building it
|
||||
|
||||
<Steps>
|
||||
@@ -253,6 +262,31 @@ A Pages deploy hook would reuse Cloudflare's build configuration too, but it bui
|
||||
|
||||
Projects deploy independently, not atomically: one failed build or upload leaves that project's previous deployment live and does not cancel the other projects. After fixing the configuration, use **Re-run failed jobs** on that release run to retry the same release commit without creating another tag or rebuilding successful jobs. Do not retry an older release after a newer one has deployed unless you intend a rollback. To pause release uploads, set `CLOUDFLARE_PAGES_DEPLOY_ENABLED` to `false`; this leaves current deployments live and does not re-enable Cloudflare's automatic deployments. This workflow deploys only the listed static frontends; it does not deploy backend services.
|
||||
|
||||
The marketing build generates a Content Security Policy in `site/dist/_headers`
|
||||
from the inline scripts in every rendered page, including the error page. Serve
|
||||
that header with the generated files when hosting outside Pages. Scripts require
|
||||
a build-generated hash or an allowed origin; inline event handlers and dynamic
|
||||
code evaluation are refused. Inline styles remain allowed for page presentation.
|
||||
The configured PostHog HTTPS origin and its regional asset host are allowed when
|
||||
analytics is enabled. Cloudflare's analytics beacon has its own explicit origin.
|
||||
Changes to scripts or analytics configuration require a fresh build. A policy
|
||||
that exceeds Pages' 2,000-character header limit fails the build.
|
||||
The policy reads analytics settings using Vite's resolved build mode and
|
||||
environment directory, including mode-specific environment files.
|
||||
|
||||
For a marketing-only update without a release tag, run **Deploy marketing Pages**
|
||||
on `main`, passing its reviewed full commit SHA as `expected_sha`. The manual
|
||||
workflow uses `site-production` and the existing Pages production variables. It
|
||||
requires exactly one `site` project in `CLOUDFLARE_PAGES_PROJECTS`, runs the site
|
||||
checks, and builds once. An isolated preview must serve the built CSP on the
|
||||
home, legal and error pages and preserve the published installer bytes before
|
||||
the same artifact is uploaded to the production branch. A failed preview leaves
|
||||
production unchanged. The workflow shares the release concurrency lock and
|
||||
deploys only the marketing site. The existing Pages deployment enable flag
|
||||
applies to this workflow too.
|
||||
Preview verification reads Wrangler's structured deployment receipt for that
|
||||
run and checks its project, environment and commit before requesting its URL.
|
||||
|
||||
## Anything the control plane cannot know
|
||||
|
||||
`warmbly join` writes `/etc/warmbly/node.env` from the control plane's answer and rewrites it on every join. Next to it, `/etc/warmbly/node.local.env` is created once and never written again, and the container reads it second, so a name repeated there wins.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Warmup diagnostic content generation
|
||||
description: Effective generation policy, stopping new jobs, batch draining and versioned diagnostic content.
|
||||
title: Warmup content generation
|
||||
description: Where warmup conversations come from, how they rotate, generation controls and batch draining.
|
||||
---
|
||||
|
||||
Warmup content is an explicitly simulated diagnostic exchange for consenting test mailboxes. It is not a customer conversation or evidence of inbox placement, authentication, improved reputation or human engagement. Hypothetical facts and closure must remain consistent across every rendered turn.
|
||||
Warmup mail is a plain-text thread between two pool mailboxes that reads like ordinary correspondence between people who know each other loosely. It never says or hints that it is automated, generated, a test or a warmup. Content comes from two sources that rotate together: a hand-written library of about seventy threads that ships with the application, and an optional bank of AI-generated threads that grows with demand. Neither is evidence of inbox placement, authentication, improved reputation or human engagement.
|
||||
|
||||
## Effective policy and stopping
|
||||
|
||||
@@ -14,19 +14,19 @@ In **Admin > Warmup content > Overview**, the effective settings editor shows th
|
||||
| Setting | Default for an absent field | Supported behavior |
|
||||
| --- | --- | --- |
|
||||
| `generation_enabled` | `true` | `false` prevents new persisted generation-job reservations. It does not delete credentials or disable cached-content use. |
|
||||
| `enabled` | `true` | Controls selection of cached AI content separately from generation. |
|
||||
| `enabled` | `true` | Admits approved AI threads to selection. When false, new threads use only the built-in library. |
|
||||
| `schedule_enabled` | `true` | Enables scheduled runs; the generation stop takes precedence. |
|
||||
| `cadence_hours` | `6` | Integer from 1 to 168. |
|
||||
| `refresh_enabled` | `true` | Permits scheduled retirement and replacement. |
|
||||
| `refresh_enabled` | `false` | Preserves usable stock by default; explicit saved settings remain effective. Permits replacement of unused stock. Reserved plans stay readable for replies. |
|
||||
| `refresh_per_run` | `10` | Integer from 0 to 25; zero means no refresh retirement. |
|
||||
| `daily_generation_cap` | `1000` | Non-negative; zero retains the existing unlimited policy. Counts reserved requests, including unfinished, rejected or cancelled work, so concurrent replicas cannot overspend by counting only approved output. Resets at the UTC day boundary. |
|
||||
| `ai_selection_share` | `70` | Integer percentage from 0 to 100; zero selects no AI openings. |
|
||||
| `ai_selection_share` | `100` | Legacy setting retained and round-tripped for rollback. Selection no longer rolls a share; AI and library threads compete on recency and use. |
|
||||
| `model` | Existing default `gpt-6-luna` | A stored non-empty model is retained, not replaced. Availability is provider-checked before submission; the default is not a claim of availability. |
|
||||
| `max_messages_per_thread` | `5` | Integer from 1 to 5 ordered replies. |
|
||||
| `pools` | One enabled `premium` library with target 200 and the generic segment | Content is shared across mailbox tiers. Legacy multi-pool settings collapse to one canonical library, preferring an enabled entry. Its enabled flag, target from 1 to 5000 and distinct trimmed segments survive. |
|
||||
| `engagement` | Existing engagement defaults | Percentages clamp to 0 to 100; dwell bounds clamp to 0 to 3600 seconds with maximum at least minimum. These controls do not constitute consent or evidence of engagement. |
|
||||
|
||||
Targets are configured floors; demand-based sizing may increase them, bounded at 5000. The scheduler also maintains the generic fallback segment. Supported values round-trip; out-of-range values clamp to the documented bounds. A backend that predates these controls must be upgraded before the admin editor is available.
|
||||
Selection draws, for each new thread, the conversation neither mailbox has seen within the last 30 days in either role. Among those it prefers the mailbox's segment, then a thread neither has ever seen, then the least used, with a random tie-break. When a pair has seen everything recently, it repeats the thread they saw longest ago rather than waiting, so warmup never stops for lack of content. Generation targets count only AI threads and use a conservative lower bound: approved threads minus the two largest active-mailbox exposure counts within the same 30 days, clamped at zero. The scheduler raises configured target floors with the busiest mailbox's average daily send and receive demand over the preceding seven days, rounded up and bounded at 5000. Demand counts distinct conversation IDs from retained warmup tokens in both roles, so replies do not multiply it. The scheduler also maintains the generic fallback segment. Supported values round-trip; out-of-range values clamp to the documented bounds.
|
||||
|
||||
## Outstanding batches and capability
|
||||
|
||||
@@ -36,23 +36,33 @@ The provider must expose the configured model to the configured client. Model vi
|
||||
|
||||
## Rendering, review and old data
|
||||
|
||||
New scenario and rendering provenance are `diagnostic-v1` and `canonical-v1`. New jobs retain the requested reply count, so a later settings change does not reinterpret accepted output. Ordered body text, hypothetical numbers, dates, negation, promises and subject are immutable; there is no spintax, random appended question or body humanization. Rendered turns include truthful diagnostic disclosure and the sender identity. New generated content must pass structural checks and a semantic review of the complete rendered thread before activation.
|
||||
New threads carry scenario version `natural-v1` and rendering version `canonical-v1`. New jobs retain the requested reply count, so a later settings change does not reinterpret accepted output. Each generation request draws a topic plus a tone, an opening approach and a length, so threads on the same topic still differ in voice, structure and size. Turns may open with a short greeting and close with a sign-off line; rendering appends only the actual sender name, directly under a sign-off when there is one. Body text and subjects are immutable once approved; there is no spintax or random appended question.
|
||||
|
||||
Review states distinguish `passed`, `rejected`, `unavailable`, `unreviewed`, `legacy_unknown` and `legacy_unreviewed`. An unavailable judge is not approval. Rejected or unavailable newly generated conversations stay archived and cannot be activated through the status control. Existing stored conversations and their IDs are not replaced or relabeled as reviewed; their missing historical evidence is `legacy_unknown`. Existing provider job IDs remain pollable. Unversioned old-job output is retained archived as `legacy_unreviewed`, without claiming it meets the new contract.
|
||||
Every outgoing turn, opening, reply or queued execution, is refused when it describes itself as simulated, diagnostic, hypothetical, fictional, automated, generated, a test message or a warmup. Generation rejects the same wording, and so does the semantic review. Threads from the retired `diagnostic-v1` content stop at their next reply and the mailbox resumes its schedule with new content; stored subjects and bodies are never rewritten. Replies stay bound to the exact selected thread. A transaction records both participants before dispatch, and retries of the same task return the original thread without consuming another use. Those records survive task and token cleanup until the conversation or mailbox is deleted; a database trigger records both participants when a warmup token is deleted or reassigned, so history from before this table existed is kept without a deployment-time backfill. Duplicate subjects or openings, ignoring case and whitespace, are rejected within a batch and against approved content, including the built-in library. Approved inserts serialize under a database transaction lock, so concurrent batches cannot admit identical content. This is not a guarantee of semantic uniqueness.
|
||||
|
||||
Vetted static scenarios use a new stable UUID namespace; historical static source IDs must never be remapped to unrelated scenarios. Exact-parent continuation, exhaustion and missing/retired source handling are required at the live dispatch integration boundary.
|
||||
Review states distinguish `passed`, `rejected`, `unavailable`, `unreviewed`, `legacy_unknown` and `legacy_unreviewed`. TypeSafe reviews the full rendered thread when configured. Otherwise a separate OpenAI request reviews it using the job’s configured model. Both paths require a coherent closed thread that reads as ordinary mail, with no pitch, no self-description as generated or a warmup, no real names, prices or exact dates, and a confidence of at least 0.70. Missing or invalid verdict fields are not approval. An unavailable judge is not approval. Rejected or unavailable newly generated conversations stay archived and cannot be activated through the status control. Existing stored conversations and their IDs are not replaced or relabeled as reviewed; their missing historical evidence is `legacy_unknown`. Existing provider job IDs remain pollable. Unversioned old-job output is retained archived as `legacy_unreviewed`, without claiming it meets the new contract. Output from a batch queued under `diagnostic-v1` is still reviewed and, because of its wording, retained archived as `rejected`; its original text and IDs remain intact.
|
||||
|
||||
The built-in library lives in code. Each thread's ID is derived from its theme and opening, so an edited thread gets a new ID and threads already in flight on the old one close at their next reply. The backend mirrors the library into the conversation bank as `static` rows the first time it picks content, so library threads share the same rotation and per-mailbox records as AI threads. Only rows matching the running release's library are selectable, and an admin who archives a library row keeps it archived.
|
||||
|
||||
Live continuation binds the exact task, token, recipient receipt and received Message-ID to the provider-reported sent Message-ID. It preserves subject, immutable source/version, ordered References and the original maximum of one opening plus the requested one to five replies, including the final closure. One parent has at most one successor. An unrelated mailbox pair, an expired/retired token or unversioned legacy lineage cannot substitute for that parent. Trusted configured display names, including Unicode and punctuation, remain intact in plaintext signatures and MIME headers; CR/LF/NUL are rejected.
|
||||
|
||||
This application-owned correspondence proof is not itself cryptographic authentication. Updated protocol-2 Gmail/Graph workers can additionally retrieve one exact authorized warmup diagnostic's bounded MIME and verify DKIM cryptographically. IMAP, legacy workers, unrelated seed/placement contexts, unavailable MIME and transient key lookup remain unknown. Copied `Authentication-Results` remains unverified metadata; SPF, DMARC and receiving-hop TLS remain unknown absent independent evidence. See [actual-message authentication and limits](/development/send-safety/#actual-message-authentication). DNS discovery and prose cannot establish pass. Received text and model output do not authorize recipients, permissions or actions.
|
||||
|
||||
The vetted fallback bank includes eight small causal scenarios: the original fictional clock and sample-count examples, hypothetical document review, summary correction, fixed-offset date/time continuity, plaintext label review, conditional wording and a Hungarian summary. Each preserves its own facts, alternating sender identities and explicit closure. The Hungarian body retains the same English subject-prefix and per-turn diagnostic disclosure; it does not change language controls or translate existing scenarios. Existing scenario IDs and text are immutable; a revised scenario needs a new versioned ID.
|
||||
## Operation and compatibility
|
||||
|
||||
These examples review hypothetical wording, not customer documents, relationships or real actions. The plaintext example uses application-constructed written labels; it does not claim an email client passed an accessibility test. A scenario saying a check is complete does not establish a provider result, authentication pass or delivery outcome. Genuine diagnostic facts must come from separately verified, application-owned observations, never from generated prose.
|
||||
AI generation needs `AI_API_KEY` with `AI_PROVIDER=openai` or the provider unset. Other assistant providers do not implement this OpenAI Batch generator. `TYPESAFE_API_KEY` is optional for warmup review. Without AI credentials, warmup runs on the built-in library alone; nothing else is required.
|
||||
|
||||
Generation and polling remain automatic. Batches can take up to 24 hours; OpenAI review without TypeSafe adds one separate completion per reviewed thread. Adjust the daily generation cap to expected pool replenishment after reuse, and include review usage in the provider budget. Failed submissions are recorded as job failures and retry on the next scheduler tick rather than consuming a successful six-hour cadence. A generation outage never pauses sending: selection falls back to the library and to the least recently seen threads.
|
||||
|
||||
The supported rollback window includes the immediately preceding application release. This change keeps `diagnostic-v1`, `canonical-v1`, the existing JSON shape and database rows readable. Migration `000332` adds the per-mailbox record table and its token trigger without changing existing rows or stored bodies; retain it during rollback. The preceding release never selects `natural-v1` rows, so a rollback returns to its own content, and threads it cannot resolve close at their next reply. During a mixed-version rollout an older poller rejects output from a `natural-v1` job it did not submit, so pause scheduled generation until every backend is upgraded. Pause warmup dispatch too, as described in the upgrade order below. Keep provider credentials while batches drain.
|
||||
|
||||
## Self-host upgrade
|
||||
|
||||
Nothing to do. The built-in library is available as soon as the new backend runs, with or without an AI provider, and existing `enabled` and `schedule_enabled` settings keep their meaning. No stored conversation or credential is deleted.
|
||||
|
||||
## Upgrade order
|
||||
|
||||
Apply the additive content-provenance migration before starting the new backend. Deploy every backend instance before relying on `generation_enabled=false`; mixed old backends do not honor the new stop or resolve the new static scenario namespace. Pause warmup dispatch through existing controls during a mixed-version rollout, and resume only after all control-plane replicas understand exact-parent resolution. Deploy the matching admin frontend after the backend. Keep provider credentials while existing jobs drain. No migration replaces saved models, existing job IDs, source IDs or customer credentials, and no live efficacy claim follows from local tests.
|
||||
Apply the additive content-provenance and participant-reservation migrations before starting the new backend. Deploy every backend instance before relying on `generation_enabled=false`; mixed old backends do not honor the new stop or resolve the new library IDs. Pause warmup dispatch through existing controls during a mixed-version rollout, and resume only after all control-plane replicas understand exact-parent resolution. Deploy the matching admin frontend after the backend. Keep provider credentials while existing jobs drain. No migration replaces saved models, existing job IDs, source IDs or customer credentials, and no live efficacy claim follows from local tests.
|
||||
|
||||
For the integrated release, preserve released migrations through 265 and main's workspace-link migration 266, then apply additive migrations 267 through 274 in order. Upgrade all result consumers and control-plane replicas, then execution workers. New shared dispatch requires an active worker reporting `warmup_send_protocol=2`; protocol 1 remains only its earlier lineage capability. Duplicate commands replay a durable terminal result rather than executing another native send. An unresolved native outcome holds the mailbox until reconciliation, not a timed blind reset. Known legacy throttle codes produce a conservative mailbox/provider cooldown without fabricated HTTP/SMTP evidence. Authentication, permanent and conflict holds need confirmed repair/operator evidence, not elapsed time or an unrelated success.
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ These preferences are yours alone, kept in your browser for each workspace.
|
||||
|
||||
It knows what page you are on, so "summarize this campaign" and "draft a reply here" resolve correctly.
|
||||
|
||||
When the available tools exceed the OpenAI-compatible provider's 128-tool limit, Remie discovers the tools it needs on demand, including tools from connected MCP servers. No permitted capability is removed. Discovery is a read-only step; the action itself keeps its normal permissions and approval requirements. Like other model steps, discovery counts toward the run's step budget and AI credits.
|
||||
When the available tools exceed the OpenAI-compatible provider's 128-tool limit, Remie discovers the tools it needs on demand, including tools from connected MCP servers. Discovery results include each tool's argument schema, so its usage remains available in the conversation after another search. No permitted capability is removed. Discovery is a read-only step; the action itself keeps its normal permissions and approval requirements. Like other model steps, discovery counts toward the run's step budget and AI credits.
|
||||
|
||||
</Fold>
|
||||
|
||||
@@ -149,8 +149,8 @@ Settings > Workspace > Remie lists every action that is always allowed, who allo
|
||||
|
||||
## Credits and privacy
|
||||
|
||||
Each step costs one AI credit, and a request is capped at a set number of steps (shown as the run progresses) so nothing runs away. Remaining credits show at the panel's bottom, and the stop button ends a run anytime. On a self-hosted install with a free or local model, runs are not charged and a "free model" notice appears.
|
||||
Each model turn costs one AI credit, and a run is capped at 20 model turns between approval pauses. A turn can call several tools, so the activity list can show more than 20 tool steps. Remie reserves the last turn for an answer from the evidence already gathered, without calling more tools. If it cannot verify the answer, it is instructed to explain what remains unknown and what to check next. An empty provider answer is reported as an error. Remaining credits show at the panel's bottom, and the stop button ends a run anytime. On a self-hosted install with a free or local model, runs are not charged and a "free model" notice appears.
|
||||
|
||||
Changes Remie makes (a created task, an updated contact) appear in the shared activity feed like any other edit, so teammates' views stay current.
|
||||
Completed tool steps stay in the conversation history if a later provider call fails or you stop the run. Remie gives recording those steps and refunding a failed model turn up to five seconds to finish after cancellation. Changes Remie makes (a created task, an updated contact) appear in the shared activity feed like any other edit, so teammates' views stay current.
|
||||
|
||||
</Fold>
|
||||
|
||||
@@ -217,7 +217,7 @@ These records back the engagement rows on a contact's [activity timeline](/guide
|
||||
| Warmup status | Whether warmup is on, actual volume today, the target the scheduler is using, max volume, configured reply target, and elapsed warmup days |
|
||||
| Warmup health | Pool standing: healthy, watch, throttled, quarantined, or blocked, with the score and reason the band decided, and the block expiry |
|
||||
|
||||
The overview calls the configured percentage **Reply target** because it controls how much synthetic warmup mail should receive a reply. The Analytics tab reports the measured reply rate from actual sends and replies. Its **Target met** percentage is actual warmup sends divided by planned target volume across the active days in the selected range; it can exceed 100% when volume beats the plan.
|
||||
The overview calls the configured percentage **Reply target**. It controls the chance that the mailbox answers an eligible incoming warmup message, rather than guaranteeing a fixed measured percentage. The Analytics tab's warmup reply rate is warmup replies sent by the mailbox divided by all its warmup sends in the selected range. It does not measure how many of the mailbox's outgoing messages received an answer. Its **Target met** percentage is actual warmup sends divided by planned target volume across the active days in the selected range; it can exceed 100% when volume beats the plan.
|
||||
|
||||
Use this to find the one mailbox dragging down a campaign's bounce rate instead of blaming the campaign.
|
||||
|
||||
|
||||
@@ -124,7 +124,9 @@ The chart draws one bar per day for campaigns up to about three months long and
|
||||
|
||||
Follow-ups that are due go out before new leads start, and the total assumes nobody replies or unsubscribes, so real sequences usually finish sooner. Replies, bounces, new contacts joining a linked segment and changes to a mailbox's health all move the real finish.
|
||||
|
||||
An unresolved send from one mailbox does not stop other healthy mailboxes from sending. A follow-up normally uses the address its lead first heard from, but can move to another eligible mailbox when that address is held or cooling. The launch plan and day plan show the hold or cooldown separately from the normal daily limit. An unknown send needs [provider-confirmed resolution](/development/send-safety/#resolving-an-unknown-send); a timeout or missing Sent copy is not proof that it can be retried.
|
||||
An unresolved send from one mailbox does not stop other healthy mailboxes from sending. A follow-up normally uses the address its lead first heard from, but can move to another eligible mailbox when that address is held or cooling. The launch plan and day plan show the hold or cooldown separately from the normal daily limit.
|
||||
|
||||
After ten minutes Warmbly isolates an authorized campaign send whose outcome is still unknown. The mailbox can send to other contacts again. Only the affected contact waits for confirmation, independently of any manual pause. No customer action is needed, and the uncertain email is never retried. A late confirmed result updates the contact automatically. A timeout or missing Sent copy never counts as proof of failure. A send the worker never started is handed back after 30 minutes and the step is sent fresh, because it provably never left. Legacy sends without durable execution authorization still require [provider-confirmed resolution](/development/send-safety/#resolving-an-unknown-send).
|
||||
|
||||
</Fold>
|
||||
|
||||
@@ -285,7 +287,7 @@ A lead is **Processing** only while steps remain, so a finished campaign reads a
|
||||
|
||||
When a recipient's mailbox answers a step with an away message, that is not a reply: Warmbly never counts an auto-reply as a human one, so stop on reply does not fire and, left alone, the next step would go out on schedule to an empty desk. Warmbly holds the lead instead, in every campaign that contact is still a lead of rather than only the one that was answered. An empty desk is an empty desk, so a contact you are running two sequences to is held in both. Completed campaigns are left alone, since nothing in them will send again.
|
||||
|
||||
The hold reads the return date out of the away message when it can. English, German, French, Spanish, Portuguese, Italian and Dutch phrasings are recognised (`back on 8 September`, `zurück am 09.09.2026`, `ab dem 10.9.`, `jusqu'au 12 septembre`), in ISO and day-dot-month form as well as written months. German calendar weeks count too: `ab KW 42` resumes from that week's Monday, `bis KW 41` from the Monday after it. Two kinds of date are deliberately not read, because a wrong one parks a live lead for weeks: slash dates, since `9/8/2026` means two different days on two sides of the Atlantic, and a month with no day (`until October`), since there is no way to tell which day in it was meant. The lead resumes one working day after the date it found, so the follow-up does not land in the backlog of their first morning back. When no date can be read, the hold is the workspace's fallback, `7` days by default, set under **Settings > Sending > Out of office**. The same section turns the whole behaviour off.
|
||||
The hold reads the return date out of the away message when it can. English, German, French, Spanish, Portuguese, Italian and Dutch phrasings are recognised (`back on 8 September`, `zurück am 09.09.2026`, `ab dem 10.9.`, `jusqu'au 12 septembre`), in ISO and day-dot-month form as well as written months. Swedish, Danish, Norwegian, Finnish, Polish and Czech phrasings are read too when the workspace adds those [tagging languages](/guides/inbox-tagging/#tagging-languages) (`tillbaka den 14 september`, `til og med 18. september`, `palaan 14.9.`, `wracam 14 września`, `budu zpět 14. září`). German calendar weeks count too: `ab KW 42` resumes from that week's Monday, `bis KW 41` from the Monday after it. Two kinds of date are deliberately not read, because a wrong one parks a live lead for weeks: slash dates, since `9/8/2026` means two different days on two sides of the Atlantic, and a month with no day (`until October`), since there is no way to tell which day in it was meant. The lead resumes one working day after the date it found, so the follow-up does not land in the backlog of their first morning back. When no date can be read, the hold is the workspace's fallback, `7` days by default, set under **Settings > Sending > Out of office**. The same section turns the whole behaviour off.
|
||||
|
||||
With [automatic inbox tagging](/guides/inbox-tagging/#confirming-an-away-messages-return-date) on, the date gets a second reading. The phrase it came from is shown to the classifier, which is asked whether it says when the sender is back. When the answer is a clear no (the date is the first day of the absence, or a stand-in's hours), the hold uses the fallback instead, and the lead's reason reads `auto-reply, return date unclear`. An unsure answer, or a failed call, leaves the date as read.
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ The **Design** tab styles the form while the canvas updates live. The defaults a
|
||||
|
||||
The **Settings** tab controls what a submission does:
|
||||
|
||||
- **Success message** is shown after submitting, or set a **redirect URL** to send the visitor to your own thank-you page instead. The page has to be on one of your workspace's own domains: a domain you have a mailbox on (not a shared provider such as `gmail.com`), a verified tracking domain, your verified [custom forms domain](#custom-domain), or a subdomain of one of them. Any other address is refused with `redirect_target_not_own_domain`. If a saved page stops qualifying, for example after the last mailbox on its domain is removed, the setting is kept and marked **Not in use**, and visitors see the success message until you change it.
|
||||
- **Success message** is shown after submitting, or set a **redirect URL** to send the visitor to your own thank-you page instead. The page has to be on one of your workspace's own domains: a domain you have a mailbox on (not a shared provider such as `gmail.com`), a verified tracking domain, your verified [custom forms domain](#custom-domain), a website you [confirmed](/guides/sending-domains/#confirm-your-website), or a subdomain of one of them. Any other address is refused with `redirect_target_not_own_domain`; if the page is on your main website, saving checks for its confirmation record first, so publishing that record is enough. If a saved page stops qualifying, for example after the last mailbox on its domain is removed, the setting is kept and marked **Not in use**, and visitors see the success message until you change it.
|
||||
- **Add to labels** puts the labels you pick on every submitted contact, for example "Website leads".
|
||||
- **Add to campaign** enrolls new contacts as leads in the campaign you pick. Sending still follows the campaign's own schedule, limits and windows; a form never causes immediate mail. Picking a campaign turns on its **Keep running for new leads** setting, so it waits between submissions instead of finishing; a campaign that had already finished restarts when a lead arrives, through the usual launch checks, and a refused restart is noted in its activity log while the lead waits.
|
||||
- **Spam protection** and **allowed embed domains** are covered below.
|
||||
|
||||
@@ -28,10 +28,11 @@ The agent does not start new conversations and never messages a new recipient. I
|
||||
|
||||
## Reviewing a draft
|
||||
|
||||
A new draft shows up two ways:
|
||||
A new draft appears in three places:
|
||||
|
||||
- In the conversation itself: open the thread in the unibox and the draft appears below the messages, in an editable box, with **Approve and send**, and **Discard**.
|
||||
- In the scope rail: the **Agent drafts** filter lists every conversation with a draft waiting, with a live count next to it. The count and list update the moment a new draft lands, no refresh needed.
|
||||
- In the **Drafts** folder: the same conversations are listed first, under **Agent drafts**, above the drafts saved in your mailboxes, and the Drafts count includes them.
|
||||
|
||||
From the draft box you can:
|
||||
|
||||
|
||||
@@ -233,7 +233,8 @@ The reading before any call covers:
|
||||
- **Quoted history**, cut from a reply so the classifier reads what the person wrote and not your own message quoted under it: the reply line each mail client writes ("Den ... skrev", "W dniu ... pisze:", "于 ... 写道:" and the like), Outlook's quoted `From: / Sent:` block in that language (`Von: / Gesendet:`, `De : / Envoyé :`, `差出人: / 送信日時:`), and the dashed "Original message" and "Forwarded message" lines.
|
||||
- **Out-of-office replies**, recognized by the subject their mail provider writes (`Автоматический ответ`, `自動応答`, `자동 회신`, `رد تلقائي` and so on) and decided with no call at all.
|
||||
- **Non-delivery notices**, by the subject Exchange writes in Spanish, Italian, Dutch and Portuguese. A notice carrying a delivery-status report is recognized in any language without this.
|
||||
- **Replies that say no**, in German, French, Spanish, Dutch, Italian and Portuguese: a declined interest ("kein Interesse", "pas intéressé", "no me interesa", "geen interesse", "non sono interessato", "não tenho interesse") or another clear no ("nein danke", "non merci", "no gracias", "nee bedankt", "no grazie", "não, obrigado", "falscher Ansprechpartner", "persona sbagliata"). Each phrase is matched as whole words, so "no grazie" never matches inside "buono, grazie". The reply classifier reads these as negative with no call, the same verdict "not interested" and "no thanks" get in English, so they take the `reply_negative` branch. Inbox labels still come from the classifier. Phrases of interest are read in English only for now.
|
||||
- **Replies that say no**, in German, French, Spanish, Dutch, Italian and Portuguese: a declined interest ("kein Interesse", "pas intéressé", "no me interesa", "geen interesse", "non sono interessato", "não tenho interesse") or another clear no ("nein danke", "non merci", "no gracias", "nee bedankt", "no grazie", "não, obrigado", "falscher Ansprechpartner", "persona sbagliata"). Each phrase is matched as whole words, so "no grazie" never matches inside "buono, grazie". The reply classifier reads these as negative with no call, the same verdict "not interested" and "no thanks" get in English, so they take the `reply_negative` branch. Inbox labels still come from the classifier.
|
||||
- **Replies that show interest**, in German, French and Spanish ("klingt gut", "lassen Sie uns telefonieren", "ça m'intéresse", "je suis intéressé", "me interesa mucho", "agendemos una llamada"), read as positive with no call, the same verdict "interested" and "let's talk" get in English, so they take the `reply_positive` branch and count as interested leads. A reply that also says no in one of these languages ("klingt gut, aber kein Bedarf") stays negative, and a phrase in a sentence that already says "no", "nicht", "pas" and the like ("no me interesa mucho", "je ne crois pas, honnêtement, que cela nous intéresse") does not count, nor does one taken back later by "pero no", "aber nicht", "mais pas" and the like ("me interesa mucho, pero no ahora"). Conditional interest such as "Si cela m'intéresse, je vous contacterai", "S’il s’avère que cela nous intéresse, nous vous recontacterons" or "Si me interesa mucho, les aviso" stays inconclusive. The accented Spanish affirmation "Sí, nos interesa mucho" reads as positive. Polite French requests beginning with "s’il vous plaît" or "s’il te plaît" still count as requests. French interest followed by "vraiment pas" or "absolument pas" does not count as positive, including with Unicode whitespace; "pas mal" keeps its affirmative meaning. A request with a qualifier, such as "Envoyez-moi une offre pas trop chère", remains positive.
|
||||
|
||||
Tagging languages are part of the workspace settings, so they travel with a [workspace export](/guides/workspace-export-import/).
|
||||
|
||||
|
||||
@@ -640,13 +640,13 @@ This is not the same as the risk band that decides which sending worker and IP h
|
||||
|
||||
Each Cloud mailbox uses its own current health report. A missing report shows **Unavailable** for that mailbox while other mailboxes keep their reported readings. Summary counts remain unavailable until every listed mailbox has a current status.
|
||||
|
||||
The Accounts list groups mailboxes as **Healthy** (sending normally), **Warming** (ramping through warmup), or **Needs attention** (paused, failing, or not sending). Each row shows the mailbox with how it connects and its tags, a **Status** that says what it is doing (**Sending**, **Warming**, **Active** when it does both, **Resting**, or **Idle**, and **Error**, **Off** or **Reconnect** when something stops it), campaign emails sent today against its cap, warmup sent today against the ramp target, the inbox rate, and the health score. Hover a status for the reason, and click any column header to sort. A drop in health between refreshes notifies you rather than waiting to be noticed.
|
||||
The Accounts list groups mailboxes as **Healthy** (sending normally), **Warming** (ramping through warmup), or **Needs attention** (paused, failing, or not sending). Each row shows the mailbox with how it connects and its tags, a **Status** that says what it is doing (**Sending**, **Warming**, **Active** when it does both, **Resting**, or **Idle**, and **Error**, **Off** or **Reconnect** when something stops it, or **Retrying** in amber while a warning such as a dropped connection is being retried on its own), campaign emails sent today against its cap, warmup sent today against the ramp target, the inbox rate, and the health score. Hover a status for the reason, and click any column header to sort. A drop in health between refreshes notifies you rather than waiting to be noticed.
|
||||
|
||||
Repeated reports of the same error code count once toward the health score, at their highest unresolved severity, rather than making one problem look like several. The drawer groups identical reports while keeping different error details and sending versus sync failures separate. Connection titles name Gmail, Microsoft Outlook or the mail server. **Reported** shows the stored report time: connection and temporary provider-limit observations refresh it, while other error categories may retain their original report time. It is not proof of an ongoing outage.
|
||||
|
||||
A later completed sync automatically clears earlier temporary sync errors. A provider-confirmed send clears earlier temporary sending errors, including provider throttling and quota warnings. Recovered reports no longer appear under **Needs attention** or reduce the health score. Older reports that do not identify which operation failed clear once both sending and sync have succeeded after the report; existing reports with that evidence are cleared on upgrade too. A newer failure remains visible, and simply waiting or completing a queued task does not count as recovery. Recoverable connection failures retry automatically while the mailbox is on; a connection warning alone is not a reason to reconnect. Authentication, credential and policy errors retain their own instructions, and a switched-off mailbox must be switched back on before it can retry.
|
||||
A later completed sync automatically clears earlier temporary sync errors. A provider-confirmed send clears earlier temporary sending errors, including provider throttling and quota warnings. Recovered reports no longer appear under **Needs attention** or reduce the health score. Older reports that do not identify which operation failed clear once both sending and sync have succeeded after the report; existing reports with that evidence are cleared on upgrade too. A newer failure remains visible, and simply waiting or completing a queued task does not count as recovery. Recoverable connection failures retry automatically while the mailbox is on; a connection warning alone is not a reason to reconnect. A temporary connection, server or throttling failure is not shown at all while the affected sync or sending has still succeeded within the last two hours, because the mailbox is working. It appears only when the failure lasts longer than that. Authentication, credential and policy errors retain their own instructions, and a switched-off mailbox must be switched back on before it can retry.
|
||||
|
||||
A send safety hold is different from a retryable connection failure. If Warmbly cannot confirm whether the provider accepted a message, sending pauses to avoid retrying a message that might already have been sent. The mailbox is shown as needing attention even without a separate connection warning, and its health details explain the hold. A successful inbox sync does not confirm a send. Campaign and other non-warmup sends still require provider-confirmed resolution. See [send safety](/development/send-safety/).
|
||||
A send safety hold is different from a retryable connection failure. If Warmbly cannot confirm whether the provider accepted a message, sending pauses to avoid retrying a message that might already have been sent. The mailbox is shown as needing attention even without a separate connection warning, and its health details explain the hold. A successful inbox sync does not confirm a send. The hold clears on its own and no customer action is needed. After ten minutes Warmbly sets the uncertain email aside for good: a campaign email waits for confirmation for that one contact while the mailbox sends to everyone else, and a Unibox, placement-test or Warmbly Cloud send simply never runs again. A send that never reached the worker is handed back after 30 minutes so the step can go out fresh. A late confirmed result still updates the email automatically. Only legacy sends without durable execution authorization need provider-confirmed resolution. See [send safety](/development/send-safety/).
|
||||
|
||||
Warmup scheduling automatically retires abandoned preparation tasks after ten minutes only when they have no generated message ID, verification token, reservation, dispatch or execution evidence. The normal scheduler can then continue with a new task. Tasks that might have sent a message remain protected; they are not retried just because they are old.
|
||||
|
||||
|
||||
@@ -65,7 +65,23 @@ A first sign-in with a new address via Google or Apple creates your account, wor
|
||||
|
||||
If the address already has a Warmbly account with a password, the first Google, Apple or single sign-on with it asks for that password before the provider is attached to the account. The provider confirms the address is yours; the password confirms the account is. Once linked, later sign-ins with that provider go straight through. An account that never set a password (created through a provider or an invitation) is linked on the first sign-in.
|
||||
|
||||
Accounts created through an external sign-in provider have no password initially. Trying password sign-in returns the same invalid-credentials response as an incorrect password. Continue with your provider, or use **Forgot password** to set a password before signing in with it. A reset link works once and only for the password it was requested against: changing your password by any route, including using another reset link, makes every earlier link invalid before it expires.
|
||||
Accounts created through an external sign-in provider have no password initially. Trying password sign-in returns the same invalid-credentials response as an incorrect password. Continue with your provider, or set a password: while signed in, open **Settings > Security** and choose **Email me a link** under **Password**, or use **Forgot password** on the sign-in page. A reset link works once and only for the password it was requested against: changing your password by any route, including using another reset link, makes every earlier link invalid before it expires.
|
||||
|
||||
### Move from Google or Apple sign-in to email sign-in
|
||||
|
||||
To stop using a provider (for example when an Apple ID or a Google Workspace account is being retired) while keeping the same Warmbly account, workspaces, roles and plan:
|
||||
|
||||
1. While you can still sign in, open **Settings > Security** and choose **Email me a link** under **Password**. The link goes to the email address on your account.
|
||||
2. Open the link within one hour and choose a password. This signs out every device.
|
||||
3. Sign in with your email and the new password. Warmbly can also email a 6-digit code to that address, for example when you sign in on a new device.
|
||||
4. Optionally add a passkey or turn on two-factor authentication on the same page.
|
||||
5. Under **Sign-in methods**, choose **Remove** next to the provider. Warmbly asks you to confirm it is you first, refuses if the provider is still your only way in, and signs out every other device that signed in with it.
|
||||
|
||||
Warmbly never removes your last way in. A provider or passkey can only be removed while a password, another passkey or another provider remains.
|
||||
|
||||
The address on the account does not change, so it must keep receiving mail (a forward is fine): sign-in codes and password reset links are sent there. If you signed up with Apple's **Hide My Email**, the address is an `@privaterelay.appleid.com` relay that only forwards while Warmbly stays connected to your Apple ID, so do not disconnect Warmbly on Apple's side. With any other address, you can also disconnect Warmbly in your Apple ID or Google account settings after removing the provider here.
|
||||
|
||||
Signing in to Warmbly is separate from any Gmail, Workspace or iCloud mailbox you connected for sending; removing a sign-in method does not affect it, and retiring that mailbox affects its sending and sync, not your sign-in. See [mailboxes](/guides/mailboxes/).
|
||||
|
||||
<Callout type="info" title="Passwordless by design">
|
||||
A passkey is tied to your device and unlocked with biometrics or a PIN, so it already proves both something you have and something you are or know. That is why it skips the emailed code. Warmbly requires that unlock: a security key with no PIN set cannot be added, and cannot sign in, until you set one on the key.
|
||||
@@ -160,6 +176,8 @@ Every signed-in device appears under **Sessions** with its device (`Chrome on ma
|
||||
|
||||
**Sign out** ends one session; **Sign out other sessions** clears everything except where you are now. Signing out everywhere, changing or resetting your password, and an account ban end every session at once, and close any live connection the dashboard or an API client has open to the realtime service.
|
||||
|
||||
Session validation reads the current session from the database on every request. If the database cannot verify the session, the request is refused. Redis availability does not determine whether a revoked session can authenticate.
|
||||
|
||||
A session renews itself in the background for up to 180 days from the sign-in that started it; after that you sign in again on that device. Each renewal replaces the credential that keeps it alive. If an old one is ever presented, a copy of it exists somewhere else, so Warmbly ends that session on the spot and you sign in once more on that device.
|
||||
|
||||
<Callout type="warn" title="If something looks wrong">
|
||||
|
||||
@@ -126,7 +126,7 @@ Warmbly serves the redirect from this instance's tracking service once DNS prove
|
||||
|
||||
### Set one up
|
||||
|
||||
Enter the website to send visitors to, such as `https://yourcompany.com`. It must be an `http` or `https` address on one of your workspace's own domains: a domain you have a mailbox on, a verified tracking host, your verified [forms domain](/guides/forms/), or a subdomain of one of them. Any other address is refused with `redirect_target_not_own_domain`, and so is a redirect back to the same domain or its `www`. A destination saved earlier that no longer qualifies, for example after the last mailbox on its domain is removed, is kept but shows **Not in use**, and the domain answers as if it had no redirect until you change it. **Include www** is on by default. Warmbly then lists the records to add at your DNS provider:
|
||||
Enter the website to send visitors to, such as `https://yourcompany.com`. It must be an `http` or `https` address on one of your workspace's own domains: a domain you have a mailbox on, a verified tracking host, your verified [forms domain](/guides/forms/), a website you [confirmed](#confirm-your-website), or a subdomain of one of them. A redirect back to the same domain or its `www` is refused. A destination saved earlier that no longer qualifies, for example after the last mailbox on its domain is removed, is kept but shows **Not in use**, and the domain answers as if it had no redirect until you change it or confirm the website. **Include www** is on by default. Warmbly then lists the records to add at your DNS provider:
|
||||
|
||||
| Purpose | Type | Name | Value | Needed to verify |
|
||||
| --- | --- | --- | --- | --- |
|
||||
@@ -140,6 +140,18 @@ When the tracking host has no public address to list, the root record is shown a
|
||||
|
||||
The root of a domain has to point here for the redirect to work, so a domain whose root already serves a website is not a candidate. Mail is unaffected: `MX`, SPF, DKIM and DMARC records live beside these and nothing here changes them.
|
||||
|
||||
### Confirm your website
|
||||
|
||||
Most teams keep their main website's domain out of cold outreach, so it is usually not a domain the workspace sends from. Confirm it once with a `TXT` record at that website's DNS provider:
|
||||
|
||||
| Type | Name | Value |
|
||||
| --- | --- | --- |
|
||||
| `TXT` | `_warmbly.<website domain>` | `warmbly-verify=<value>` |
|
||||
|
||||
The record goes on the website's registrable domain (`yourcompany.com` for `https://www.yourcompany.com`), and confirming it covers every page and subdomain under it. Saving a redirect to a website that is not confirmed yet shows the record to add instead of saving; once it is in place, **Check and save** saves it. The value is unique to your workspace on this instance, like the ownership value, so another workspace's record confirms nothing for yours. Adding it changes nothing about how your website is served. One confirmation covers every sending domain that redirects there, and [form redirects](/guides/forms/#settings) too.
|
||||
|
||||
Warmbly looks for the record again every 6 hours. When it is definitively gone, the website is no longer confirmed and redirects to it stop, showing the record to add again; a DNS lookup that fails or times out changes nothing. While a website is not confirmed, the redirect's progress shows that step with the record, and Warmbly does not open the domain to check what visitors get, since it is holding the redirect back itself.
|
||||
|
||||
### Verification
|
||||
|
||||
A redirect verifies when the `TXT` record and the root record are both in place. The `www` record is optional; without it, only the bare domain redirects.
|
||||
@@ -201,7 +213,7 @@ On a self-hosted instance [linked to Warmbly Cloud](/guides/warmbly-cloud/), a r
|
||||
### Limits
|
||||
|
||||
- The workspace must have a mailbox on the domain.
|
||||
- The website must be on one of the workspace's own domains, as described in [set one up](#set-one-up).
|
||||
- The website must be on one of the workspace's own domains or a [confirmed website](#confirm-your-website), as described in [set one up](#set-one-up).
|
||||
- Domains of shared email providers, such as `gmail.com` or `outlook.com`, are refused.
|
||||
- One workspace per domain on an instance. While one workspace's redirect for a domain is verified, another workspace's redirect for it is refused with `domain_redirect_taken` and does not verify.
|
||||
- The instance needs a tracking host (`TRACKING_DOMAIN`), because the tracking service is what answers. Without one, redirects are not offered, except from Warmbly Cloud on a linked instance.
|
||||
@@ -242,7 +254,7 @@ The vendor's domain list is read with the workspace's own API key, only for conn
|
||||
|
||||
## What travels in an export
|
||||
|
||||
Redirects travel in a [workspace export](/guides/workspace-export-import/). They arrive unverified and are served once the destination's own check sees both records. One Warmbly Cloud served for the source arrives served by the destination itself. The ownership value belongs to the workspace on the instance that issued it, so the destination lists its own value: publish that value in the `TXT` record, and point the root at the destination. A tracking host is part of each mailbox's settings and travels with the mailbox; it arrives unverified, and the destination's hourly check verifies it once the `CNAME` points at the destination and the destination's ownership value is published. Forwarding set through a vendor lives at the vendor and is unaffected by a move.
|
||||
Redirects travel in a [workspace export](/guides/workspace-export-import/). They arrive unverified and are served once the destination's own check sees both records. One Warmbly Cloud served for the source arrives served by the destination itself. The ownership value belongs to the workspace on the instance that issued it, so the destination lists its own value: publish that value in the `TXT` record, and point the root at the destination. A tracking host is part of each mailbox's settings and travels with the mailbox; it arrives unverified, and the destination's hourly check verifies it once the `CNAME` points at the destination and the destination's ownership value is published. Forwarding set through a vendor lives at the vendor and is unaffected by a move. [Confirmed websites](#confirm-your-website) do not travel: their record is bound to the source workspace, so the destination shows its own record to add for each website its redirects point at.
|
||||
|
||||
</Fold>
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ The rail is two short groups and then your mailboxes. The first group is where y
|
||||
| Folder | Group | Shows |
|
||||
| --- | --- | --- |
|
||||
| Inbox | First | Inbound mail, plus anything filed in a custom folder at the provider, unless that folder is [excluded from sync](/guides/mailboxes/#folders-you-do-not-want-synced) |
|
||||
| Drafts | Second | Messages sitting in a mailbox's drafts folder |
|
||||
| Drafts | Second | Conversations with an [inbox agent](/guides/inbox-agent/) reply waiting for review, listed first under **Agent drafts**, then messages sitting in a mailbox's drafts folder. The count includes both, counting a conversation once if it has both kinds of draft |
|
||||
| Sent | Second | Outbound mail, campaign and manual |
|
||||
| Archive | Second | Archived (Gmail's All Mail, the Archive folder elsewhere) |
|
||||
| Spam | Second | Junked at the provider |
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Warmup
|
||||
description: "Disclosed diagnostics, placement evidence, participation and conservative pacing."
|
||||
description: "Natural warmup threads, placement evidence, participation and conservative pacing."
|
||||
---
|
||||
|
||||
Warmup sends short, disclosed test messages between participating mailboxes and records where they land. It reveals configuration and delivery problems, but it does not guarantee inbox placement.
|
||||
Warmup sends ordinary-looking plain-text threads between participating mailboxes and records where they land. It reveals configuration and delivery problems, but it does not guarantee inbox placement.
|
||||
|
||||

|
||||
|
||||
@@ -49,7 +49,7 @@ Pause to stop both sending and receiving warmup mail, or Stop to also turn diagn
|
||||
|
||||
## What warmup is and who gets it
|
||||
|
||||
Warmup sends disclosed automated diagnostics between participating mailboxes. It measures observed placement and bounded actual-message DKIM evidence. It does not establish organic engagement or guarantee reputation improvement or inbox placement.
|
||||
Warmup sends natural plain-text threads between participating mailboxes. It measures observed placement and bounded actual-message DKIM evidence. It does not establish organic engagement or guarantee reputation improvement or inbox placement.
|
||||
|
||||
<Callout type="info" title="Warmup is a paid feature">
|
||||
Free organizations can connect mailboxes, but no warmup traffic is scheduled for them; pending warmup activity is skipped rather than sent.
|
||||
@@ -71,13 +71,13 @@ Diagnostics reveal configuration and delivery problems, not whether real recipie
|
||||
|
||||
With warmup enabled, Warmbly repeatedly picks a partner mailbox (avoiding recent ones), decides whether to start a thread or reply to one, sends a short plaintext message through that mailbox's worker, then records stats and schedules the next send.
|
||||
|
||||
Diagnostics carry task/sender/recipient-bound application tokens and disclose automation and hypothetical scenarios. They use configured mailbox identities and no open/click pixels.
|
||||
Warmup messages carry task/sender/recipient-bound application tokens. They use configured mailbox identities and no open/click pixels.
|
||||
|
||||
Providers may strip headers or replace identifiers. Exact authorized lineage and send-result identifiers correlate diagnostics; missing or ambiguous lineage stays closed. Tokens identify application-owned traffic, not cryptographic authentication.
|
||||
|
||||
When an SMTP relay rewrites a Message-ID, a valid recipient-bound verification token, the expected sender address and a confirmed send can authorize one received copy. Replies and message-specific DKIM verification use that copy's received identifier. Headerless arrivals still require an exact confirmed identifier for new diagnostic lineage; a matching subject or mailbox pair alone does not authorize a reply. Arrivals held before send confirmation or during a verification outage are retained and retried automatically while their token remains valid.
|
||||
|
||||
New mailboxes default off. Independent send/receive controls and shared daily/rolling limits are on the Warmup tab. Start/resume enables disclosed automated sending and, when starting from Off or legacy, receiving with provider-supported spam rescue, reads, importance and stars or flags. Pause stops receiving as well as sending, and Stop disables both participation directions, each while retaining ramp history and holds. A mailbox whose warmup is paused or was never started receives no warmup mail, whatever its receive setting; the send and receive settings only narrow participation while warmup is on. Recipient-only (sending off, receiving on, warmup on) keeps receiving and cannot reply. Sender-only does not authorize recipient engagement. Existing receive-enabled diagnostic mailboxes also use these actions after the consumer, backend and workers are upgraded; no new setting or data migration is needed. Existing NULL stays legacy until explicit action; unrelated edits do not relabel it. Cloud controls require updated Cloud replicas. See [send safety](/development/send-safety/).
|
||||
New mailboxes default off. Independent send/receive controls and shared daily/rolling limits are on the Warmup tab. Start/resume enables warmup sending and, when starting from Off or legacy, receiving with provider-supported spam rescue, reads, importance and stars or flags. Pause stops receiving as well as sending, and Stop disables both participation directions, each while retaining ramp history and holds. A mailbox whose warmup is paused or was never started receives no warmup mail, whatever its receive setting; the send and receive settings only narrow participation while warmup is on. Recipient-only (sending off, receiving on, warmup on) keeps receiving and cannot reply. Sender-only does not authorize recipient engagement. Existing receive-enabled diagnostic mailboxes also use these actions after the consumer, backend and workers are upgraded; no new setting or data migration is needed. Existing NULL stays legacy until explicit action; unrelated edits do not relabel it. Cloud controls require updated Cloud replicas. See [send safety](/development/send-safety/).
|
||||
|
||||
### When a send fails
|
||||
|
||||
@@ -105,11 +105,13 @@ Recovery does not bypass paused participation, provider limits or deliverability
|
||||
|
||||
### Where the content comes from
|
||||
|
||||
Message generation stays off the live sending path. When an AI provider is configured, a background batch builds complete conversation plans (a subject, an opening, and five alternating reply turns), each validated against a strict schema, checked for robotic language, and passed through a safety lint before entering the active bank. When the operator has also configured TypeSafe (`TYPESAFE_API_KEY`), each thread is judged for pitches and generated-sounding filler before entering the bank, and the thread text is sent to TypeSafe for that.
|
||||
Warmup mail reads like ordinary correspondence: a short, specific subject, an opening and up to five alternating replies between two people who know each other loosely. It never says it is automated, generated or a warmup, and any turn that does is refused before it sends. Topics, tone, structure and length vary from thread to thread, and replies keep the same subject and the real sender names.
|
||||
|
||||
Canonical turns use actual alternating configured identities and pinned subject/source/version. Exact-parent continuation preserves facts and closes exhausted, retired or missing threads. A varied vetted bank of disclosed hypothetical exercises supplies fallback. Generated prose never claims a provider check passed.
|
||||
Every instance ships with a hand-written library of about seventy threads, so warmup works with no AI provider at all. With an OpenAI key configured and `AI_PROVIDER` unset or set to `openai`, background batches add generated threads. Each passes structural and wording checks, then a separate review of the complete thread (TypeSafe when configured, otherwise OpenAI) before it can be used. An unavailable, incomplete or uncertain review never approves content.
|
||||
|
||||
The controller runs every six hours against the last seven days of demand: at least 200 active threads, up to 5,000, refreshing the most-used content, at most 250 threads per batch and 1,000 per day. Threads are retired automatically when at least 3 of 20 or more sampled deliveries land in spam and the rate is `15%` or higher. Admins monitor it but never refill it by hand.
|
||||
For each new thread, Warmbly picks a conversation neither mailbox has seen in the last 30 days, as sender or recipient, preferring ones neither has ever seen and the least used. When a pair has seen everything recently, it reuses the one they saw longest ago instead of waiting, so a generation outage never pauses warmup. Duplicate subjects or openings are rejected across the library and every approved batch. Threads started with the retired "Simulated diagnostic" wording stop at their next reply, and the mailbox carries on with new content.
|
||||
|
||||
The generator refills the AI bank every six hours toward a target of at least 200 threads, rising with demand up to 5,000, in batches of at most 250 and within a default budget of 1,000 a day. Operators can adjust cadence, targets and budgets in the admin content controls; see [generation configuration](/development/warmup-generation/). None of this guarantees inbox placement or reputation improvement.
|
||||
|
||||
</Fold>
|
||||
|
||||
@@ -218,7 +220,7 @@ The partner cap exists because a mailbox never writes to the same partner twice
|
||||
|
||||
Warmup hours are read in the mailbox's timezone: its own when one is set on the **Settings** tab of its drawer, otherwise the workspace timezone under **Settings > Profile > Timezones**, and UTC when neither is set. Set the workspace timezone once and every mailbox that follows it reads its warmup hours in the team's day. A mailbox with its own timezone keeps it, and changing the workspace timezone does not change any mailbox's hours.
|
||||
|
||||
While [Sending behavior](/guides/sending-behavior/) is on, which it is for a newly connected mailbox, warmup only sends when both the warmup hours and that workday allow it, and the Warmup tab says so above the hours. A mailbox connected after its workday ends therefore sends its first warmup email the next working morning. Switch the mailbox to **Fixed schedule** on its **Sending** tab to use the warmup hours alone. Changing the warmup hours, days or timezone (the mailbox's own, or the workspace's for a mailbox that follows it), or switching sending behavior on or off, moves the queued warmup send at once. The mailbox list shows when the next warmup send is queued under the day's count.
|
||||
While [Sending behavior](/guides/sending-behavior/) is on, which it is for a newly connected mailbox (a warmup-only mailbox enrolled from a self-hosted instance starts with it off), warmup only sends when both the warmup hours and that workday allow it, and the Warmup tab says so above the hours. A mailbox connected after its workday ends therefore sends its first warmup email the next working morning. The workday's working days default to Monday to Friday, so warmup skips the weekend even when the warmup days include it. When that happens the Warmup tab names the skipped days, with a button that adds them to the working days (for example **Work Saturday and Sunday too**). Switch the mailbox to **Fixed schedule** on its **Sending** tab to send on the warmup hours and days alone, without the workday. Changing the warmup hours, days or timezone (the mailbox's own, or the workspace's for a mailbox that follows it), or switching sending behavior on or off, moves the queued warmup send at once. The mailbox list shows when the next warmup send is queued under the day's count.
|
||||
|
||||
Warmup hours must end later than they start on the same day. Equal or reversed hours are rejected, including a change to only one endpoint that would invalidate the stored window. Existing invalid windows are not widened or corrected automatically: pending sends stay unstarted and recheck after five minutes, while admin monitoring shows **Invalid warmup sending hours** until the configured window is corrected. Other send protections still apply after correction; this does not replay uncertain sends or confirm mailbox recovery.
|
||||
|
||||
@@ -248,12 +250,14 @@ Placement slowdown and ramp pause have different windows. The drawer shows obser
|
||||
|
||||
## Replies
|
||||
|
||||
Configured diagnostic turns continue disclosed scenarios, not organic relationships. Exact pinned plans and subjects are reloaded, each parent is answered once, and exhausted, retired or missing threads close.
|
||||
Replies continue the exact pinned thread and subject, each parent is answered once, and exhausted, retired or missing threads close.
|
||||
|
||||
Replies thread properly with a real `Re:` subject and `In-Reply-To` header, and candidates must be between 45 minutes and seven days old, so nothing is answered instantly or revived indefinitely.
|
||||
|
||||
Receiving warmup mail can also prompt an answer directly. When a verified warmup email arrives, the recipient sometimes points its next scheduled send back at whoever wrote, 45 minutes to 5 hours later and inside its own warmup hours. That is a re-pointing, not extra work: each mailbox has one warmup send queued at a time, so a reply-back moves that send earlier and aims it, and can never push a send the mailbox had already planned sooner. When that send is already answering someone, the new email is not answered, so replies never crowd out new threads. A reply is held to the same daily receiving cap as any other warmup email: when the inbox it answers is full for the day, the thread ends there and the mailbox goes on with its normal schedule, so one busy partner never stops a mailbox's warmup. The chance is the recipient's own reply rate (raised for a sender in [recovery](#recovery-engagement), which includes every free Gmail and Outlook.com mailbox and every mailbox backing a live campaign), drawn once when the reply is scheduled rather than again when it sends, and it stops before a thread reaches its message cap so replies cannot answer replies indefinitely. A reply crosses the free and paid tiers like the mail it answers: a paid mailbox answers a free partner that wrote to it, and a free mailbox answers a paid one while it is healthy and its workspace is in good standing.
|
||||
|
||||
If the next send is already scheduled earlier than the reply's drawn time, it keeps that time when it is at least 45 minutes after the receipt. If it is due before that minimum delay, it stays a new send rather than being postponed for a reply. The configured percentage is a chance to answer eligible messages, so sending windows, thread limits and available capacity can make the measured rate differ from it.
|
||||
|
||||
Scheduling respects windows, provider feedback, shared limits and spacing. Jitter distributes load, not human identities. Receiving participation allows probabilistic spam rescue, reads, importance and stars or flags on verified warmup messages. Filing and selected spam rescues are requested immediately; reads, importance and stars are durably scheduled after a randomized dwell. Current receiving permission and worker assignment are checked again at execution time. These actions are automation, not human feedback or a guaranteed reputation improvement.
|
||||
|
||||
</Fold>
|
||||
|
||||
@@ -96,6 +96,8 @@ Inbox, send history, delivery events, and logs are the ones that grow without li
|
||||
|
||||
The pending warmup-filing queue stays on its source instance. The destination resyncs mail and files recognized warmup messages using its own workers and the mailbox's placement setting.
|
||||
|
||||
Campaign contacts waiting for an uncertain send retain that protection with **Campaigns**, even when you omit **Send history**. Imported uncertain commands cannot execute again. Without their send history, those contacts stay protected because the destination cannot confirm the original outcome. Manual resume does not remove this protection.
|
||||
|
||||
Warmup statistics travel as history. Source-only per-task charge and refund markers reset on import so settling an old task cannot refund another send's destination statistics. Existing destination charge dates and older completed-day counters are protected on overwrite; preserving older counts does not create charge or refund proof. Whole-instance database backups retain these markers.
|
||||
|
||||
Mailbox transport-error reports travel as history, retaining every report ID, observation timestamp, task reference and recorded resolution. Their operation and observation provenance reset to unknown, including overwrite imports and older archives without those fields. Imported and legacy historical reports do not share the uniqueness rule for new, locally observed reports and are not automatically cleared by a successful sync or send. Unknown history means recovery is unverified, not that a provider is still failing.
|
||||
@@ -194,6 +196,7 @@ Some things belong to an instance rather than to a workspace, so they are not ap
|
||||
| Raw warmup receipt provenance | `warmup_received` observations, first-folder/auth header provenance and provider thread handles are source-instance evidence and are explicitly excluded. Aggregated warmup placement history travels, but raw receipt provenance does not |
|
||||
| Warmup dispatch and continuation authority | Parent task/receipt/message handles, lineage authority, queue revisions, worker IDs, dispatch nonces and native result state reset. Imported historical diagnostic metadata and tokens do not authorize automatic continuation on the destination |
|
||||
| Provider-attempt history | Immutable attempted timestamps and recipient counts travel in the sending group, retaining restrictive daily/rolling evidence after a capacity refund. Historical attempt nonces never authorize a new executor command |
|
||||
| Warmup content reservations | Shared conversation plans and their per-mailbox reuse reservations belong to the source instance and do not travel. Imported mailboxes use the destination’s approved pool |
|
||||
| Warmup pool membership | Pools are shared across every workspace on an instance, so membership is re-earned rather than asserted by a file |
|
||||
| Domain authentication timings | The verdict travels (public DNS reads the same anywhere), but the destination re-checks before it can stop any sending, so a mailbox is never blocked on an observation the new instance never made |
|
||||
| Risk and review status | A workspace's abuse posture is one platform's verdict about a tenant on its own infrastructure, reached from evidence the destination never saw. An archive can neither carry a restriction nor clear one |
|
||||
@@ -261,6 +264,8 @@ A [community directory](/guides/integrations/#community-apps) listing does not t
|
||||
|
||||
[Slack](/guides/slack/) account links, the record of which Slack thread belongs to which assistant conversation, and which Slack thread mirrors which inbox conversation in the [inbox channel](/guides/slack/#inbox-in-slack) do not travel. They name the Slack install on the source instance, so members link again after Slack is reconnected on the destination, and inbox conversations start new Slack threads there. The assistant conversations themselves move with the Assistant group.
|
||||
|
||||
[Confirmed websites](/guides/sending-domains/#confirm-your-website) do not travel. The `TXT` record that confirms one is bound to the source workspace, so it proves nothing on the destination. Redirects and form redirects to the website arrive kept but not used. The destination shows its own record to publish on each sending domain's **Redirect** tab, and form redirects to the website work again once it is confirmed there.
|
||||
|
||||
Reply and forward drafts kept in your browser are also excluded. Finish or copy them before moving to another instance. See [reply drafts](/guides/unibox/#reply-drafts).
|
||||
|
||||
</Fold>
|
||||
|
||||
@@ -229,6 +229,59 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/login/initial-password": {
|
||||
"post": {
|
||||
"operationId": "auth_login_initial_password",
|
||||
"summary": "Replace an issued initial password and continue signing in",
|
||||
"description": "Answers a /auth/login result with password_change_required. Takes the single-use pending_token (ten minute lifetime) and the holder's own password, stores it in place of the issued one, signs out every other session, then continues the sign-in exactly as /auth/login would: an emailed code, a 2FA challenge or the session. Refusals: the password rules (8 to 128 characters, password_breached), password_reused for the issued password itself, and password_change_expired for a token that is unknown, expired, already used or whose issued password ran out.",
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"security": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InitialPasswordRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The sign-in continues, in the same shape /auth/login returns.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/AuthSession"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "The new password was refused, or the challenge expired.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"429": {
|
||||
"description": "Rate limited.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/register": {
|
||||
"post": {
|
||||
"operationId": "auth_register_start",
|
||||
@@ -31749,14 +31802,53 @@
|
||||
},
|
||||
"AuthSession": {
|
||||
"type": "object",
|
||||
"description": "Opaque session handle returned by login/register start; pass it to the matching confirm call.",
|
||||
"required": [
|
||||
"session"
|
||||
],
|
||||
"description": "Returned by login/register start. With code_required, pass session to the matching confirm call. Without it, the sign-in completed (token), needs a 2FA code (two_fa_required with pending_token), or used an issued initial password that has to be replaced first (password_change_required with pending_token for /auth/login/initial-password).",
|
||||
"properties": {
|
||||
"session": {
|
||||
"type": "string",
|
||||
"description": "Opaque session handle."
|
||||
},
|
||||
"code_required": {
|
||||
"type": "boolean",
|
||||
"description": "True when a code was emailed and session goes to the confirm call."
|
||||
},
|
||||
"two_fa_required": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"password_change_required": {
|
||||
"type": "boolean",
|
||||
"description": "True when the password was an issued initial password. No session exists; post pending_token and a new password to /auth/login/initial-password."
|
||||
},
|
||||
"pending_token": {
|
||||
"type": "string",
|
||||
"description": "Single-use pending token for /auth/2fa/verify or /auth/login/initial-password."
|
||||
},
|
||||
"expires_in": {
|
||||
"type": "integer",
|
||||
"description": "Seconds until pending_token expires."
|
||||
}
|
||||
}
|
||||
},
|
||||
"InitialPasswordRequest": {
|
||||
"type": "object",
|
||||
"description": "Request body for /auth/login/initial-password.",
|
||||
"required": [
|
||||
"pending_token",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"pending_token": {
|
||||
"type": "string",
|
||||
"description": "The pending_token from a password_change_required sign-in."
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"format": "password",
|
||||
"description": "The new password, 8 to 128 characters, not on the breached list and not the issued password."
|
||||
},
|
||||
"device_token": {
|
||||
"type": "string",
|
||||
"description": "The remembered-browser token, as sent to /auth/login."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Generated
+82
-79
@@ -6,6 +6,7 @@ settings:
|
||||
|
||||
overrides:
|
||||
dompurify: ^3.4.17
|
||||
seroval: ^1.6.11
|
||||
|
||||
importers:
|
||||
|
||||
@@ -47,16 +48,16 @@ importers:
|
||||
version: 19.2.5(@types/react@19.2.18)
|
||||
'@vitejs/plugin-react':
|
||||
specifier: ^5.0.4
|
||||
version: 5.2.0(vite@7.3.7(@types/node@24.13.3))
|
||||
version: 5.2.0(supports-color@7.2.0)(vite@7.3.7(@types/node@24.13.3))
|
||||
eslint:
|
||||
specifier: ^9.36.0
|
||||
version: 9.39.5
|
||||
version: 9.39.5(supports-color@7.2.0)
|
||||
eslint-plugin-react-hooks:
|
||||
specifier: ^5.2.0
|
||||
version: 5.2.0(eslint@9.39.5)
|
||||
version: 5.2.0(eslint@9.39.5(supports-color@7.2.0))
|
||||
eslint-plugin-react-refresh:
|
||||
specifier: ^0.4.22
|
||||
version: 0.4.26(eslint@9.39.5)
|
||||
version: 0.4.26(eslint@9.39.5(supports-color@7.2.0))
|
||||
globals:
|
||||
specifier: ^16.4.0
|
||||
version: 16.5.0
|
||||
@@ -65,7 +66,7 @@ importers:
|
||||
version: 5.9.3
|
||||
typescript-eslint:
|
||||
specifier: ^8.45.0
|
||||
version: 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
version: 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
vite:
|
||||
specifier: ^7.3.7
|
||||
version: 7.3.7(@types/node@24.13.3)
|
||||
@@ -1159,11 +1160,11 @@ packages:
|
||||
resolution: {integrity: sha512-R0f1U9hmn38+dFMz6b6ab8lwucmw4AtiY7St+JPWudy1dm+Bs3g884nyrsH9Cy6rKpZKLYayXuMda9GZ/fl8JQ==}
|
||||
engines: {node: '>=10'}
|
||||
peerDependencies:
|
||||
seroval: ^1.0
|
||||
seroval: ^1.6.11
|
||||
|
||||
seroval@1.6.4:
|
||||
resolution: {integrity: sha512-LErWMNS2RRFdu2RMA5u/PA59/IWs0XsikyEXGQ2/36iEWFrdG0ABmg17E17cikrv76891kOAMq3TkTFXpwAHXw==}
|
||||
engines: {node: '>=10'}
|
||||
seroval@1.7.5:
|
||||
resolution: {integrity: sha512-UdNgpHdq0gVpme5JdQF+S3jNscnjFr4NTwUWOc1qcOa8OuWZmbV0+YX2hsqxkUZshBpHnpxDZfAKVZG2ugbrJA==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
shebang-command@2.0.0:
|
||||
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
||||
@@ -1297,20 +1298,20 @@ snapshots:
|
||||
|
||||
'@babel/compat-data@7.29.7': {}
|
||||
|
||||
'@babel/core@7.29.7':
|
||||
'@babel/core@7.29.7(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.29.7
|
||||
'@babel/generator': 7.29.8
|
||||
'@babel/helper-compilation-targets': 7.29.7
|
||||
'@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7)
|
||||
'@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)
|
||||
'@babel/helpers': 7.29.7
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/template': 7.29.7
|
||||
'@babel/traverse': 7.29.8
|
||||
'@babel/traverse': 7.29.8(supports-color@7.2.0)
|
||||
'@babel/types': 7.29.8
|
||||
'@jridgewell/remapping': 2.3.5
|
||||
convert-source-map: 2.0.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
gensync: 1.0.0-beta.2
|
||||
json5: 2.2.3
|
||||
semver: 6.3.1
|
||||
@@ -1335,19 +1336,19 @@ snapshots:
|
||||
|
||||
'@babel/helper-globals@7.29.7': {}
|
||||
|
||||
'@babel/helper-module-imports@7.29.7':
|
||||
'@babel/helper-module-imports@7.29.7(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/traverse': 7.29.8
|
||||
'@babel/traverse': 7.29.8(supports-color@7.2.0)
|
||||
'@babel/types': 7.29.8
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)':
|
||||
'@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/helper-module-imports': 7.29.7
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-module-imports': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-validator-identifier': 7.29.7
|
||||
'@babel/traverse': 7.29.8
|
||||
'@babel/traverse': 7.29.8(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -1368,14 +1369,14 @@ snapshots:
|
||||
dependencies:
|
||||
'@babel/types': 7.29.8
|
||||
|
||||
'@babel/plugin-transform-react-jsx-self@7.29.7(@babel/core@7.29.7)':
|
||||
'@babel/plugin-transform-react-jsx-self@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-plugin-utils': 7.29.7
|
||||
|
||||
'@babel/plugin-transform-react-jsx-source@7.29.7(@babel/core@7.29.7)':
|
||||
'@babel/plugin-transform-react-jsx-source@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/helper-plugin-utils': 7.29.7
|
||||
|
||||
'@babel/template@7.29.7':
|
||||
@@ -1384,7 +1385,7 @@ snapshots:
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/types': 7.29.8
|
||||
|
||||
'@babel/traverse@7.29.8':
|
||||
'@babel/traverse@7.29.8(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.29.7
|
||||
'@babel/generator': 7.29.8
|
||||
@@ -1392,7 +1393,7 @@ snapshots:
|
||||
'@babel/parser': 7.29.8
|
||||
'@babel/template': 7.29.7
|
||||
'@babel/types': 7.29.8
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -1479,17 +1480,17 @@ snapshots:
|
||||
'@esbuild/win32-x64@0.28.2':
|
||||
optional: true
|
||||
|
||||
'@eslint-community/eslint-utils@4.10.1(eslint@9.39.5)':
|
||||
'@eslint-community/eslint-utils@4.10.1(eslint@9.39.5(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
eslint: 9.39.5
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
eslint-visitor-keys: 3.4.3
|
||||
|
||||
'@eslint-community/regexpp@4.12.2': {}
|
||||
|
||||
'@eslint/config-array@0.21.2':
|
||||
'@eslint/config-array@0.21.2(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@eslint/object-schema': 2.1.7
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
minimatch: 3.1.5
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -1502,10 +1503,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/json-schema': 7.0.15
|
||||
|
||||
'@eslint/eslintrc@3.3.6':
|
||||
'@eslint/eslintrc@3.3.6(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
ajv: 6.15.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
espree: 10.4.0
|
||||
globals: 14.0.0
|
||||
ignore: 5.3.2
|
||||
@@ -1739,8 +1740,8 @@ snapshots:
|
||||
dependencies:
|
||||
'@tanstack/history': 1.162.1
|
||||
cookie-es: 3.1.1
|
||||
seroval: 1.6.4
|
||||
seroval-plugins: 1.6.4(seroval@1.6.4)
|
||||
seroval: 1.7.5
|
||||
seroval-plugins: 1.6.4(seroval@1.7.5)
|
||||
|
||||
'@tanstack/store@0.11.1': {}
|
||||
|
||||
@@ -1786,15 +1787,15 @@ snapshots:
|
||||
'@types/trusted-types@2.0.7':
|
||||
optional: true
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.68.0(@typescript-eslint/parser@8.68.0(eslint@9.39.5)(typescript@5.9.3))(eslint@9.39.5)(typescript@5.9.3)':
|
||||
'@typescript-eslint/eslint-plugin@8.68.0(@typescript-eslint/parser@8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@typescript-eslint/parser': 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
'@typescript-eslint/parser': 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/scope-manager': 8.68.0
|
||||
'@typescript-eslint/type-utils': 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
'@typescript-eslint/type-utils': 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/visitor-keys': 8.68.0
|
||||
eslint: 9.39.5
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
ignore: 7.0.7
|
||||
natural-compare: 1.4.0
|
||||
ts-api-utils: 2.5.0(typescript@5.9.3)
|
||||
@@ -1802,23 +1803,23 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/parser@8.68.0(eslint@9.39.5)(typescript@5.9.3)':
|
||||
'@typescript-eslint/parser@8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 8.68.0
|
||||
'@typescript-eslint/types': 8.68.0
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(typescript@5.9.3)
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/visitor-keys': 8.68.0
|
||||
debug: 4.4.3
|
||||
eslint: 9.39.5
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/project-service@8.68.0(typescript@5.9.3)':
|
||||
'@typescript-eslint/project-service@8.68.0(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/tsconfig-utils': 8.68.0(typescript@5.9.3)
|
||||
'@typescript-eslint/types': 8.68.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -1832,13 +1833,13 @@ snapshots:
|
||||
dependencies:
|
||||
typescript: 5.9.3
|
||||
|
||||
'@typescript-eslint/type-utils@8.68.0(eslint@9.39.5)(typescript@5.9.3)':
|
||||
'@typescript-eslint/type-utils@8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.68.0
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
debug: 4.4.3
|
||||
eslint: 9.39.5
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
ts-api-utils: 2.5.0(typescript@5.9.3)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
@@ -1846,13 +1847,13 @@ snapshots:
|
||||
|
||||
'@typescript-eslint/types@8.68.0': {}
|
||||
|
||||
'@typescript-eslint/typescript-estree@8.68.0(typescript@5.9.3)':
|
||||
'@typescript-eslint/typescript-estree@8.68.0(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/project-service': 8.68.0(typescript@5.9.3)
|
||||
'@typescript-eslint/project-service': 8.68.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/tsconfig-utils': 8.68.0(typescript@5.9.3)
|
||||
'@typescript-eslint/types': 8.68.0
|
||||
'@typescript-eslint/visitor-keys': 8.68.0
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
minimatch: 10.2.6
|
||||
semver: 7.8.5
|
||||
tinyglobby: 0.2.17
|
||||
@@ -1861,13 +1862,13 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/utils@8.68.0(eslint@9.39.5)(typescript@5.9.3)':
|
||||
'@typescript-eslint/utils@8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5)
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(supports-color@7.2.0))
|
||||
'@typescript-eslint/scope-manager': 8.68.0
|
||||
'@typescript-eslint/types': 8.68.0
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(typescript@5.9.3)
|
||||
eslint: 9.39.5
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -1877,11 +1878,11 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.68.0
|
||||
eslint-visitor-keys: 5.0.1
|
||||
|
||||
'@vitejs/plugin-react@5.2.0(vite@7.3.7(@types/node@24.13.3))':
|
||||
'@vitejs/plugin-react@5.2.0(supports-color@7.2.0)(vite@7.3.7(@types/node@24.13.3))':
|
||||
dependencies:
|
||||
'@babel/core': 7.29.7
|
||||
'@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7)
|
||||
'@babel/plugin-transform-react-jsx-source': 7.29.7(@babel/core@7.29.7)
|
||||
'@babel/core': 7.29.7(supports-color@7.2.0)
|
||||
'@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))
|
||||
'@babel/plugin-transform-react-jsx-source': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))
|
||||
'@rolldown/pluginutils': 1.0.0-rc.3
|
||||
'@types/babel__core': 7.20.5
|
||||
react-refresh: 0.18.0
|
||||
@@ -1962,9 +1963,11 @@ snapshots:
|
||||
|
||||
csstype@3.2.3: {}
|
||||
|
||||
debug@4.4.3:
|
||||
debug@4.4.3(supports-color@7.2.0):
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
optionalDependencies:
|
||||
supports-color: 7.2.0
|
||||
|
||||
deep-is@0.1.4: {}
|
||||
|
||||
@@ -2007,13 +2010,13 @@ snapshots:
|
||||
|
||||
escape-string-regexp@4.0.0: {}
|
||||
|
||||
eslint-plugin-react-hooks@5.2.0(eslint@9.39.5):
|
||||
eslint-plugin-react-hooks@5.2.0(eslint@9.39.5(supports-color@7.2.0)):
|
||||
dependencies:
|
||||
eslint: 9.39.5
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
|
||||
eslint-plugin-react-refresh@0.4.26(eslint@9.39.5):
|
||||
eslint-plugin-react-refresh@0.4.26(eslint@9.39.5(supports-color@7.2.0)):
|
||||
dependencies:
|
||||
eslint: 9.39.5
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
|
||||
eslint-scope@8.4.0:
|
||||
dependencies:
|
||||
@@ -2026,14 +2029,14 @@ snapshots:
|
||||
|
||||
eslint-visitor-keys@5.0.1: {}
|
||||
|
||||
eslint@9.39.5:
|
||||
eslint@9.39.5(supports-color@7.2.0):
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5)
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(supports-color@7.2.0))
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@eslint/config-array': 0.21.2
|
||||
'@eslint/config-array': 0.21.2(supports-color@7.2.0)
|
||||
'@eslint/config-helpers': 0.4.2
|
||||
'@eslint/core': 0.17.0
|
||||
'@eslint/eslintrc': 3.3.6
|
||||
'@eslint/eslintrc': 3.3.6(supports-color@7.2.0)
|
||||
'@eslint/js': 9.39.5
|
||||
'@eslint/plugin-kit': 0.4.1
|
||||
'@humanfs/node': 0.16.8
|
||||
@@ -2043,7 +2046,7 @@ snapshots:
|
||||
ajv: 6.15.0
|
||||
chalk: 4.1.2
|
||||
cross-spawn: 7.0.6
|
||||
debug: 4.4.3
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
escape-string-regexp: 4.0.0
|
||||
eslint-scope: 8.4.0
|
||||
eslint-visitor-keys: 4.2.1
|
||||
@@ -2308,11 +2311,11 @@ snapshots:
|
||||
|
||||
semver@7.8.5: {}
|
||||
|
||||
seroval-plugins@1.6.4(seroval@1.6.4):
|
||||
seroval-plugins@1.6.4(seroval@1.7.5):
|
||||
dependencies:
|
||||
seroval: 1.6.4
|
||||
seroval: 1.7.5
|
||||
|
||||
seroval@1.6.4: {}
|
||||
seroval@1.7.5: {}
|
||||
|
||||
shebang-command@2.0.0:
|
||||
dependencies:
|
||||
@@ -2341,13 +2344,13 @@ snapshots:
|
||||
dependencies:
|
||||
prelude-ls: 1.2.1
|
||||
|
||||
typescript-eslint@8.68.0(eslint@9.39.5)(typescript@5.9.3):
|
||||
typescript-eslint@8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3):
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.68.0(@typescript-eslint/parser@8.68.0(eslint@9.39.5)(typescript@5.9.3))(eslint@9.39.5)(typescript@5.9.3)
|
||||
'@typescript-eslint/parser': 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.68.0(eslint@9.39.5)(typescript@5.9.3)
|
||||
eslint: 9.39.5
|
||||
'@typescript-eslint/eslint-plugin': 8.68.0(@typescript-eslint/parser@8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/parser': 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/typescript-estree': 8.68.0(supports-color@7.2.0)(typescript@5.9.3)
|
||||
'@typescript-eslint/utils': 8.68.0(eslint@9.39.5(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)
|
||||
eslint: 9.39.5(supports-color@7.2.0)
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -9,3 +9,5 @@ allowBuilds:
|
||||
|
||||
overrides:
|
||||
dompurify: ^3.4.17
|
||||
# Floor transitive dependencies at their patched releases.
|
||||
seroval: ^1.6.11
|
||||
|
||||
@@ -52,14 +52,14 @@ require (
|
||||
github.com/stripe/stripe-go/v86 v86.4.2
|
||||
github.com/xuri/excelize/v2 v2.11.1-0.20261003002531-6258dcebc4e2
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/crypto v0.57.0
|
||||
golang.org/x/crypto v0.58.0
|
||||
golang.org/x/image v0.45.0
|
||||
golang.org/x/mod v0.41.0
|
||||
golang.org/x/net v0.60.0
|
||||
golang.org/x/net v0.62.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sync v0.23.0
|
||||
golang.org/x/term v0.46.0
|
||||
golang.org/x/text v0.42.0
|
||||
golang.org/x/sync v0.24.0
|
||||
golang.org/x/term v0.47.0
|
||||
golang.org/x/text v0.43.0
|
||||
google.golang.org/api v0.264.0
|
||||
google.golang.org/grpc v1.83.2
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.1
|
||||
@@ -167,7 +167,7 @@ require (
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.19.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
golang.org/x/sys v0.49.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
||||
|
||||
@@ -688,8 +688,8 @@ golang.org/x/arch v0.19.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
|
||||
@@ -712,8 +712,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
|
||||
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||
@@ -722,8 +722,8 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -738,20 +738,20 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
|
||||
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
|
||||
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
|
||||
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
||||
@@ -31,6 +31,7 @@ func TestRoutesThatNeedAFreshConfirmation(t *testing.T) {
|
||||
"org POST /members/invite": false,
|
||||
"org POST /transfer-ownership": false,
|
||||
"org POST /current/danger-zone/delete": false,
|
||||
"adminRoutes POST /testers/:id/password": false,
|
||||
"protectedAuth POST /passkey/register/finish": false,
|
||||
}
|
||||
file, err := parser.ParseFile(token.NewFileSet(), "routes.go", nil, 0)
|
||||
|
||||
@@ -79,6 +79,8 @@ type adminCreateTesterResponse struct {
|
||||
// means making another tester, which is cheap.
|
||||
Password string `json:"password"`
|
||||
PasswordExpiresAt time.Time `json:"password_expires_at"`
|
||||
// PasswordChangeRequired is always true: the holder replaces the password at first sign-in.
|
||||
PasswordChangeRequired bool `json:"password_change_required"`
|
||||
}
|
||||
|
||||
// testerPasswordAlphabet leaves out the characters that are misread when a
|
||||
@@ -170,6 +172,10 @@ func (h *Handler) AdminCreateTester(c *gin.Context) {
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not create the account"))
|
||||
return
|
||||
}
|
||||
// The workspace grant must end exactly when the stored password does.
|
||||
if created.PasswordExpiresAt != nil {
|
||||
passwordExpiresAt = *created.PasswordExpiresAt
|
||||
}
|
||||
|
||||
// A tester joined to an existing workspace gets no workspace of its own on
|
||||
// purpose. Owning one would leave the reviewer a member of two, and the
|
||||
@@ -210,12 +216,13 @@ func (h *Handler) AdminCreateTester(c *gin.Context) {
|
||||
h.logTesterAction(c, *adminID, created.ID, "create_tester", entry)
|
||||
|
||||
c.JSON(http.StatusOK, adminCreateTesterResponse{
|
||||
UserID: created.ID,
|
||||
Email: created.Email,
|
||||
OrgID: orgID,
|
||||
Joined: joined,
|
||||
Password: password,
|
||||
PasswordExpiresAt: passwordExpiresAt,
|
||||
UserID: created.ID,
|
||||
Email: created.Email,
|
||||
OrgID: orgID,
|
||||
Joined: joined,
|
||||
Password: password,
|
||||
PasswordExpiresAt: passwordExpiresAt,
|
||||
PasswordChangeRequired: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -332,6 +339,98 @@ func (h *Handler) revokeExemption(c *gin.Context, userID uuid.UUID) (passwordCle
|
||||
return cleared, true
|
||||
}
|
||||
|
||||
type adminReissueTesterPasswordResponse struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
// Password is returned once and never stored in a readable form.
|
||||
Password string `json:"password"`
|
||||
PasswordExpiresAt time.Time `json:"password_expires_at"`
|
||||
PasswordChangeRequired bool `json:"password_change_required"`
|
||||
}
|
||||
|
||||
// AdminReissueTesterPassword gives an account created as a tester a fresh
|
||||
// initial password, valid 48 hours, and signs out everything it held.
|
||||
func (h *Handler) AdminReissueTesterPassword(c *gin.Context) {
|
||||
adminID := middleware.GetAdminUserID(c)
|
||||
if adminID == nil {
|
||||
errx.JSON(c, errx.ErrUnauthorized)
|
||||
return
|
||||
}
|
||||
userID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil || userID == uuid.Nil {
|
||||
errx.JSON(c, errx.New(errx.BadRequest, "that is not a user id"))
|
||||
return
|
||||
}
|
||||
if h.UserRepo == nil {
|
||||
errx.JSON(c, errx.New(errx.ServiceUnavailable, "accounts are not available on this instance"))
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
|
||||
// Checked before anything is revoked, so a refused call changes nothing.
|
||||
tester, terr := h.UserRepo.IsCreatedTester(ctx, userID)
|
||||
if errors.Is(terr, repository.ErrUserNotFound) || (terr == nil && !tester) {
|
||||
errx.JSON(c, errx.New(errx.NotFound, "no account created as a tester has that id"))
|
||||
return
|
||||
}
|
||||
if terr != nil {
|
||||
errs.CaptureException(terr)
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not read the account"))
|
||||
return
|
||||
}
|
||||
|
||||
password, gerr := testerPassword()
|
||||
if gerr != nil {
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not generate a password"))
|
||||
return
|
||||
}
|
||||
hash, herr := argon2.Hash(password)
|
||||
if herr != nil {
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not hash the password"))
|
||||
return
|
||||
}
|
||||
|
||||
// Sessions and remembered devices end first, so a failure leaves the old password in place.
|
||||
if h.TokenService != nil {
|
||||
if xerr := h.TokenService.RevokeOtherSessions(ctx, userID, uuid.Nil); xerr != nil {
|
||||
errs.CaptureException(xerr)
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not end the account's sessions"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if h.AuthService != nil {
|
||||
if xerr := h.AuthService.ForgetTrustedDevices(ctx, userID); xerr != nil {
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not forget the account's remembered devices"))
|
||||
return
|
||||
}
|
||||
}
|
||||
until, rerr := h.UserRepo.ReissueTesterPassword(ctx, userID, hash)
|
||||
if rerr != nil {
|
||||
if errors.Is(rerr, repository.ErrNotTester) {
|
||||
errx.JSON(c, errx.New(errx.NotFound, "no account created as a tester has that id"))
|
||||
return
|
||||
}
|
||||
errs.CaptureException(rerr)
|
||||
errx.JSON(c, errx.New(errx.Internal, "could not store the new password"))
|
||||
return
|
||||
}
|
||||
// A sign-in that landed between the two writes is ended too.
|
||||
if h.TokenService != nil {
|
||||
if xerr := h.TokenService.RevokeOtherSessions(ctx, userID, uuid.Nil); xerr != nil {
|
||||
errs.CaptureException(xerr)
|
||||
}
|
||||
}
|
||||
|
||||
h.logTesterAction(c, *adminID, userID, "reissue_tester_password", map[string]any{
|
||||
"password_expires_at": until.UTC().Format(time.RFC3339),
|
||||
})
|
||||
c.JSON(http.StatusOK, adminReissueTesterPasswordResponse{
|
||||
UserID: userID,
|
||||
Password: password,
|
||||
PasswordExpiresAt: until,
|
||||
PasswordChangeRequired: true,
|
||||
})
|
||||
}
|
||||
|
||||
type adminSetLoginCodeExemptRequest struct {
|
||||
Exempt *bool `json:"exempt"`
|
||||
Reason string `json:"reason"`
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/warmbly/warmbly/internal/api/middleware"
|
||||
"github.com/warmbly/warmbly/internal/app/auth"
|
||||
"github.com/warmbly/warmbly/internal/app/organization"
|
||||
"github.com/warmbly/warmbly/internal/app/token"
|
||||
"github.com/warmbly/warmbly/internal/errx"
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/pkg/argon2"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
)
|
||||
|
||||
type reissueUsers struct {
|
||||
repository.UserRepository
|
||||
tester bool
|
||||
missing bool
|
||||
hash string
|
||||
until time.Time
|
||||
reissued int
|
||||
log *[]string
|
||||
}
|
||||
|
||||
func (r *reissueUsers) IsCreatedTester(context.Context, uuid.UUID) (bool, error) {
|
||||
if r.missing {
|
||||
return false, repository.ErrUserNotFound
|
||||
}
|
||||
return r.tester, nil
|
||||
}
|
||||
|
||||
func (r *reissueUsers) ReissueTesterPassword(_ context.Context, _ uuid.UUID, hash string) (time.Time, error) {
|
||||
if !r.tester {
|
||||
return time.Time{}, repository.ErrNotTester
|
||||
}
|
||||
r.reissued++
|
||||
r.hash = hash
|
||||
r.until = time.Now().Add(48 * time.Hour)
|
||||
*r.log = append(*r.log, "store")
|
||||
return r.until, nil
|
||||
}
|
||||
|
||||
type reissueTokens struct {
|
||||
token.TokenService
|
||||
log *[]string
|
||||
}
|
||||
|
||||
func (t *reissueTokens) RevokeOtherSessions(context.Context, uuid.UUID, uuid.UUID) *errx.Error {
|
||||
*t.log = append(*t.log, "revoke")
|
||||
return nil
|
||||
}
|
||||
|
||||
type reissueAuth struct {
|
||||
auth.AuthService
|
||||
log *[]string
|
||||
}
|
||||
|
||||
func (a *reissueAuth) ForgetTrustedDevices(context.Context, uuid.UUID) *errx.Error {
|
||||
*a.log = append(*a.log, "forget")
|
||||
return nil
|
||||
}
|
||||
|
||||
type reissueAdmins struct {
|
||||
organization.OrganizationService
|
||||
perms models.AdminPermission
|
||||
}
|
||||
|
||||
func (o reissueAdmins) GetUserAdminPermissions(context.Context, uuid.UUID) (uint32, error) {
|
||||
return uint32(o.perms), nil
|
||||
}
|
||||
|
||||
// reissueRouter registers the handler behind the same gates routes.go gives it.
|
||||
func reissueRouter(h *Handler, session *models.Session, perms models.AdminPermission) *gin.Engine {
|
||||
gin.SetMode(gin.TestMode)
|
||||
m := &middleware.Handler{OrganizationService: reissueAdmins{perms: perms}}
|
||||
r := gin.New()
|
||||
r.Use(func(c *gin.Context) {
|
||||
if session != nil {
|
||||
c.Set(middleware.SessionKey, session)
|
||||
}
|
||||
c.Next()
|
||||
})
|
||||
r.POST("/admin/testers/:id/password", m.AdminMiddleware(), middleware.RequireAdminPermission(models.AdminPermManageTesters), middleware.RequireFreshAuth(), h.AdminReissueTesterPassword)
|
||||
return r
|
||||
}
|
||||
|
||||
func reissue(r *gin.Engine) *httptest.ResponseRecorder {
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/admin/testers/"+uuid.NewString()+"/password", strings.NewReader("")))
|
||||
return w
|
||||
}
|
||||
|
||||
func reissueFixture(tester bool) (*Handler, *reissueUsers, *[]string) {
|
||||
var log []string
|
||||
users := &reissueUsers{tester: tester, log: &log}
|
||||
h := &Handler{UserRepo: users, TokenService: &reissueTokens{log: &log}, AuthService: &reissueAuth{log: &log}}
|
||||
return h, users, &log
|
||||
}
|
||||
|
||||
// A fresh, MFA-verified admin with manage_testers gets a new 48-hour initial
|
||||
// password; sessions and remembered devices end before it is stored.
|
||||
func TestAdminReissueTesterPassword(t *testing.T) {
|
||||
h, users, log := reissueFixture(true)
|
||||
now := time.Now()
|
||||
w := reissue(reissueRouter(h, &models.Session{UserID: uuid.New(), MFAVerified: true, ReauthAt: &now}, models.AdminPermManageTesters))
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("HTTP %d: %s", w.Code, w.Body.String())
|
||||
}
|
||||
var res adminReissueTesterPasswordResponse
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &res); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(res.Password, "Tester-") || len(res.Password) != len("Tester-")+20 || !res.PasswordChangeRequired {
|
||||
t.Fatalf("response %+v", res)
|
||||
}
|
||||
if ok, _ := argon2.Verify(res.Password, users.hash); !ok {
|
||||
t.Fatal("the stored hash is not the returned password's")
|
||||
}
|
||||
if left := time.Until(res.PasswordExpiresAt); left > 48*time.Hour || left < 47*time.Hour {
|
||||
t.Fatalf("expires in %v", left)
|
||||
}
|
||||
if got := strings.Join(*log, ","); got != "revoke,forget,store,revoke" {
|
||||
t.Fatalf("order = %s, want sessions and devices ended before the store", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing is revoked or stored unless every gate passes and the account was created as a tester.
|
||||
func TestAdminReissueTesterPasswordRefusals(t *testing.T) {
|
||||
now, stale := time.Now(), time.Now().Add(-time.Hour)
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
session *models.Session
|
||||
perms models.AdminPermission
|
||||
tester bool
|
||||
missing bool
|
||||
code int
|
||||
}{
|
||||
{"not created as a tester", &models.Session{UserID: uuid.New(), MFAVerified: true, ReauthAt: &now}, models.AdminPermManageTesters, false, false, http.StatusNotFound},
|
||||
{"unknown account", &models.Session{UserID: uuid.New(), MFAVerified: true, ReauthAt: &now}, models.AdminPermManageTesters, true, true, http.StatusNotFound},
|
||||
{"admin without a second factor", &models.Session{UserID: uuid.New(), ReauthAt: &now}, models.AdminPermManageTesters, true, false, http.StatusForbidden},
|
||||
{"admin without manage_testers", &models.Session{UserID: uuid.New(), MFAVerified: true, ReauthAt: &now}, models.AdminPermViewUsers, true, false, http.StatusForbidden},
|
||||
{"no recent confirmation", &models.Session{UserID: uuid.New(), MFAVerified: true, ReauthAt: &stale}, models.AdminPermManageTesters, true, false, http.StatusForbidden},
|
||||
{"not an admin", &models.Session{UserID: uuid.New(), MFAVerified: true, ReauthAt: &now}, 0, true, false, http.StatusForbidden},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
h, users, log := reissueFixture(tc.tester)
|
||||
users.missing = tc.missing
|
||||
w := reissue(reissueRouter(h, tc.session, tc.perms))
|
||||
if w.Code != tc.code {
|
||||
t.Fatalf("HTTP %d, want %d: %s", w.Code, tc.code, w.Body.String())
|
||||
}
|
||||
if users.reissued != 0 || len(*log) != 0 {
|
||||
t.Fatalf("a refused call did %v", *log)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -23,13 +23,15 @@ type testerUsers struct {
|
||||
repository.UserRepository
|
||||
userID uuid.UUID
|
||||
until time.Time
|
||||
// stored, when set, is the expiry the database kept in place of the requested one.
|
||||
stored *time.Time
|
||||
}
|
||||
|
||||
func (r *testerUsers) GetUserByEmail(context.Context, string) (*models.User, error) { return nil, nil }
|
||||
|
||||
func (r *testerUsers) CreateExemptUser(_ context.Context, email *mail.Address, _, _ string, _ *uuid.UUID, until time.Time) (*models.User, error) {
|
||||
r.until = until
|
||||
return &models.User{ID: r.userID, Email: email.Address}, nil
|
||||
return &models.User{ID: r.userID, Email: email.Address, PasswordExpiresAt: r.stored}, nil
|
||||
}
|
||||
|
||||
type testerWorkspaces struct {
|
||||
@@ -172,3 +174,31 @@ func TestTesterPasswordLifetimeIsAtMostTwoDays(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The response and the workspace grant carry the expiry the database stored, and the password is marked initial.
|
||||
func TestAdminCreateTesterUsesTheStoredExpiry(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
stored := time.Now().Add(47 * time.Hour).Truncate(time.Second)
|
||||
users := &testerUsers{userID: uuid.New(), stored: &stored}
|
||||
orgs := &testerWorkspaces{orgID: uuid.New()}
|
||||
h := &Handler{UserRepo: users, OrganizationService: orgs}
|
||||
r := gin.New()
|
||||
r.Use(func(c *gin.Context) { c.Set(middleware.AdminUserIDKey, uuid.New()) })
|
||||
r.POST("/testers", h.AdminCreateTester)
|
||||
body := `{"email":"` + "reviewer" + "@example.test" + `","reason":"OAuth review"}`
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/testers", strings.NewReader(body)))
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("HTTP %d", w.Code)
|
||||
}
|
||||
var response adminCreateTesterResponse
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &response); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !response.PasswordExpiresAt.Equal(stored) || !orgs.until.Equal(stored) {
|
||||
t.Fatalf("response %v, grant %v; want the stored %v", response.PasswordExpiresAt, orgs.until, stored)
|
||||
}
|
||||
if !response.PasswordChangeRequired {
|
||||
t.Fatal("an issued password was not marked as one to change")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,11 @@ func (h *Handler) AdminWarmupContentOverview(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
totalDemand, _ := h.WarmupContentRepo.WarmupSendsSince(ctx, time.Now().AddDate(0, 0, -7))
|
||||
mailboxDemand, err := h.WarmupContentRepo.WarmupMailboxDemandSince(ctx, time.Now().AddDate(0, 0, -7))
|
||||
if err != nil {
|
||||
errx.JSON(c, errx.InternalError())
|
||||
return
|
||||
}
|
||||
|
||||
stock := make([]warmupSegmentStock, 0, 1)
|
||||
for _, pool := range settings.Pools {
|
||||
@@ -161,12 +165,16 @@ func (h *Handler) AdminWarmupContentOverview(c *gin.Context) {
|
||||
segmentSet[segment] = struct{}{}
|
||||
}
|
||||
for seg := range segmentSet {
|
||||
active, _ := h.WarmupContentRepo.CountActiveConversations(ctx, pool.PoolType, seg)
|
||||
recent := totalDemand
|
||||
active, err := h.WarmupContentRepo.CountAvailableConversations(ctx, pool.PoolType, seg)
|
||||
if err != nil {
|
||||
errx.JSON(c, errx.InternalError())
|
||||
return
|
||||
}
|
||||
recent := mailboxDemand
|
||||
stock = append(stock, warmupSegmentStock{
|
||||
Segment: seg,
|
||||
Active: active,
|
||||
Target: warmupcontent.AdaptiveThreadTarget(recent, settings.AISelectionShare, pool.TargetActiveThreads),
|
||||
Target: warmupcontent.AdaptiveThreadTarget(recent, pool.TargetActiveThreads),
|
||||
RecentSends: recent,
|
||||
AverageDailySends: (recent + 6) / 7,
|
||||
})
|
||||
|
||||
@@ -55,6 +55,26 @@ func (h *Handler) LoginConfirm(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// LoginInitialPassword answers a password_change_required sign-in. Public
|
||||
// like /login/confirm: the single-use challenge from LoginStart is the proof.
|
||||
func (h *Handler) LoginInitialPassword(c *gin.Context) {
|
||||
var data auth.InitialPasswordData
|
||||
if err := c.ShouldBindJSON(&data); err != nil {
|
||||
errx.Handle(c, errx.InvalidBody(err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), authRequestTimeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := h.AuthService.CompleteInitialPassword(ctx, &data, c.ClientIP(), c.Request.UserAgent())
|
||||
if err != nil {
|
||||
errx.Handle(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func (h *Handler) RegistrationStart(c *gin.Context) {
|
||||
var data auth.AuthData
|
||||
|
||||
@@ -114,17 +134,41 @@ func (h *Handler) RefreshToken(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, token)
|
||||
}
|
||||
|
||||
// logoutRequest optionally names the remembered-device tokens this browser holds, so signing out forgets them.
|
||||
type logoutRequest struct {
|
||||
DeviceTokens []string `json:"device_tokens"`
|
||||
}
|
||||
|
||||
func (h *Handler) Logout(c *gin.Context) {
|
||||
accessToken := middleware.GetAccessToken(c)
|
||||
|
||||
var req logoutRequest
|
||||
if c.Request.ContentLength != 0 {
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
errx.Handle(c, errx.InvalidBody(err))
|
||||
return
|
||||
}
|
||||
if len(req.DeviceTokens) > maxLogoutDeviceTokens {
|
||||
req.DeviceTokens = req.DeviceTokens[:maxLogoutDeviceTokens]
|
||||
}
|
||||
}
|
||||
|
||||
if err := h.TokenService.RevokeSession(c.Request.Context(), accessToken); err != nil {
|
||||
errx.Handle(c, err)
|
||||
return
|
||||
}
|
||||
if uid, err := middleware.GetUserUUID(c); err == nil && len(req.DeviceTokens) > 0 {
|
||||
if ferr := h.AuthService.ForgetTrustedDevice(c.Request.Context(), uid, req.DeviceTokens); ferr != nil {
|
||||
errx.Handle(c, ferr)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
const maxLogoutDeviceTokens = 16
|
||||
|
||||
func (h *Handler) LogoutAll(c *gin.Context) {
|
||||
accessToken := middleware.GetAccessToken(c)
|
||||
|
||||
@@ -279,6 +323,58 @@ func (h *Handler) ResetPasswordConfirm(c *gin.Context) {
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
|
||||
// SendPasswordLink emails the signed-in user a link to set a password.
|
||||
func (h *Handler) SendPasswordLink(c *gin.Context) {
|
||||
uid, err := uuid.Parse(middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
errx.Handle(c, errx.ErrUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), authRequestTimeout)
|
||||
defer cancel()
|
||||
|
||||
if xerr := h.AuthService.SendPasswordLink(ctx, uid); xerr != nil {
|
||||
errx.Handle(c, xerr)
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
|
||||
// LinkedIdentities lists the providers the signed-in user can sign in with.
|
||||
func (h *Handler) LinkedIdentities(c *gin.Context) {
|
||||
uid, err := uuid.Parse(middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
errx.Handle(c, errx.ErrUnauthorized)
|
||||
return
|
||||
}
|
||||
ids, xerr := h.AuthService.LinkedIdentities(c.Request.Context(), uid)
|
||||
if xerr != nil {
|
||||
errx.Handle(c, xerr)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"data": ids})
|
||||
}
|
||||
|
||||
// UnlinkIdentity removes one provider from the signed-in user's sign-in methods.
|
||||
func (h *Handler) UnlinkIdentity(c *gin.Context) {
|
||||
uid, err := uuid.Parse(middleware.GetUserID(c))
|
||||
if err != nil {
|
||||
errx.Handle(c, errx.ErrUnauthorized)
|
||||
return
|
||||
}
|
||||
session := middleware.GetSession(c)
|
||||
if session == nil || session.UserID != uid {
|
||||
errx.Handle(c, errx.ErrUnauthorized)
|
||||
return
|
||||
}
|
||||
if xerr := h.AuthService.UnlinkIdentity(c.Request.Context(), uid, session.ID, c.Param("provider")); xerr != nil {
|
||||
errx.Handle(c, xerr)
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// ChangePassword updates the signed-in user's password (current + new). Every
|
||||
// session ends with it; the response carries the token pair of a new session
|
||||
// for this device, and the client must use it from here on.
|
||||
|
||||
@@ -3,14 +3,15 @@ package handler
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/warmbly/warmbly/internal/api/middleware"
|
||||
)
|
||||
|
||||
// Access logging for every internal endpoint that hands a node something worth
|
||||
// more than a record: the data-key decrypt broker, the blob presigner, the
|
||||
// node env and the managed-mailbox access token. Each access, allowed or
|
||||
// refused, leaves one line naming the operation, the subject, the caller and
|
||||
// the outcome, so an operator can see a misconfigured node or someone holding
|
||||
// a node credential and looking around.
|
||||
// refused, leaves one line naming the operation, the subject, the node that
|
||||
// asked, the caller's address and the outcome, so an operator can see a
|
||||
// misconfigured node or someone holding a node credential and looking around.
|
||||
//
|
||||
// Never logged: ciphertext, plaintext keys, signed URLs, env contents or
|
||||
// tokens. The record is who asked for what shape of thing and whether it was
|
||||
@@ -24,9 +25,18 @@ func logBrokerAccess(c *gin.Context, operation, subject string, allowed bool, re
|
||||
Str("event", "broker_access").
|
||||
Str("operation", operation).
|
||||
Str("subject", subject).
|
||||
Str("node_id", brokerCaller(c)).
|
||||
Bool("allowed", allowed).
|
||||
Str("client_ip", c.ClientIP()).
|
||||
Str("request_id", c.GetHeader("X-Request-Id")).
|
||||
Str("reason", reason).
|
||||
Msg("internal broker access")
|
||||
}
|
||||
|
||||
// brokerCaller names the node whose own credential admitted the call, or "fleet_token".
|
||||
func brokerCaller(c *gin.Context) string {
|
||||
if id, ok := middleware.AuthenticatedNodeID(c); ok {
|
||||
return id.String()
|
||||
}
|
||||
return "fleet_token"
|
||||
}
|
||||
|
||||
@@ -335,6 +335,10 @@ func (h *Handler) InternalCloudLinkToken(c *gin.Context) {
|
||||
errx.JSON(c, errx.ErrUuid)
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "cloud_link.token", http.StatusNotFound, uuid.Nil, id) {
|
||||
logBrokerAccess(c, "cloud_link.token", id.String(), false, "mailbox outside the node's assignment")
|
||||
return
|
||||
}
|
||||
// A mailbox under an administrator's grant is minted for here, not by the cloud.
|
||||
if h.DelegationService != nil {
|
||||
tok, handled, xerr := h.DelegationService.AccessToken(c.Request.Context(), id)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog"
|
||||
zlog "github.com/rs/zerolog/log"
|
||||
"github.com/warmbly/warmbly/internal/api/middleware"
|
||||
"github.com/warmbly/warmbly/internal/app/fleetnode"
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
)
|
||||
|
||||
// A node admitted by its own credential acts only as itself, and the broker log names it.
|
||||
func TestNodeAuthenticatedByCredentialActsOnlyAsItself(t *testing.T) {
|
||||
setInstanceEnv(t)
|
||||
t.Setenv("NODE_BROKER_TOKEN", "fleet")
|
||||
t.Setenv("NODE_REQUIRE_NODE_CREDENTIAL", "true")
|
||||
var logs bytes.Buffer
|
||||
prev := zlog.Logger
|
||||
zlog.Logger = zerolog.New(&logs)
|
||||
defer func() { zlog.Logger = prev }()
|
||||
|
||||
worker, other := uuid.New(), uuid.New()
|
||||
fleet := &fleetOf{
|
||||
roles: map[uuid.UUID]models.NodeRole{worker: models.NodeRoleWorker, other: models.NodeRoleWorker},
|
||||
hashes: map[uuid.UUID]string{},
|
||||
}
|
||||
svc := fleetnode.New(fleet, nil, joinSettings{})
|
||||
secret, err := svc.IssueNodeCredential(t.Context(), worker)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h := &Handler{FleetNodes: svc}
|
||||
m := &middleware.Handler{NodeCredentials: svc}
|
||||
r := gin.New()
|
||||
r.GET("/api/v1/internal/fleet/node-env", m.NodeBrokerAuthMiddleware(), h.InternalFleetNodeEnv)
|
||||
r.POST("/api/v1/internal/fleet/heartbeat", m.NodeHeartbeatAuthMiddleware(), h.FleetHeartbeat)
|
||||
|
||||
send := func(req *http.Request, withID bool) int {
|
||||
if withID {
|
||||
req.Header.Set(nodeauth.IDHeader, worker.String())
|
||||
}
|
||||
req.Header.Set(nodeauth.CredentialHeader, secret)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
return w.Code
|
||||
}
|
||||
|
||||
if code := send(httptest.NewRequest(http.MethodGet, "/api/v1/internal/fleet/node-env?node_id="+worker.String()+"&role=worker", nil), true); code != http.StatusOK {
|
||||
t.Fatalf("own env: %d", code)
|
||||
}
|
||||
// The updater names its node only in the query, as it always has.
|
||||
if code := send(httptest.NewRequest(http.MethodGet, "/api/v1/internal/fleet/node-env?node_id="+worker.String()+"&role=worker", nil), false); code != http.StatusOK {
|
||||
t.Fatalf("own env named in the query: %d", code)
|
||||
}
|
||||
if code := send(httptest.NewRequest(http.MethodGet, "/api/v1/internal/fleet/node-env?node_id="+other.String()+"&role=worker", nil), true); code != http.StatusForbidden {
|
||||
t.Fatalf("another node's env: %d, want 403", code)
|
||||
}
|
||||
beat := httptest.NewRequest(http.MethodPost, "/api/v1/internal/fleet/heartbeat",
|
||||
strings.NewReader(`{"node_id":"`+other.String()+`","role":"worker"}`))
|
||||
beat.Header.Set("Content-Type", "application/json")
|
||||
if code := send(beat, true); code != http.StatusForbidden {
|
||||
t.Fatalf("a heartbeat for another node: %d, want 403", code)
|
||||
}
|
||||
|
||||
out := logs.String()
|
||||
if !strings.Contains(out, `"node_id":"`+worker.String()+`"`) || strings.Contains(out, secret) {
|
||||
t.Fatalf("the broker log must name the node and never its credential: %s", out)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/errx"
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/observability/errs"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
"github.com/warmbly/warmbly/internal/pkg/publicip"
|
||||
)
|
||||
|
||||
@@ -187,6 +188,14 @@ func (h *Handler) FleetHeartbeat(c *gin.Context) {
|
||||
h.fleetUpdateOnlyHeartbeat(c, beat)
|
||||
return
|
||||
}
|
||||
if caller, ok := middleware.AuthenticatedNodeID(c); ok {
|
||||
if caller != beat.NodeID {
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "a node may heartbeat only as itself"})
|
||||
return
|
||||
}
|
||||
} else if _, seen := fleetTokenNodes.LoadOrStore(beat.NodeID, struct{}{}); !seen {
|
||||
log.Warn().Str("node_id", beat.NodeID.String()).Msg("fleet: node heartbeats without its own node credential; it will be refused once NODE_REQUIRE_NODE_CREDENTIAL is on. Update it, or join it again if it predates node credentials")
|
||||
}
|
||||
beat.Address = heartbeatAddress(beat.Address)
|
||||
reply, err := h.FleetNodes.Heartbeat(c.Request.Context(), beat)
|
||||
if err != nil {
|
||||
@@ -237,7 +246,7 @@ func (h *Handler) nodeEnvFor(ctx context.Context, id uuid.UUID, role models.Node
|
||||
}
|
||||
|
||||
// nodeCredentialHeader carries the credential join issued to one node, next to the fleet bearer.
|
||||
const nodeCredentialHeader = "X-Warmbly-Node-Credential"
|
||||
const nodeCredentialHeader = nodeauth.CredentialHeader
|
||||
|
||||
// InternalFleetNodeEnv hands an enrolled node the env file join would write
|
||||
// today, so a rotated value reaches it by pulling instead of rejoining. The
|
||||
@@ -268,7 +277,13 @@ func (h *Handler) InternalFleetNodeEnv(c *gin.Context) {
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
reason := "node credential"
|
||||
if credential := c.GetHeader(nodeCredentialHeader); credential != "" {
|
||||
if caller, ok := middleware.AuthenticatedNodeID(c); ok {
|
||||
if caller != id {
|
||||
logBrokerAccess(c, op, id.String(), false, "node asked for another node's env")
|
||||
c.JSON(http.StatusForbidden, gin.H{"error": "a node may fetch only its own env"})
|
||||
return
|
||||
}
|
||||
} else if credential := c.GetHeader(nodeCredentialHeader); credential != "" {
|
||||
switch err := h.FleetNodes.VerifyNodeCredential(ctx, id, credential); {
|
||||
case errors.Is(err, fleetnode.ErrNoNodeCredential), errors.Is(err, fleetnode.ErrBadNodeCredential):
|
||||
logBrokerAccess(c, op, id.String(), false, err.Error())
|
||||
@@ -300,6 +315,9 @@ func (h *Handler) InternalFleetNodeEnv(c *gin.Context) {
|
||||
// legacyTokenNodes remembers which nodes were already warned about, so the log says it once per process.
|
||||
var legacyTokenNodes sync.Map
|
||||
|
||||
// fleetTokenNodes remembers which nodes were already warned for beating on the fleet token alone.
|
||||
var fleetTokenNodes sync.Map
|
||||
|
||||
// fleetUpdateOnlyHeartbeat answers a node still on INTERNAL_API_TOKEN with its version only.
|
||||
func (h *Handler) fleetUpdateOnlyHeartbeat(c *gin.Context, beat models.NodeHeartbeat) {
|
||||
reply, err := h.FleetNodes.UpdateOnly(c.Request.Context(), beat)
|
||||
|
||||
@@ -49,6 +49,7 @@ import (
|
||||
"github.com/warmbly/warmbly/internal/app/mcp"
|
||||
"github.com/warmbly/warmbly/internal/app/monitoring"
|
||||
"github.com/warmbly/warmbly/internal/app/nodelogs"
|
||||
"github.com/warmbly/warmbly/internal/app/nodescope"
|
||||
"github.com/warmbly/warmbly/internal/app/notification"
|
||||
"github.com/warmbly/warmbly/internal/app/oauth"
|
||||
"github.com/warmbly/warmbly/internal/app/opsnotify"
|
||||
@@ -201,6 +202,8 @@ type Handler struct {
|
||||
// Fleet. Nodes enrol with the join token and pull everything else; the
|
||||
// control plane never reaches into a machine.
|
||||
FleetNodes *fleetnode.Service
|
||||
// NodeScope binds a worker node's internal calls to its assignment; nil binds nothing.
|
||||
NodeScope *nodescope.Service
|
||||
// KeyStatusDB is the pool the admin key status scans read through. Nil turns the page off.
|
||||
KeyStatusDB keystatus.DB
|
||||
NodeLogs nodelogs.Store
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/warmbly/warmbly/internal/infrastructure/storage"
|
||||
)
|
||||
|
||||
@@ -101,6 +103,12 @@ func (h *Handler) InternalPresignBlob(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
if !h.nodeInScope(c, "blob.presign", http.StatusForbidden, func(ctx context.Context, node uuid.UUID) (bool, error) {
|
||||
return h.NodeScope.BlobKey(ctx, node, req.Key)
|
||||
}) {
|
||||
logBrokerAccess(c, "blob.presign."+string(op), req.Key, false, "key outside the node's assignment")
|
||||
return
|
||||
}
|
||||
logBrokerAccess(c, "blob.presign."+string(op), req.Key, true, "")
|
||||
|
||||
url, err := h.Storage.PresignedURL(c.Request.Context(), op, req.Key, req.ContentType, blobPresignTTL)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -48,6 +49,9 @@ func (h *Handler) InternalGetDEK(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if !h.nodeOrganization(c, "dek.get", id) {
|
||||
return
|
||||
}
|
||||
v, err := h.EncryptedKeys.Get(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
errx.JSON(c, errx.New(errx.Internal, err.Error()))
|
||||
@@ -65,6 +69,9 @@ func (h *Handler) InternalPutDEK(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if !h.nodeOrganization(c, "dek.put", id) {
|
||||
return
|
||||
}
|
||||
body, err := io.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "read body"})
|
||||
@@ -101,6 +108,7 @@ func (h *Handler) InternalPutDEK(c *gin.Context) {
|
||||
// It takes ciphertext and returns plaintext, with no organization id anywhere
|
||||
// in the exchange: a caller can only open a key it was already given, so this
|
||||
// grants nothing beyond what holding the sealed key and the token already did.
|
||||
// A worker that presents its own credential opens only its assigned organizations' keys.
|
||||
func (h *Handler) InternalDecryptDEK(c *gin.Context) {
|
||||
if h.KMS == nil {
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "no kms provider configured"})
|
||||
@@ -115,6 +123,12 @@ func (h *Handler) InternalDecryptDEK(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "encrypted_data_key required"})
|
||||
return
|
||||
}
|
||||
if !h.nodeInScope(c, "dek.decrypt", http.StatusNotFound, func(ctx context.Context, node uuid.UUID) (bool, error) {
|
||||
return h.NodeScope.DataKey(ctx, node, p.EncryptedDataKey)
|
||||
}) {
|
||||
logBrokerAccess(c, "dek.decrypt", "", false, "data key outside the node's assignment")
|
||||
return
|
||||
}
|
||||
key, err := h.KMS.GetDecryptedKey(c.Request.Context(), p.EncryptedDataKey)
|
||||
if err != nil {
|
||||
// The reason is not echoed: this answers an unauthenticated-by-org
|
||||
|
||||
@@ -14,6 +14,9 @@ func (h *Handler) InternalDiagnosticAuth(c *gin.Context) {
|
||||
c.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !h.nodeWorkerMailbox(c, "worker.diagnostic_auth", http.StatusForbidden, request.WorkerID, request.MailboxID) {
|
||||
return
|
||||
}
|
||||
authority, ok := h.WarmupDispatch.(repository.DiagnosticAuthAuthority)
|
||||
if !ok {
|
||||
c.Status(http.StatusServiceUnavailable)
|
||||
|
||||
@@ -23,6 +23,9 @@ func (h *Handler) InternalAdmitEmailArrival(c *gin.Context) {
|
||||
c.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if user, mailbox := mapScope(p.Map.UserID, p.Map.EmailID); !h.nodeMailbox(c, "email_message_map.arrival", http.StatusNotFound, user, mailbox) {
|
||||
return
|
||||
}
|
||||
repo, ok := h.EmailMessageMap.(repository.ArrivalAdmission)
|
||||
if !ok {
|
||||
logArrivalAdmissionFailure(c, p.Map, repository.ErrArrivalOutboxUnsupported)
|
||||
@@ -96,6 +99,9 @@ func (h *Handler) InternalLookupEmailMessageMaps(c *gin.Context) {
|
||||
c.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "email_message_map.lookup", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
for _, id := range payload.MessageIDs {
|
||||
if id == "" {
|
||||
c.Status(http.StatusBadRequest)
|
||||
@@ -129,6 +135,9 @@ func (h *Handler) InternalPutEmailMessageMap(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "user_id, email_id, message_id, id required"})
|
||||
return
|
||||
}
|
||||
if user, mailbox := mapScope(p.UserID, p.EmailID); !h.nodeMailbox(c, "email_message_map.put", http.StatusNotFound, user, mailbox) {
|
||||
return
|
||||
}
|
||||
err = h.EmailMessageMap.Add(c.Request.Context(), repository.EmailMessageData{
|
||||
UserID: p.UserID,
|
||||
EmailID: p.EmailID,
|
||||
@@ -148,6 +157,9 @@ func (h *Handler) InternalGetEmailMessageMap(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "email_message_map.get", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
data, err := h.EmailMessageMap.Get(c.Request.Context(), userID, emailID, messageID)
|
||||
if err != nil {
|
||||
errx.JSON(c, errx.New(errx.Internal, err.Error()))
|
||||
@@ -171,6 +183,9 @@ func (h *Handler) InternalDeleteEmailMessageMap(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "email_message_map.delete", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
var id uuid.UUID
|
||||
if raw := c.Query("id"); raw != "" {
|
||||
parsed, err := uuid.Parse(raw)
|
||||
|
||||
@@ -35,6 +35,9 @@ func (h *Handler) InternalSyncOwnConversation(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid email_id"})
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "sync.own_conversation", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
var ids []string
|
||||
for _, raw := range strings.Split(c.Query("message_ids"), ",") {
|
||||
if id := strings.TrimSpace(raw); id != "" {
|
||||
@@ -72,6 +75,9 @@ func (h *Handler) InternalSyncFolderMessages(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid email_id"})
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "sync.folder_messages", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
folderPath := c.Query("folder_path")
|
||||
if folderPath == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "folder_path required"})
|
||||
@@ -104,6 +110,9 @@ func (h *Handler) InternalSyncProviderMessages(c *gin.Context) {
|
||||
errx.JSON(c, errx.ErrUuid)
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "sync.provider_messages", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
var after *uuid.UUID
|
||||
if raw := c.Query("after"); raw != "" {
|
||||
id, err := uuid.Parse(raw)
|
||||
@@ -153,6 +162,9 @@ func (h *Handler) InternalSyncProviderFolderMessages(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid email_id"})
|
||||
return
|
||||
}
|
||||
if !h.nodeMailbox(c, "sync.provider_folder_messages", http.StatusNotFound, userID, emailID) {
|
||||
return
|
||||
}
|
||||
var folders []string
|
||||
for _, raw := range strings.Split(c.Query("folders"), ",") {
|
||||
f := strings.TrimSpace(raw)
|
||||
|
||||
@@ -23,6 +23,9 @@ func (h *Handler) InternalWarmupActions(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if !h.nodeWorkerMailbox(c, "worker.warmup_actions", http.StatusNotFound, req.WorkerID, req.MailboxID) {
|
||||
return
|
||||
}
|
||||
if r, ok := h.WarmupDispatch.(repository.WarmupActionRecoveryAdmission); ok {
|
||||
decision, err := r.AdmitWarmupAction(c.Request.Context(), req)
|
||||
if err != nil {
|
||||
@@ -52,6 +55,9 @@ func (h *Handler) InternalWarmupFilingDeferral(c *gin.Context) {
|
||||
c.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !h.nodeWorkerMailbox(c, "worker.warmup_filing_deferral", http.StatusForbidden, req.WorkerID, req.MailboxID) {
|
||||
return
|
||||
}
|
||||
r, ok := h.WarmupDispatch.(repository.WarmupFilingDeferralAuthority)
|
||||
if !ok {
|
||||
c.Status(http.StatusServiceUnavailable)
|
||||
|
||||
@@ -28,6 +28,9 @@ func (h *Handler) InternalWarmupDispatch(c *gin.Context) {
|
||||
c.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !h.nodeWorkerMailbox(c, "worker.warmup_dispatch", http.StatusNotFound, req.WorkerID, req.MailboxID) {
|
||||
return
|
||||
}
|
||||
ctx := c.Request.Context()
|
||||
if admission, ok := h.WarmupDispatch.(repository.OutboundAdmissionRepository); ok {
|
||||
state, err := admission.InspectOutbound(ctx, req.TaskID, req.MailboxID, req.WorkerID)
|
||||
|
||||
@@ -46,7 +46,13 @@ func newOutboundStartFixture(t *testing.T) *outboundStartFixture {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(handle.Pool.Close)
|
||||
f := &outboundStartFixture{db: handle, user: uuid.New(), org: uuid.New(), sender: uuid.New(), recipient: uuid.New(), task: uuid.New(), worker: uuid.New(), source: tasks.VettedDiagnosticConversations()[0]}
|
||||
f := &outboundStartFixture{db: handle, user: uuid.New(), org: uuid.New(), sender: uuid.New(), recipient: uuid.New(), task: uuid.New(), worker: uuid.New(), source: tasks.Conversation{ID: uuid.New(), Version: generation.WarmupScenarioVersion, Subject: "A wording choice", Description: "I'm rewording the labels on our intake form and can't pick between two options. Which one reads clearer to you?", Messages: []string{"The shorter one, I think. It scans faster.", "Agreed, I'll go with that. Thanks for the quick read."}}}
|
||||
contentRepo := repository.NewWarmupContentRepository(handle.Pool)
|
||||
rendering := generation.CanonicalRenderingVersion
|
||||
if err := contentRepo.InsertConversation(t.Context(), &models.WarmupConversation{ID: f.source.ID, PoolType: "premium", Source: models.WarmupContentSourceAI, Subject: f.source.Subject, Description: f.source.Description, Messages: f.source.Messages, Status: models.WarmupConversationActive, LintPassed: true, ReplyEligible: true, ScenarioVersion: &f.source.Version, RenderingVersion: &rendering, SemanticReview: "passed"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = contentRepo.DeleteConversation(context.Background(), f.source.ID) })
|
||||
f.exec(t, `INSERT INTO users(id,email,first_name,last_name,password_hash) VALUES($1,$2,'Start','Test','x')`, f.user, f.user.String()+"@example.test")
|
||||
f.exec(t, `INSERT INTO organizations(id,name,slug,owner_user_id,risk_state) VALUES($1,'Start test',$2,$3,'trusted')`, f.org, f.org.String(), f.user)
|
||||
t.Cleanup(func() {
|
||||
@@ -72,7 +78,7 @@ func newOutboundStartFixture(t *testing.T) *outboundStartFixture {
|
||||
}
|
||||
f.exec(t, `INSERT INTO tasks(id,task_type,email_account_id,status,message_id,scheduled_at) VALUES($1,'warmup',$2,'active','',NOW())`, f.task, f.sender)
|
||||
f.exec(t, `INSERT INTO warmup_tasks(task_id,target_account_id,lineage_version,subject,scenario_version,rendering_version,max_turns) VALUES($1,$2,1,$3,$4,$5,$6)`, f.task, f.recipient, f.source.Subject, f.source.Version, generation.CanonicalRenderingVersion, len(f.source.Messages)+1)
|
||||
f.exec(t, `INSERT INTO warmup_tokens(token,task_id,sender_account_id,recipient_account_id,subject,content_source,conversation_id,conversation_turn) VALUES($1,$2,$3,$4,$5,'static',$6,0)`, uuid.New(), f.task, f.sender, f.recipient, f.source.Subject, f.source.ID)
|
||||
f.exec(t, `INSERT INTO warmup_tokens(token,task_id,sender_account_id,recipient_account_id,subject,content_source,conversation_id,conversation_turn) VALUES($1,$2,$3,$4,$5,'ai',$6,0)`, uuid.New(), f.task, f.sender, f.recipient, f.source.Subject, f.source.ID)
|
||||
f.repo = repository.NewTaskRepository(handle.Pool)
|
||||
f.admission = f.repo.(repository.OutboundAdmissionRepository)
|
||||
f.dispatch = f.repo.(repository.WarmupDispatchRepository)
|
||||
@@ -88,7 +94,7 @@ func newOutboundStartFixture(t *testing.T) *outboundStartFixture {
|
||||
emailRepo := repository.NewEmailRepostory(handle, enc)
|
||||
warmupRepo := repository.NewWarmupRepository(handle.Pool)
|
||||
policy := scheduler.NewSchedulerService(f.repo, warmupRepo, nil, emailRepo, nil, nil, nil)
|
||||
f.svc = tasks.NewService(nil, nil, nil, nil, policy, nil, nil, nil, nil, f.repo, warmupRepo, nil, nil, nil, emailRepo, nil, nil, nil, nil, nil, nil, nil)
|
||||
f.svc = tasks.NewService(nil, nil, nil, nil, policy, nil, nil, nil, nil, f.repo, warmupRepo, nil, contentRepo, nil, emailRepo, nil, nil, nil, nil, nil, nil, nil)
|
||||
f.nonce, err = f.dispatch.AuthorizeWarmupDispatch(t.Context(), f.task, f.sender, f.worker)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -123,7 +129,7 @@ func (f *outboundStartFixture) importPendingSnapshot(t *testing.T, status string
|
||||
rows := map[string][]map[string]any{
|
||||
"tasks": {{"id": f.task, "task_type": "warmup", "email_account_id": f.sender, "status": status, "message_id": "", "send_result_state": "unknown"}},
|
||||
"warmup_tasks": {{"task_id": f.task, "target_account_id": f.recipient, "subject": f.source.Subject}},
|
||||
"warmup_tokens": {{"token": uuid.New(), "task_id": f.task, "sender_account_id": f.sender, "recipient_account_id": f.recipient, "subject": f.source.Subject, "content_source": "static", "conversation_id": f.source.ID, "conversation_turn": 0}},
|
||||
"warmup_tokens": {{"token": uuid.New(), "task_id": f.task, "sender_account_id": f.sender, "recipient_account_id": f.recipient, "subject": f.source.Subject, "content_source": "ai", "conversation_id": f.source.ID, "conversation_turn": 0}},
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
zw := zip.NewWriter(&buf)
|
||||
@@ -185,7 +191,7 @@ func (f *outboundStartFixture) prepareDeferredWarmup(t *testing.T) {
|
||||
}
|
||||
if err := repository.NewWarmupRepository(f.db.Pool).CreateWarmupToken(t.Context(), &models.WarmupToken{
|
||||
Token: uuid.New(), TaskID: f.task, SenderAccountID: f.sender, RecipientAccountID: f.recipient,
|
||||
Subject: f.source.Subject, ContentSource: "static", ConversationID: &f.source.ID,
|
||||
Subject: f.source.Subject, ContentSource: models.WarmupContentSourceAI, ConversationID: &f.source.ID,
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour),
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -519,3 +525,18 @@ func TestLiveWarmupGenericCannotRepeatStartedWarmupClaim(t *testing.T) {
|
||||
t.Fatal("cancel erased already started native warmup claim", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveWarmupGenericDeniesHistoricalDiagnosticContent(t *testing.T) {
|
||||
f := newOutboundStartFixture(t)
|
||||
legacy := tasks.Conversation{ID: uuid.NewSHA1(uuid.NameSpaceOID, []byte("warmbly:diagnostic-clock:v1")), Subject: "Simulated diagnostic: fictional clock"}
|
||||
f.exec(t, `UPDATE warmup_tasks SET subject=$2 WHERE task_id=$1`, f.task, legacy.Subject)
|
||||
f.exec(t, `UPDATE warmup_tokens SET subject=$2,content_source='static',conversation_id=$3 WHERE task_id=$1`, f.task, legacy.Subject, legacy.ID)
|
||||
response, state := f.request(t, f.svc, true, nil)
|
||||
if response.Code != http.StatusOK || state != "denied" {
|
||||
t.Fatalf("historical wording authorized: status=%d state=%s", response.Code, state)
|
||||
}
|
||||
var unstarted bool
|
||||
if err := f.db.QueryRow(t.Context(), `SELECT send_executor_started_at IS NULL FROM tasks WHERE id=$1`, f.task).Scan(&unstarted); err != nil || !unstarted {
|
||||
t.Fatalf("denied content entered native execution: unstarted=%v err=%v", unstarted, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
@@ -59,6 +60,11 @@ func (h *Handler) InternalWorkerConfig(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "valid worker_id query param required"})
|
||||
return
|
||||
}
|
||||
if !h.nodeInScope(c, "worker.config", http.StatusNotFound, func(ctx context.Context, node uuid.UUID) (bool, error) {
|
||||
return h.NodeScope.Worker(ctx, node, id)
|
||||
}) {
|
||||
return
|
||||
}
|
||||
bindIP := c.Query("bind_ip")
|
||||
tag := c.Query("tag")
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/warmbly/warmbly/internal/api/middleware"
|
||||
)
|
||||
|
||||
// nodeScopeRefusals remembers which node and route pairs were already logged, so each is said once per process.
|
||||
var nodeScopeRefusals sync.Map
|
||||
|
||||
// nodeInScope answers whether the node that authenticated this call may act on what it names.
|
||||
// A fleet-token caller is not bound. A false has already answered the caller with refusal.
|
||||
func (h *Handler) nodeInScope(c *gin.Context, route string, refusal int, allowed func(ctx context.Context, node uuid.UUID) (bool, error)) bool {
|
||||
node, ok := middleware.AuthenticatedNodeID(c)
|
||||
if !ok || h.NodeScope == nil {
|
||||
return true
|
||||
}
|
||||
ok, err := allowed(c.Request.Context(), node)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusServiceUnavailable, gin.H{"error": "node assignment could not be checked"})
|
||||
return false
|
||||
}
|
||||
if ok {
|
||||
return true
|
||||
}
|
||||
if _, seen := nodeScopeRefusals.LoadOrStore(node.String()+" "+route, struct{}{}); !seen {
|
||||
log.Warn().Str("event", "node_scope_refused").Str("node_id", node.String()).Str("route", route).
|
||||
Msg("fleet: a worker node named something it is not assigned; refused")
|
||||
}
|
||||
if refusal == http.StatusNotFound {
|
||||
c.AbortWithStatusJSON(refusal, gin.H{"error": "not found"})
|
||||
} else {
|
||||
c.AbortWithStatusJSON(refusal, gin.H{"error": "not assigned to this node"})
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// nodeMailbox binds a call naming a mailbox (and the user it belongs to, when given) to the node's assignment.
|
||||
func (h *Handler) nodeMailbox(c *gin.Context, route string, refusal int, user, mailbox uuid.UUID) bool {
|
||||
return h.nodeInScope(c, route, refusal, func(ctx context.Context, node uuid.UUID) (bool, error) {
|
||||
return h.NodeScope.Mailbox(ctx, node, user, mailbox)
|
||||
})
|
||||
}
|
||||
|
||||
// nodeOrganization binds a call naming an organization to the node's assignment.
|
||||
func (h *Handler) nodeOrganization(c *gin.Context, route string, org uuid.UUID) bool {
|
||||
return h.nodeInScope(c, route, http.StatusNotFound, func(ctx context.Context, node uuid.UUID) (bool, error) {
|
||||
return h.NodeScope.Organization(ctx, node, org)
|
||||
})
|
||||
}
|
||||
|
||||
// parsedOrNil reads an id from a request field; anything unreadable is uuid.Nil, which no node is assigned.
|
||||
func parsedOrNil(raw string) uuid.UUID {
|
||||
id, err := uuid.Parse(raw)
|
||||
if err != nil {
|
||||
return uuid.Nil
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// mapScope reads the user and mailbox a message-map call names; an unreadable user names no mailbox.
|
||||
func mapScope(rawUser, rawMailbox string) (uuid.UUID, uuid.UUID) {
|
||||
user := parsedOrNil(rawUser)
|
||||
if user == uuid.Nil {
|
||||
return uuid.Nil, uuid.Nil
|
||||
}
|
||||
return user, parsedOrNil(rawMailbox)
|
||||
}
|
||||
|
||||
// nodeWorkerMailbox binds a call naming both a worker and one of its mailboxes.
|
||||
func (h *Handler) nodeWorkerMailbox(c *gin.Context, route string, refusal int, worker, mailbox uuid.UUID) bool {
|
||||
return h.nodeInScope(c, route, refusal, func(ctx context.Context, node uuid.UUID) (bool, error) {
|
||||
ok, err := h.NodeScope.Worker(ctx, node, worker)
|
||||
if err != nil || !ok {
|
||||
return ok, err
|
||||
}
|
||||
return h.NodeScope.Mailbox(ctx, node, uuid.Nil, mailbox)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog"
|
||||
zlog "github.com/rs/zerolog/log"
|
||||
"github.com/warmbly/warmbly/internal/api/middleware"
|
||||
"github.com/warmbly/warmbly/internal/app/fleetnode"
|
||||
"github.com/warmbly/warmbly/internal/app/nodescope"
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
)
|
||||
|
||||
// scopeRepo assigns one mailbox of one organization to one worker.
|
||||
type scopeRepo struct {
|
||||
repository.NodeScopeRepository
|
||||
roles map[uuid.UUID]models.NodeRole
|
||||
worker uuid.UUID
|
||||
mailbox repository.NodeMailbox
|
||||
}
|
||||
|
||||
func (r *scopeRepo) NodeRole(_ context.Context, id uuid.UUID) (models.NodeRole, bool, error) {
|
||||
role, ok := r.roles[id]
|
||||
return role, ok, nil
|
||||
}
|
||||
|
||||
func (r *scopeRepo) WorkerMailboxes(_ context.Context, w uuid.UUID, _ time.Duration) ([]repository.NodeMailbox, error) {
|
||||
if w == r.worker {
|
||||
return []repository.NodeMailbox{r.mailbox}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *scopeRepo) WorkerHoldsMailbox(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, time.Duration) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (r *scopeRepo) WorkerHoldsOrganization(context.Context, uuid.UUID, uuid.UUID, time.Duration) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (r *scopeRepo) OrganizationDataKeys(context.Context, []uuid.UUID) ([]string, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type stubKeys struct{}
|
||||
|
||||
func (stubKeys) Put(context.Context, uuid.UUID, string) error { return nil }
|
||||
func (stubKeys) Get(context.Context, uuid.UUID) (string, error) { return "sealed", nil }
|
||||
func (stubKeys) Name() string { return "stub" }
|
||||
|
||||
type stubSyncState struct {
|
||||
repository.EmailSyncStateRepository
|
||||
}
|
||||
|
||||
func (s stubSyncState) IsOwnConversation(context.Context, uuid.UUID, uuid.UUID, []string, string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func TestWorkerNodeCallsAreBoundToItsAssignment(t *testing.T) {
|
||||
setInstanceEnv(t)
|
||||
t.Setenv("NODE_BROKER_TOKEN", "fleet")
|
||||
t.Setenv("NODE_REQUIRE_NODE_CREDENTIAL", "")
|
||||
var logs bytes.Buffer
|
||||
prev := zlog.Logger
|
||||
zlog.Logger = zerolog.New(&logs)
|
||||
defer func() { zlog.Logger = prev }()
|
||||
|
||||
worker, otherWorker, consumer := uuid.New(), uuid.New(), uuid.New()
|
||||
user, org, otherOrg, mailbox := uuid.New(), uuid.New(), uuid.New(), uuid.New()
|
||||
roles := map[uuid.UUID]models.NodeRole{worker: models.NodeRoleWorker, otherWorker: models.NodeRoleWorker, consumer: models.NodeRoleConsumer}
|
||||
fleet := &fleetOf{roles: roles, hashes: map[uuid.UUID]string{}}
|
||||
svc := fleetnode.New(fleet, nil, joinSettings{})
|
||||
creds := map[uuid.UUID]string{}
|
||||
for id := range roles {
|
||||
secret, err := svc.IssueNodeCredential(t.Context(), id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
creds[id] = secret
|
||||
}
|
||||
h := &Handler{
|
||||
FleetNodes: svc,
|
||||
NodeScope: nodescope.New(&scopeRepo{roles: roles, worker: worker, mailbox: repository.NodeMailbox{ID: mailbox, UserID: user, OrganizationID: &org}}, nil),
|
||||
EncryptedKeys: stubKeys{},
|
||||
EmailSyncState: stubSyncState{},
|
||||
}
|
||||
m := &middleware.Handler{NodeCredentials: svc}
|
||||
r := gin.New()
|
||||
r.GET("/api/v1/internal/dek/:orgID", m.NodeAuthMiddleware(), h.InternalGetDEK)
|
||||
r.GET("/api/v1/internal/worker/config", m.NodeAuthMiddleware(), h.InternalWorkerConfig)
|
||||
r.GET("/api/v1/internal/sync/own-conversation", m.NodeAuthMiddleware(), h.InternalSyncOwnConversation)
|
||||
|
||||
call := func(node uuid.UUID, path string) int {
|
||||
req := httptest.NewRequest(http.MethodGet, path, nil)
|
||||
if node == uuid.Nil {
|
||||
req.Header.Set("Authorization", "Bearer fleet")
|
||||
} else {
|
||||
req.Header.Set(nodeauth.IDHeader, node.String())
|
||||
req.Header.Set(nodeauth.CredentialHeader, creds[node])
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
return w.Code
|
||||
}
|
||||
sync := func(u, box uuid.UUID) string {
|
||||
return "/api/v1/internal/sync/own-conversation?user_id=" + u.String() + "&email_id=" + box.String() + "&message_ids=a"
|
||||
}
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
node uuid.UUID
|
||||
path string
|
||||
code int
|
||||
}{
|
||||
{"worker: assigned organization's key", worker, "/api/v1/internal/dek/" + org.String(), http.StatusOK},
|
||||
{"worker: another organization's key", worker, "/api/v1/internal/dek/" + otherOrg.String(), http.StatusNotFound},
|
||||
{"worker: its own config", worker, "/api/v1/internal/worker/config?worker_id=" + worker.String(), http.StatusOK},
|
||||
{"worker: another worker's config", worker, "/api/v1/internal/worker/config?worker_id=" + otherWorker.String(), http.StatusNotFound},
|
||||
{"worker: assigned mailbox sync", worker, sync(user, mailbox), http.StatusOK},
|
||||
{"worker: unassigned mailbox sync", worker, sync(user, uuid.New()), http.StatusNotFound},
|
||||
{"other worker: that mailbox", otherWorker, sync(user, mailbox), http.StatusNotFound},
|
||||
{"consumer: any organization", consumer, "/api/v1/internal/dek/" + otherOrg.String(), http.StatusOK},
|
||||
{"consumer: any mailbox", consumer, sync(user, uuid.New()), http.StatusOK},
|
||||
{"fleet token: any organization", uuid.Nil, "/api/v1/internal/dek/" + otherOrg.String(), http.StatusOK},
|
||||
{"fleet token: any worker", uuid.Nil, "/api/v1/internal/worker/config?worker_id=" + otherWorker.String(), http.StatusOK},
|
||||
} {
|
||||
if got := call(tc.node, tc.path); got != tc.code {
|
||||
t.Fatalf("%s: %d, want %d", tc.name, got, tc.code)
|
||||
}
|
||||
}
|
||||
call(worker, "/api/v1/internal/dek/"+otherOrg.String())
|
||||
|
||||
out := logs.String()
|
||||
if n := strings.Count(out, `"route":"dek.get"`); n != 1 {
|
||||
t.Fatalf("a refusal is logged once per node and route, got %d: %s", n, out)
|
||||
}
|
||||
if !strings.Contains(out, `"node_id":"`+worker.String()+`"`) {
|
||||
t.Fatalf("the refusal names the node: %s", out)
|
||||
}
|
||||
for _, secret := range creds {
|
||||
if strings.Contains(out, secret) {
|
||||
t.Fatal("the log carried a node credential")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -672,7 +672,10 @@ fetch_env() {
|
||||
cred=$(env_value NODE_CREDENTIAL)
|
||||
code=$( {
|
||||
printf 'header = "Authorization: Bearer %s"\n' "$token"
|
||||
if [ -n "$cred" ]; then printf 'header = "X-Warmbly-Node-Credential: %s"\n' "$cred"; fi
|
||||
if [ -n "$cred" ]; then
|
||||
printf 'header = "X-Warmbly-Node-Id: %s"\n' "$id"
|
||||
printf 'header = "X-Warmbly-Node-Credential: %s"\n' "$cred"
|
||||
fi
|
||||
} | curl -sS -K - --max-time 30 -o "$1" -w '%{http_code}' \
|
||||
"${url%/}/api/v1/internal/fleet/node-env?node_id=$id&role=$role") || code=000
|
||||
if [ "$code" != "200" ]; then
|
||||
|
||||
@@ -128,11 +128,11 @@ func (h *Handler) PoolLinkOAuthContinue(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
// The form posts the cookie's value, which only the consent page rendered in this browser knows.
|
||||
// A GET with query values is still taken for a page rendered by the previous release.
|
||||
state, sent := c.Query("state"), c.Query("t")
|
||||
if c.Request.Method == http.MethodPost {
|
||||
state, sent = c.PostForm("state"), c.PostForm("t")
|
||||
if c.Request.Method != http.MethodPost {
|
||||
renderBrokerNotice(c, poollink.ErrOAuthBrowser)
|
||||
return
|
||||
}
|
||||
state, sent := c.PostForm("state"), c.PostForm("t")
|
||||
cookie, _ := c.Cookie(brokerCookieName)
|
||||
if cookie == "" || subtle.ConstantTimeCompare([]byte(cookie), []byte(sent)) != 1 {
|
||||
renderBrokerNotice(c, poollink.ErrOAuthBrowser)
|
||||
@@ -143,9 +143,5 @@ func (h *Handler) PoolLinkOAuthContinue(c *gin.Context) {
|
||||
renderBrokerNotice(c, xerr)
|
||||
return
|
||||
}
|
||||
code := http.StatusFound
|
||||
if c.Request.Method == http.MethodPost {
|
||||
code = http.StatusSeeOther
|
||||
}
|
||||
c.Redirect(code, to)
|
||||
c.Redirect(http.StatusSeeOther, to)
|
||||
}
|
||||
|
||||
@@ -115,8 +115,11 @@ func TestBrokeredSigninCompletesOnlyInTheBrowserThatContinued(t *testing.T) {
|
||||
t.Fatalf("continue from the page = %d, bound %q", w.Code, f.bound)
|
||||
}
|
||||
f.bound = ""
|
||||
if w := serve(t, h.PoolLinkOAuthContinue, "/addresses/connect/continue?state=pl_x&t="+token, cookies[0]); w.Code != http.StatusFound || f.bound != token {
|
||||
t.Fatalf("continue from a page rendered by the previous release = %d, bound %q", w.Code, f.bound)
|
||||
if w := serve(t, h.PoolLinkOAuthContinue, "/addresses/connect/continue?state=pl_x&t="+token, cookies[0]); w.Code == http.StatusFound || w.Code == http.StatusSeeOther || f.bound != "" {
|
||||
t.Fatalf("continue with the binding value in the URL = %d, bound %q", w.Code, f.bound)
|
||||
}
|
||||
if w := servePost(t, h.PoolLinkOAuthContinue, url.Values{"state": {"pl_x"}, "t": {token}}, cookies[0]); w.Code != http.StatusSeeOther || f.bound != token {
|
||||
t.Fatalf("continue from the page again = %d, bound %q", w.Code, f.bound)
|
||||
}
|
||||
|
||||
if w := serve(t, h.EmailOAuthCallbackGmail, "/addresses/google/callback?state=pl_x&code=c"); w.Code == http.StatusFound || strings.Contains(w.Body.String(), "postMessage") {
|
||||
|
||||
@@ -148,6 +148,30 @@ func (h *Handler) VerifyDomainRedirect(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, r)
|
||||
}
|
||||
|
||||
type websiteProofRequest struct {
|
||||
TargetURL string `json:"target_url"`
|
||||
}
|
||||
|
||||
// VerifyRedirectWebsite is POST /emails/domains/:domain/redirect/website: the
|
||||
// TXT record that makes the destination's website the workspace's, checked now. Safe to repeat.
|
||||
func (h *Handler) VerifyRedirectWebsite(c *gin.Context) {
|
||||
orgID, _, ok := importCaller(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req websiteProofRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
errx.Handle(c, errx.ErrInvalid)
|
||||
return
|
||||
}
|
||||
w, xerr := h.SendingDomainService.WebsiteProof(c.Request.Context(), orgID, c.Param("domain"), req.TargetURL)
|
||||
if xerr != nil {
|
||||
errx.Handle(c, xerr)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, w)
|
||||
}
|
||||
|
||||
// DeleteDomainRedirect is DELETE /emails/domains/:domain/redirect.
|
||||
func (h *Handler) DeleteDomainRedirect(c *gin.Context) {
|
||||
orgID, _, ok := importCaller(c)
|
||||
|
||||
@@ -26,4 +26,6 @@ type Handler struct {
|
||||
Cache *cache.Cache
|
||||
// PoolLinkService authenticates linked instances; nil-safe, routes answer 501.
|
||||
PoolLinkService poollink.Service
|
||||
// NodeCredentials verifies a fleet node's own credential on the node-only routes; nil admits none.
|
||||
NodeCredentials NodeCredentialVerifier
|
||||
}
|
||||
|
||||
@@ -50,14 +50,18 @@ func internalAuth(c *gin.Context) {
|
||||
}
|
||||
|
||||
// NodeBrokerAuthMiddleware protects the internal routes only fleet nodes
|
||||
// call: key material, blob signing, the message map, sync lookups, worker
|
||||
// config and the node heartbeat.
|
||||
// call: key material, blob signing, the cloud-link token and the node env.
|
||||
//
|
||||
// NODE_BROKER_TOKEN is that credential, kept apart from the one the
|
||||
// internet-facing tracking and forms services carry. It falls back to
|
||||
// INTERNAL_API_TOKEN when unset, so a single-token deployment keeps working.
|
||||
// A node is admitted by its own NODE_CREDENTIAL and is then named on the
|
||||
// request. Unless NODE_REQUIRE_NODE_CREDENTIAL is on, NODE_BROKER_TOKEN (else
|
||||
// INTERNAL_API_TOKEN) is also accepted, kept apart from the edge services' token.
|
||||
func (h *Handler) NodeBrokerAuthMiddleware() gin.HandlerFunc {
|
||||
return nodeBrokerAuth
|
||||
return func(c *gin.Context) {
|
||||
if h.authenticateNode(c) {
|
||||
return
|
||||
}
|
||||
nodeBrokerAuth(c)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -94,9 +98,12 @@ func previousTokenMatches(provided []byte, prefix string) bool {
|
||||
return matched
|
||||
}
|
||||
|
||||
// NodeAuthMiddleware guards node-only routes on NODE_BROKER_TOKEN; NODE_ACCEPT_INTERNAL_TOKEN=true also admits INTERNAL_API_TOKEN while older nodes upgrade.
|
||||
// NodeAuthMiddleware guards node-only routes on the node's own credential, or NODE_BROKER_TOKEN while it is not required; NODE_ACCEPT_INTERNAL_TOKEN=true also admits INTERNAL_API_TOKEN while older nodes upgrade.
|
||||
func (h *Handler) NodeAuthMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if h.authenticateNode(c) {
|
||||
return
|
||||
}
|
||||
brokerTokenOnce.Do(loadBrokerToken)
|
||||
var legacy []byte
|
||||
if os.Getenv("NODE_ACCEPT_INTERNAL_TOKEN") == "true" {
|
||||
@@ -114,6 +121,9 @@ const nodeUpdateOnlyKey = "node_update_only"
|
||||
// always learn the version that sends NODE_BROKER_TOKEN.
|
||||
func (h *Handler) NodeHeartbeatAuthMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if h.authenticateNode(c) {
|
||||
return
|
||||
}
|
||||
brokerTokenOnce.Do(loadBrokerToken)
|
||||
shared := []byte(os.Getenv("INTERNAL_API_TOKEN"))
|
||||
if os.Getenv("NODE_ACCEPT_INTERNAL_TOKEN") == "true" {
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/warmbly/warmbly/internal/app/fleetnode"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
)
|
||||
|
||||
// NodeCredentialVerifier checks that secret is the credential join issued to an enrolled node.
|
||||
type NodeCredentialVerifier interface {
|
||||
VerifyNodeCredential(ctx context.Context, id uuid.UUID, secret string) error
|
||||
}
|
||||
|
||||
const authenticatedNodeKey = "warmbly_authenticated_node"
|
||||
|
||||
// NodeCredentialRequired reports whether node-only routes admit only a node's own credential.
|
||||
func NodeCredentialRequired() bool {
|
||||
v, err := strconv.ParseBool(strings.TrimSpace(os.Getenv("NODE_REQUIRE_NODE_CREDENTIAL")))
|
||||
return err == nil && v
|
||||
}
|
||||
|
||||
// AuthenticatedNodeID is the node whose own credential admitted this request, if any.
|
||||
func AuthenticatedNodeID(c *gin.Context) (uuid.UUID, bool) {
|
||||
id, ok := c.Get(authenticatedNodeKey)
|
||||
if !ok {
|
||||
return uuid.Nil, false
|
||||
}
|
||||
nodeID, ok := id.(uuid.UUID)
|
||||
return nodeID, ok
|
||||
}
|
||||
|
||||
// mismatchedNodes remembers up to maxMismatchedNodes presented ids already warned about, so the log says it once per node.
|
||||
var (
|
||||
mismatchedNodes sync.Map
|
||||
mismatchedNodeCount atomic.Int64
|
||||
)
|
||||
|
||||
const maxMismatchedNodes = 1024
|
||||
|
||||
// authenticateNode admits a caller presenting its own node credential. It returns true once the
|
||||
// request is answered either way; false leaves it to the fleet token, which only happens while not required.
|
||||
func (h *Handler) authenticateNode(c *gin.Context) bool {
|
||||
required := NodeCredentialRequired()
|
||||
rawID := strings.TrimSpace(c.GetHeader(nodeauth.IDHeader))
|
||||
if rawID == "" {
|
||||
// The host updater names its node in the query and has always done so.
|
||||
rawID = strings.TrimSpace(c.Query("node_id"))
|
||||
}
|
||||
secret := strings.TrimSpace(c.GetHeader(nodeauth.CredentialHeader))
|
||||
if rawID == "" || secret == "" {
|
||||
if required {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "node credential required; join this machine again to receive one"})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
reason := "node credential does not match the node"
|
||||
id, err := uuid.Parse(rawID)
|
||||
switch {
|
||||
case err != nil:
|
||||
reason = "node id is not a uuid"
|
||||
case h.NodeCredentials == nil:
|
||||
reason = "node credentials are not available on this instance"
|
||||
default:
|
||||
verr := h.NodeCredentials.VerifyNodeCredential(c.Request.Context(), id, secret)
|
||||
switch {
|
||||
case verr == nil:
|
||||
c.Set(authenticatedNodeKey, id)
|
||||
c.Next()
|
||||
return true
|
||||
case errors.Is(verr, fleetnode.ErrNoNodeCredential), errors.Is(verr, fleetnode.ErrBadNodeCredential):
|
||||
default:
|
||||
if required {
|
||||
c.AbortWithStatusJSON(http.StatusServiceUnavailable, gin.H{"error": "node credential could not be checked"})
|
||||
return true
|
||||
}
|
||||
reason = "node credential could not be checked"
|
||||
}
|
||||
}
|
||||
if required {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "node credential does not match this node; join this machine again"})
|
||||
return true
|
||||
}
|
||||
if _, seen := mismatchedNodes.Load(rawID); !seen && mismatchedNodeCount.Add(1) <= maxMismatchedNodes {
|
||||
mismatchedNodes.Store(rawID, struct{}{})
|
||||
log.Warn().Str("node_id", rawID).Str("reason", reason).Msg("fleet: node credential refused; the request falls back to the fleet token, which stops working once NODE_REQUIRE_NODE_CREDENTIAL is on. Join this machine again")
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/warmbly/warmbly/internal/app/fleetnode"
|
||||
"github.com/warmbly/warmbly/internal/pkg/nodeauth"
|
||||
"github.com/warmbly/warmbly/internal/repository"
|
||||
)
|
||||
|
||||
// credentialRegistry holds credential hashes the way fleet_nodes does; a removed node has no row.
|
||||
type credentialRegistry struct {
|
||||
repository.FleetNodeRepository
|
||||
hashes map[uuid.UUID]string
|
||||
err error
|
||||
}
|
||||
|
||||
func (r *credentialRegistry) SetCredentialHash(_ context.Context, id uuid.UUID, hash string) error {
|
||||
r.hashes[id] = hash
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *credentialRegistry) CredentialHash(_ context.Context, id uuid.UUID) (string, error) {
|
||||
return r.hashes[id], r.err
|
||||
}
|
||||
|
||||
type nodeCall struct {
|
||||
id, credential, bearer string
|
||||
}
|
||||
|
||||
type nodeOutcome struct {
|
||||
code int
|
||||
nodeID uuid.UUID
|
||||
named bool
|
||||
}
|
||||
|
||||
// nodeRouteOutcome sends one call through each node middleware and fails unless all three agree.
|
||||
func nodeRouteOutcome(t *testing.T, h *Handler, call nodeCall) nodeOutcome {
|
||||
t.Helper()
|
||||
brokerTokenOnce = sync.Once{}
|
||||
brokerToken = nil
|
||||
mws := map[string]gin.HandlerFunc{
|
||||
"broker": h.NodeBrokerAuthMiddleware(),
|
||||
"node": h.NodeAuthMiddleware(),
|
||||
"heartbeat": h.NodeHeartbeatAuthMiddleware(),
|
||||
}
|
||||
var first *nodeOutcome
|
||||
for name, mw := range mws {
|
||||
var got nodeOutcome
|
||||
r := gin.New()
|
||||
r.POST("/n", mw, func(c *gin.Context) {
|
||||
got.nodeID, got.named = AuthenticatedNodeID(c)
|
||||
c.Status(http.StatusOK)
|
||||
})
|
||||
req := httptest.NewRequest(http.MethodPost, "/n", nil)
|
||||
if call.bearer != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+call.bearer)
|
||||
}
|
||||
if call.id != "" {
|
||||
req.Header.Set(nodeauth.IDHeader, call.id)
|
||||
}
|
||||
if call.credential != "" {
|
||||
req.Header.Set(nodeauth.CredentialHeader, call.credential)
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
got.code = w.Code
|
||||
if first == nil {
|
||||
first = &got
|
||||
} else if *first != got {
|
||||
t.Fatalf("%s middleware answered %+v, the others %+v", name, got, *first)
|
||||
}
|
||||
}
|
||||
return *first
|
||||
}
|
||||
|
||||
func TestNodeRoutesAuthenticateTheNode(t *testing.T) {
|
||||
t.Setenv("INTERNAL_API_TOKEN", "edge")
|
||||
t.Setenv("NODE_BROKER_TOKEN", "fleet")
|
||||
t.Setenv("NODE_ACCEPT_INTERNAL_TOKEN", "")
|
||||
|
||||
reg := &credentialRegistry{hashes: map[uuid.UUID]string{}}
|
||||
svc := fleetnode.New(reg, nil, nil)
|
||||
node, other, removed := uuid.New(), uuid.New(), uuid.New()
|
||||
secret, err := svc.IssueNodeCredential(t.Context(), node)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := svc.IssueNodeCredential(t.Context(), other); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
removedSecret, err := svc.IssueNodeCredential(t.Context(), removed)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
delete(reg.hashes, removed)
|
||||
h := &Handler{NodeCredentials: svc}
|
||||
|
||||
for _, required := range []string{"", "true"} {
|
||||
t.Run("required="+required, func(t *testing.T) {
|
||||
t.Setenv("NODE_REQUIRE_NODE_CREDENTIAL", required)
|
||||
strict := required == "true"
|
||||
fleetOnly := http.StatusOK
|
||||
if strict {
|
||||
fleetOnly = http.StatusUnauthorized
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
call nodeCall
|
||||
code int
|
||||
named bool
|
||||
}{
|
||||
{"own credential", nodeCall{node.String(), secret, ""}, http.StatusOK, true},
|
||||
{"own credential next to the fleet token", nodeCall{node.String(), secret, "fleet"}, http.StatusOK, true},
|
||||
{"fleet token alone", nodeCall{"", "", "fleet"}, fleetOnly, false},
|
||||
{"another node's id", nodeCall{other.String(), secret, ""}, http.StatusUnauthorized, false},
|
||||
{"wrong credential", nodeCall{node.String(), "forged", ""}, http.StatusUnauthorized, false},
|
||||
{"removed node", nodeCall{removed.String(), removedSecret, ""}, http.StatusUnauthorized, false},
|
||||
{"unknown node", nodeCall{uuid.NewString(), secret, ""}, http.StatusUnauthorized, false},
|
||||
{"id that is not a uuid", nodeCall{"node-1", secret, ""}, http.StatusUnauthorized, false},
|
||||
{"credential without an id", nodeCall{"", secret, ""}, http.StatusUnauthorized, false},
|
||||
{"nothing", nodeCall{}, http.StatusUnauthorized, false},
|
||||
{"wrong credential with the fleet token", nodeCall{node.String(), "forged", "fleet"}, fleetOnly, false},
|
||||
} {
|
||||
got := nodeRouteOutcome(t, h, tc.call)
|
||||
if got.code != tc.code || got.named != tc.named || (tc.named && got.nodeID != node) {
|
||||
t.Fatalf("%s: got %+v, want %d named=%v", tc.name, got, tc.code, tc.named)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeCredentialLookupFailure(t *testing.T) {
|
||||
t.Setenv("NODE_BROKER_TOKEN", "fleet")
|
||||
reg := &credentialRegistry{hashes: map[uuid.UUID]string{}}
|
||||
svc := fleetnode.New(reg, nil, nil)
|
||||
node := uuid.New()
|
||||
secret, err := svc.IssueNodeCredential(t.Context(), node)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
reg.err = errors.New("database unavailable")
|
||||
h := &Handler{NodeCredentials: svc}
|
||||
|
||||
t.Setenv("NODE_REQUIRE_NODE_CREDENTIAL", "true")
|
||||
if got := nodeRouteOutcome(t, h, nodeCall{node.String(), secret, "fleet"}); got.code != http.StatusServiceUnavailable {
|
||||
t.Fatalf("required: a failed lookup answered %d, want 503", got.code)
|
||||
}
|
||||
t.Setenv("NODE_REQUIRE_NODE_CREDENTIAL", "false")
|
||||
if got := nodeRouteOutcome(t, h, nodeCall{node.String(), secret, "fleet"}); got.code != http.StatusOK || got.named {
|
||||
t.Fatalf("not required: a failed lookup must fall back to the fleet token, got %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeCredentialRequiredWithoutRegistryRefusesEverything(t *testing.T) {
|
||||
t.Setenv("NODE_BROKER_TOKEN", "fleet")
|
||||
t.Setenv("NODE_REQUIRE_NODE_CREDENTIAL", "true")
|
||||
got := nodeRouteOutcome(t, &Handler{}, nodeCall{uuid.NewString(), "secret", "fleet"})
|
||||
if got.code != http.StatusUnauthorized {
|
||||
t.Fatalf("got %d, want 401", got.code)
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -133,7 +133,6 @@ func Run(
|
||||
// A linked instance's brokered sign-in opens here first: the page names who is asking and binds the browser.
|
||||
r.GET("/addresses/connect", m.PublicIPRateLimitMiddleware(), h.PoolLinkOAuthConsentPage)
|
||||
r.POST("/addresses/connect/continue", m.PublicIPRateLimitMiddleware(), h.PoolLinkOAuthContinue)
|
||||
r.GET("/addresses/connect/continue", m.PublicIPRateLimitMiddleware(), h.PoolLinkOAuthContinue)
|
||||
|
||||
// Public OAuth callback bouncer for third-party integrations (HubSpot,
|
||||
// Slack, Google, Pipedrive, …). The provider redirects here; the page
|
||||
@@ -399,6 +398,8 @@ func Run(
|
||||
|
||||
auth.POST("/login", h.LoginStart)
|
||||
auth.POST("/login/confirm", h.LoginConfirm)
|
||||
// An issued initial password is replaced here before the sign-in continues.
|
||||
auth.POST("/login/initial-password", h.LoginInitialPassword)
|
||||
auth.POST("/register", h.RegistrationStart)
|
||||
auth.POST("/register/confirm", h.RegistrationConfirm)
|
||||
auth.POST("/refresh", h.RefreshToken)
|
||||
@@ -473,6 +474,11 @@ func Run(
|
||||
protectedAuth.POST("/me/avatar", h.UploadUserAvatar)
|
||||
protectedAuth.DELETE("/me/avatar", h.DeleteUserAvatar)
|
||||
protectedAuth.POST("/me/password", m.RateLimitMiddleware(models.RateLimitWrite), h.ChangePassword)
|
||||
// No Idempotency-Key: a repeat mails another single-use link on the capped reset budget.
|
||||
protectedAuth.POST("/me/password/link", m.RateLimitMiddleware(models.RateLimitWrite), h.SendPasswordLink)
|
||||
// Removing a sign-in method changes who can get in. A repeat converges, so it takes no Idempotency-Key.
|
||||
protectedAuth.GET("/me/identities", h.LinkedIdentities)
|
||||
protectedAuth.DELETE("/me/identities/:provider", middleware.RequireFreshAuth(), m.RateLimitMiddleware(models.RateLimitWrite), h.UnlinkIdentity)
|
||||
// Undo-send window (user-scoped; current value rides /auth/me).
|
||||
protectedAuth.PUT("/me/send-preferences", h.UpdateSendPreferences)
|
||||
|
||||
@@ -680,6 +686,7 @@ func Run(
|
||||
sendingDomains.PUT("/:domain/tracking", h.SetDomainTracking)
|
||||
sendingDomains.PUT("/:domain/redirect", h.SetDomainRedirect)
|
||||
sendingDomains.POST("/:domain/redirect/verify", h.VerifyDomainRedirect)
|
||||
sendingDomains.POST("/:domain/redirect/website", h.VerifyRedirectWebsite)
|
||||
sendingDomains.DELETE("/:domain/redirect", h.DeleteDomainRedirect)
|
||||
sendingDomains.PUT("/:domain/vendor-forwarding", h.SetDomainVendorForwarding)
|
||||
sendingDomains.POST("/:domain/vendor-tracking", h.SetDomainVendorTracking)
|
||||
@@ -1858,6 +1865,8 @@ func Run(
|
||||
adminRoutes.POST("/testers", middleware.RequireAdminPermission(models.AdminPermManageTesters), h.AdminCreateTester)
|
||||
adminRoutes.POST("/organizations/:id/sample-data", middleware.RequireAdminPermission(models.AdminPermManageTesters), h.AdminSeedTesterWorkspace)
|
||||
adminRoutes.DELETE("/testers/:id", middleware.RequireAdminPermission(models.AdminPermManageTesters), h.AdminRevokeTester)
|
||||
// A fresh initial password changes who can get in.
|
||||
adminRoutes.POST("/testers/:id/password", middleware.RequireAdminPermission(models.AdminPermManageTesters), middleware.RequireFreshAuth(), h.AdminReissueTesterPassword)
|
||||
// Removing a sign-in step from an account changes who can get in.
|
||||
adminRoutes.PUT("/users/:id/login-code-exempt", middleware.RequireAdminPermission(models.AdminPermManageTesters), middleware.RequireFreshAuth(), h.AdminSetLoginCodeExempt)
|
||||
adminRoutes.POST("/users/:id/ban", middleware.RequireAdminPermission(models.AdminPermBanUsers), h.AdminBanUser)
|
||||
|
||||
@@ -189,3 +189,25 @@ func TestHoldForOutOfOfficeReadsTheReturnDateCheck(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A workspace's tagging languages reach the return-date reader, so a Polish
|
||||
// away message holds until its date instead of the fallback.
|
||||
func TestHoldForOutOfOfficeReadsTheWorkspaceLanguages(t *testing.T) {
|
||||
cfg := models.ReplyIntentSettings{HoldOnOutOfOffice: true, OutOfOfficeHoldDays: 7}
|
||||
back := time.Now().UTC().Truncate(24*time.Hour).AddDate(0, 0, 10)
|
||||
msg := &models.EmailMessageStoreData{Subject: "Odpowiedź automatyczna", BodyText: "Wracam " + back.Format("02.01.2006") + "."}
|
||||
for name, langs := range map[string][]string{"with Polish chosen": {"pl"}, "without it": nil} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
rec := &holdRecorder{}
|
||||
s := &service{campaignProgressRepo: rec}
|
||||
s.holdForOutOfOffice(context.Background(), uuid.New(), uuid.New(), cfg, msg, langs...)
|
||||
want := "auto-reply, no return date"
|
||||
if langs != nil {
|
||||
want = "back " + back.Format("2 Jan 2006")
|
||||
}
|
||||
if rec.reason != want {
|
||||
t.Errorf("hold reason = %q, want %q", rec.reason, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1614,7 +1614,7 @@ func (s *service) ProcessIncomingReply(ctx context.Context, emailAccountID uuid.
|
||||
|
||||
var held *time.Time
|
||||
if campaignID != nil && contactID != nil && !senderIsCopy && verdict.Class == replyclassify.ClassOutOfOffice && settings.ReplyIntent.HoldOnOutOfOffice {
|
||||
held = s.holdForOutOfOffice(ctx, *account.OrganizationID, *contactID, settings.ReplyIntent, msg)
|
||||
held = s.holdForOutOfOffice(ctx, *account.OrganizationID, *contactID, settings.ReplyIntent, msg, settings.InboxTagging.Languages...)
|
||||
}
|
||||
|
||||
actionTaken := ""
|
||||
@@ -1806,7 +1806,7 @@ func (s *service) ProcessIncomingReply(ctx context.Context, emailAccountID uuid.
|
||||
// one this reply was attributed to. An empty desk is an empty desk: holding
|
||||
// one sequence while a second kept mailing them was issue #470 again, narrowed
|
||||
// to the second campaign (issue #518).
|
||||
func (s *service) holdForOutOfOffice(ctx context.Context, orgID, contactID uuid.UUID, cfg models.ReplyIntentSettings, msg *models.EmailMessageStoreData) *time.Time {
|
||||
func (s *service) holdForOutOfOffice(ctx context.Context, orgID, contactID uuid.UUID, cfg models.ReplyIntentSettings, msg *models.EmailMessageStoreData, langs ...string) *time.Time {
|
||||
if s.campaignProgressRepo == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -1820,7 +1820,7 @@ func (s *service) holdForOutOfOffice(ctx context.Context, orgID, contactID uuid.
|
||||
return now.AddDate(0, 0, days), "auto-reply, no return date"
|
||||
}
|
||||
until, reason := fallback()
|
||||
if back, ok := replyclassify.ParseReturnDate(msg.Subject, body, now); ok {
|
||||
if back, ok := replyclassify.ParseReturnDate(msg.Subject, body, now, langs...); ok {
|
||||
if s.returnDateDoubted(ctx, orgID, msg.MessageID, back) {
|
||||
until, reason = now.AddDate(0, 0, days), "auto-reply, return date unclear"
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package aiagent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/warmbly/warmbly/internal/app/aitools"
|
||||
"github.com/warmbly/warmbly/internal/app/credits"
|
||||
"github.com/warmbly/warmbly/internal/errx"
|
||||
"github.com/warmbly/warmbly/internal/models"
|
||||
"github.com/warmbly/warmbly/internal/pkg/generation"
|
||||
)
|
||||
|
||||
type runCreditLedger struct {
|
||||
credits.CreditService
|
||||
balance, attempts, refunded, settlements, settledCredits, settledTokens int
|
||||
keys []string
|
||||
}
|
||||
|
||||
// Consume enforces the fixture balance and records the idempotency key of each charged turn.
|
||||
func (l *runCreditLedger) Consume(ctx context.Context, _ uuid.UUID, amount int, _, _ string, _ int, key string) (int, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return l.balance, err
|
||||
}
|
||||
l.attempts++
|
||||
if l.balance < amount {
|
||||
return l.balance, credits.ErrInsufficientCredits
|
||||
}
|
||||
l.balance -= amount
|
||||
l.keys = append(l.keys, key)
|
||||
return l.balance, nil
|
||||
}
|
||||
|
||||
// Grant records failed-turn refunds and rejects canceled storage contexts.
|
||||
func (l *runCreditLedger) Grant(ctx context.Context, _ uuid.UUID, amount int, _ string) (int, *errx.Error) {
|
||||
if ctx.Err() != nil {
|
||||
return l.balance, errx.New(errx.Internal, "credit context is canceled")
|
||||
}
|
||||
l.refunded += amount
|
||||
l.balance += amount
|
||||
return l.balance, nil
|
||||
}
|
||||
|
||||
// SettleUsage records the charged turns and token usage without introducing external pricing into the fixture.
|
||||
func (l *runCreditLedger) SettleUsage(ctx context.Context, _ uuid.UUID, charged int, _ string, tokens int, _, _ string) (int, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
l.settlements++
|
||||
l.settledCredits, l.settledTokens = charged, tokens
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// TestRunMessageChargesReservedAnswerWithinBudget covers successful answers, failed-turn refunds, and depleted credits.
|
||||
func TestRunMessageChargesReservedAnswerWithinBudget(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
balance, wantRequests, wantCharged, wantRefund, wantBalance, wantRows, wantSettlements int
|
||||
wantCode string
|
||||
}{
|
||||
{name: "answer", balance: 50, wantRequests: 20, wantCharged: 20, wantBalance: 30, wantRows: 40, wantSettlements: 1},
|
||||
{name: "empty_answer", balance: 50, wantRequests: 20, wantCharged: 20, wantRefund: 1, wantBalance: 31, wantRows: 39, wantCode: "provider_error"},
|
||||
{name: "no_credit_for_answer", balance: 19, wantRequests: 19, wantCharged: 19, wantBalance: 0, wantRows: 39, wantSettlements: 1, wantCode: "insufficient_credits"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
requests := 0
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
requests++
|
||||
message := map[string]any{"role": "assistant", "content": "The mailbox is paused."}
|
||||
if requests < 20 {
|
||||
message["content"], message["tool_calls"] = "", []any{map[string]any{
|
||||
"id": fmt.Sprint(requests), "type": "function", "function": map[string]string{"name": "read", "arguments": `{}`},
|
||||
}}
|
||||
} else if tc.name == "empty_answer" {
|
||||
message["content"] = ""
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"choices": []any{map[string]any{"message": message}}, "usage": map[string]int{"total_tokens": 10},
|
||||
})
|
||||
}))
|
||||
defer srv.Close()
|
||||
provider, err := generation.NewProvider(generation.ProviderConfig{
|
||||
OpenAIAPIKey: "fixture", OpenAIBaseURL: srv.URL, OpenAIModelPaid: "fixture-model",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
registry := aitools.NewRegistry()
|
||||
registry.Register(aitools.Tool{Name: "read", Risk: generation.RiskRead, Handler: func(context.Context, aitools.Invocation, json.RawMessage) (string, error) {
|
||||
return `{"status":"paused"}`, nil
|
||||
}})
|
||||
repo := &runRepository{session: models.AgentSession{ID: uuid.New(), OrgID: uuid.New(), UserID: uuid.New()}}
|
||||
ledger := &runCreditLedger{balance: tc.balance}
|
||||
svc := NewService(repo, registry, provider, ledger, runFeatureGate{}, nil, nil, nil, nil)
|
||||
var last StreamEvent
|
||||
if xerr := svc.RunMessage(context.Background(), aitools.Invocation{OrgID: repo.session.OrgID, UserID: repo.session.UserID}, repo.session.ID, "paid-message", "Inspect sending", "", "", func(ev StreamEvent) { last = ev }); xerr != nil {
|
||||
t.Fatal(xerr)
|
||||
}
|
||||
if requests != tc.wantRequests || ledger.attempts != 20 || len(ledger.keys) != tc.wantCharged || ledger.refunded != tc.wantRefund || ledger.balance != tc.wantBalance {
|
||||
t.Fatalf("requests=%d attempts=%d charged=%d refunded=%d balance=%d", requests, ledger.attempts, len(ledger.keys), ledger.refunded, ledger.balance)
|
||||
}
|
||||
if ledger.keys[0] != "paid-message:1" || ledger.keys[len(ledger.keys)-1] != fmt.Sprintf("paid-message:%d", tc.wantCharged) {
|
||||
t.Fatalf("credit idempotency keys changed: %v", ledger.keys)
|
||||
}
|
||||
if ledger.settlements != tc.wantSettlements || tc.wantSettlements > 0 && (ledger.settledCredits != tc.wantCharged || ledger.settledTokens != tc.wantRequests*10) {
|
||||
t.Fatalf("settlements=%d credits=%d tokens=%d", ledger.settlements, ledger.settledCredits, ledger.settledTokens)
|
||||
}
|
||||
if last.Code != tc.wantCode || last.CreditsRemaining != tc.wantBalance || len(repo.rows) != tc.wantRows {
|
||||
t.Fatalf("event=%+v persisted rows=%d", last, len(repo.rows))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user