@coffre/conformance 0.10.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{idp-B8u4UPA4.js → idp-B9CQgH3O.js} +15 -7
- package/dist/idp.d.ts +10 -0
- package/dist/idp.js +1 -1
- package/dist/main.js +65 -9
- package/package.json +4 -4
- package/src/bundle.ts +1 -0
- package/src/checks/audit.ts +5 -3
- package/src/checks/environments.ts +34 -0
- package/src/draining.ts +2 -0
- package/src/idp/authorize.ts +6 -9
- package/src/idp/idp.ts +17 -1
- package/src/suite.ts +2 -1
|
@@ -246,8 +246,9 @@ function randomToken() {
|
|
|
246
246
|
return randomBytes(32).toString("base64url");
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
|
-
* The built-in client accepts any loopback URI, because local dev ports vary
|
|
250
|
-
*
|
|
249
|
+
* The built-in client accepts any loopback URI, because local dev ports vary,
|
|
250
|
+
* and any URI under an origin it was given (a tunnel to the app); every other
|
|
251
|
+
* redirect URI must match a registered one exactly.
|
|
251
252
|
*/
|
|
252
253
|
function allowsRedirect(client, uri) {
|
|
253
254
|
if (client.redirectUris.includes(uri)) return true;
|
|
@@ -258,7 +259,8 @@ function allowsRedirect(client, uri) {
|
|
|
258
259
|
} catch {
|
|
259
260
|
return false;
|
|
260
261
|
}
|
|
261
|
-
|
|
262
|
+
if (url.username !== "" || url.password !== "" || uri.includes("#")) return false;
|
|
263
|
+
return url.protocol === "http:" && (url.hostname === "127.0.0.1" || url.hostname === "localhost") || client.redirectOrigins.includes(url.origin);
|
|
262
264
|
}
|
|
263
265
|
/** RFC 7636 §4.6, S256 only. */
|
|
264
266
|
function verifies(verifier, challenge) {
|
|
@@ -1391,6 +1393,7 @@ const DEFAULT_CLIENT = Object.freeze({
|
|
|
1391
1393
|
var DevIdp = class {
|
|
1392
1394
|
#server = null;
|
|
1393
1395
|
#port = 0;
|
|
1396
|
+
#publicOrigin;
|
|
1394
1397
|
#clients = /* @__PURE__ */ new Map();
|
|
1395
1398
|
#subjects = /* @__PURE__ */ new Map();
|
|
1396
1399
|
#gitHubAccounts = /* @__PURE__ */ new Map();
|
|
@@ -1410,18 +1413,22 @@ var DevIdp = class {
|
|
|
1410
1413
|
githubApp;
|
|
1411
1414
|
constructor(options = {}) {
|
|
1412
1415
|
this.autoApprove = options.autoApprove ?? false;
|
|
1416
|
+
this.#publicOrigin = options.publicOrigin === void 0 ? void 0 : new URL(options.publicOrigin).origin;
|
|
1417
|
+
const redirectOrigins = (options.redirectOrigins ?? []).map((each) => new URL(each).origin);
|
|
1413
1418
|
this.githubApp = new FakeGitHubApp(() => this.origin, options.githubAppKey);
|
|
1414
1419
|
this.#clients.set(DEFAULT_CLIENT.clientId, {
|
|
1415
1420
|
...DEFAULT_CLIENT,
|
|
1416
1421
|
redirectUris: [],
|
|
1417
|
-
anyLoopbackRedirect: true
|
|
1422
|
+
anyLoopbackRedirect: true,
|
|
1423
|
+
redirectOrigins
|
|
1418
1424
|
});
|
|
1419
1425
|
for (const client of options.clients ?? []) this.registerClient(client);
|
|
1420
1426
|
this.#clients.set(this.githubApp.clientId, {
|
|
1421
1427
|
clientId: this.githubApp.clientId,
|
|
1422
1428
|
clientSecret: this.githubApp.clientSecret,
|
|
1423
1429
|
redirectUris: [],
|
|
1424
|
-
anyLoopbackRedirect: true
|
|
1430
|
+
anyLoopbackRedirect: true,
|
|
1431
|
+
redirectOrigins
|
|
1425
1432
|
});
|
|
1426
1433
|
const authz = new AuthorizationServer(this);
|
|
1427
1434
|
this.#routes = [
|
|
@@ -1433,7 +1440,7 @@ var DevIdp = class {
|
|
|
1433
1440
|
}
|
|
1434
1441
|
get origin() {
|
|
1435
1442
|
if (this.#port === 0) throw new Error("DevIdp is not started");
|
|
1436
|
-
return `http://127.0.0.1:${this.#port}`;
|
|
1443
|
+
return this.#publicOrigin ?? `http://127.0.0.1:${this.#port}`;
|
|
1437
1444
|
}
|
|
1438
1445
|
/** Matches the Cloudflare Access team-domain issuer shape. */
|
|
1439
1446
|
get issuer() {
|
|
@@ -1503,7 +1510,8 @@ var DevIdp = class {
|
|
|
1503
1510
|
clientId: client.clientId,
|
|
1504
1511
|
clientSecret: client.clientSecret,
|
|
1505
1512
|
redirectUris: [...client.redirectUris],
|
|
1506
|
-
anyLoopbackRedirect: false
|
|
1513
|
+
anyLoopbackRedirect: false,
|
|
1514
|
+
redirectOrigins: []
|
|
1507
1515
|
});
|
|
1508
1516
|
}
|
|
1509
1517
|
client(clientId) {
|
package/dist/idp.d.ts
CHANGED
|
@@ -182,6 +182,8 @@ interface DevIdpClient {
|
|
|
182
182
|
interface RegisteredClient extends DevIdpClient {
|
|
183
183
|
/** Accept any http://127.0.0.1 or http://localhost redirect URI, on any port. */
|
|
184
184
|
anyLoopbackRedirect: boolean;
|
|
185
|
+
/** Also accept redirect URIs under these origins (a tunnel to the app). Only for the built-in clients. */
|
|
186
|
+
redirectOrigins: readonly string[];
|
|
185
187
|
}
|
|
186
188
|
interface DevIdpOptions {
|
|
187
189
|
/** Registered alongside the built-in `coffre-local` client. */
|
|
@@ -190,6 +192,14 @@ interface DevIdpOptions {
|
|
|
190
192
|
autoApprove?: boolean;
|
|
191
193
|
/** The fake GitHub App's private key, PKCS #1 PEM: made at start unless given. */
|
|
192
194
|
githubAppKey?: string;
|
|
195
|
+
/**
|
|
196
|
+
* The origin a browser reaches this server at, when that is not its loopback
|
|
197
|
+
* address (a tunnel to it): the issuer, and every URL it publishes, name it.
|
|
198
|
+
* It still listens on loopback only.
|
|
199
|
+
*/
|
|
200
|
+
publicOrigin?: string;
|
|
201
|
+
/** Origins besides loopback that the built-in clients may redirect to: the app's, behind the same tunnel. */
|
|
202
|
+
redirectOrigins?: readonly string[];
|
|
193
203
|
}
|
|
194
204
|
/** Built in, so local dev needs no registration step. */
|
|
195
205
|
export declare const DEFAULT_CLIENT: Readonly<{
|
package/dist/idp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FakeGitHubApp, i as WorkloadIssuer, n as DevIdp, o as fakeInstallations, r as GITHUB_RUN, s as PERSONAS, t as DEFAULT_CLIENT } from "./idp-
|
|
1
|
+
import { a as FakeGitHubApp, i as WorkloadIssuer, n as DevIdp, o as fakeInstallations, r as GITHUB_RUN, s as PERSONAS, t as DEFAULT_CLIENT } from "./idp-B9CQgH3O.js";
|
|
2
2
|
export { DEFAULT_CLIENT, DevIdp, FakeGitHubApp, GITHUB_RUN, PERSONAS, WorkloadIssuer, fakeInstallations };
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as defaultGitHubAccount, n as DevIdp, r as GITHUB_RUN } from "./idp-
|
|
1
|
+
import { c as defaultGitHubAccount, n as DevIdp, r as GITHUB_RUN } from "./idp-B9CQgH3O.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { delimiter, dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { inspect, parseArgs } from "node:util";
|
|
@@ -64,6 +64,7 @@ const KEYS = {
|
|
|
64
64
|
function drainingConfig(server) {
|
|
65
65
|
writeFileSync(join(server, "conformance.js"), [
|
|
66
66
|
"import app from './index.js';",
|
|
67
|
+
"export * from './index.js';",
|
|
67
68
|
"export default {",
|
|
68
69
|
" ...app,",
|
|
69
70
|
" async fetch(request, env, ctx) {",
|
|
@@ -84,7 +85,7 @@ function drainingConfig(server) {
|
|
|
84
85
|
}
|
|
85
86
|
if (import.meta.main) console.log(drainingConfig(resolve(process.argv[2])));
|
|
86
87
|
//#endregion
|
|
87
|
-
//#region ../client/dist/
|
|
88
|
+
//#region ../client/dist/src-CjUBSxZs.js
|
|
88
89
|
/** Two colons or more, in hex: an IPv6 address, as `::1` or `2001:db8::1:443` with its port. */
|
|
89
90
|
const IPV6 = /[0-9a-f]*:[0-9a-f]*:[0-9a-f:]*/i;
|
|
90
91
|
const TIMEOUT_OR_REFUSAL = /* @__PURE__ */ new Set([
|
|
@@ -226,7 +227,7 @@ function createClient(options) {
|
|
|
226
227
|
/**
|
|
227
228
|
* Protected, a person holds their role's protected column there
|
|
228
229
|
* (docs/design/roles.md); whoever manages the project's environments
|
|
229
|
-
* protects one, and only an Owner of the whole instance unprotects it.
|
|
230
|
+
* protects one, and only an Owner of its project, or of the whole instance, unprotects it.
|
|
230
231
|
*/
|
|
231
232
|
protect: (path, on = true) => call("PATCH /projects/:project/:environment", place(path), { protected: on }),
|
|
232
233
|
/** What deleting an archived environment would erase and revoke; changes nothing. */
|
|
@@ -252,8 +253,11 @@ function createClient(options) {
|
|
|
252
253
|
secrets: {
|
|
253
254
|
/** Keys, versions and who changed what; never values. */
|
|
254
255
|
list: (path) => call("GET /secrets/:project/:environment", place(path)),
|
|
255
|
-
/** Decrypts one secret, or every secret in an environment. Logged in your name. */
|
|
256
|
-
reveal: (path) => call("POST /reveals", {}, { path }
|
|
256
|
+
/** Decrypts one secret, or every secret in an environment, or, `keys` named, those of it only. Logged in your name. */
|
|
257
|
+
reveal: (path, keys) => call("POST /reveals", {}, keys === void 0 ? { path } : {
|
|
258
|
+
path,
|
|
259
|
+
keys
|
|
260
|
+
}),
|
|
257
261
|
/** One transaction, a version and an audit entry per key; `null` archives. */
|
|
258
262
|
set: (path, values) => call("PATCH /secrets/:project/:environment", place(path), values),
|
|
259
263
|
/**
|
|
@@ -320,7 +324,11 @@ function createClient(options) {
|
|
|
320
324
|
* values, which only the credential proxy (`/use`) takes. The value is
|
|
321
325
|
* in the answer, and only there; it is revoked as a token is.
|
|
322
326
|
*/
|
|
323
|
-
handles: {
|
|
327
|
+
handles: {
|
|
328
|
+
create: (input) => call("POST /handles", {}, input),
|
|
329
|
+
/** Ends a handle of the caller's own, as `coffre run` does once its command ends. */
|
|
330
|
+
revoke: (id) => call("DELETE /handles/:id", { id })
|
|
331
|
+
},
|
|
324
332
|
/** Trust bindings: which CI runs may sign in as a service, by their platform's ID token. */
|
|
325
333
|
bindings: {
|
|
326
334
|
list: (member) => call("GET /members/:member/bindings", { member }),
|
|
@@ -2499,7 +2507,8 @@ async function checkpoints(deployment, { admin }) {
|
|
|
2499
2507
|
}
|
|
2500
2508
|
/**
|
|
2501
2509
|
* Every version the app says it stored names the vault's entry for the key
|
|
2502
|
-
* it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore
|
|
2510
|
+
* it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore,
|
|
2511
|
+
* a mark and a loosening:
|
|
2503
2512
|
* the same member, request and operation, the same secret and version. And
|
|
2504
2513
|
* every value read is the vault's to log: the app keeps no reads of its own.
|
|
2505
2514
|
*/
|
|
@@ -2507,10 +2516,10 @@ async function writesAgree(deployment) {
|
|
|
2507
2516
|
return using(deployment.database(), async (sql) => {
|
|
2508
2517
|
const entries = await sql.query("SELECT * FROM audit_log ORDER BY seq");
|
|
2509
2518
|
const bySeq = new Map(entries.map((entry) => [String(entry.seq), entry]));
|
|
2510
|
-
const writes = entries.filter((entry) => entry.author === "app" && entry.decision === "allow" && (entry.action === "secret.write" || entry.action === "secret.restore"));
|
|
2519
|
+
const writes = entries.filter((entry) => entry.author === "app" && entry.decision === "allow" && (entry.action === "secret.write" || entry.action === "secret.restore" || entry.action === "secret.loosen"));
|
|
2511
2520
|
for (const entry of entries.filter((row) => row.author === "app" && row.decision === "allow")) expect(entry.action !== "secret.read", "the app logged an allowed read of a value", entry);
|
|
2512
2521
|
for (const entry of writes) {
|
|
2513
|
-
const seal = entry.action === "secret.write" ? "key.wrap" : "key.rewrap";
|
|
2522
|
+
const seal = entry.action === "secret.write" && JSON.parse(entry.metadata).kept === void 0 ? "key.wrap" : "key.rewrap";
|
|
2514
2523
|
const key = entry.related_seq === null ? void 0 : bySeq.get(String(entry.related_seq));
|
|
2515
2524
|
expect(key !== void 0 && key.author === "vault" && key.action === seal && key.decision === "allow", `a ${entry.action} names no ${seal} of the vault's`, {
|
|
2516
2525
|
entry,
|
|
@@ -3075,6 +3084,46 @@ async function references(deployment, { admin, reader, leaver }, canaries) {
|
|
|
3075
3084
|
}
|
|
3076
3085
|
/** A key prod has and dev does not, for the missing-keys check; archived once checked. */
|
|
3077
3086
|
const PROD_ONLY = "CONFORMANCE_PROD_ONLY";
|
|
3087
|
+
const LOOSE = "CONFORMANCE_LOOSENED";
|
|
3088
|
+
/**
|
|
3089
|
+
* A sensitive value is made a secret in place by an Owner alone (R30): the
|
|
3090
|
+
* leaver, a developer on dev, is refused, and told the listing does not
|
|
3091
|
+
* offer it; the admin's mark answers no value, and the reader, a viewer on
|
|
3092
|
+
* dev, reads it after, as a secret, its old version still sensitive. Its
|
|
3093
|
+
* own `secret.loosen`, which "keys behind writes" holds to the vault's
|
|
3094
|
+
* `key.rewrap`. The key is archived after.
|
|
3095
|
+
*/
|
|
3096
|
+
async function loosening({ admin, reader, leaver }) {
|
|
3097
|
+
const value = canary();
|
|
3098
|
+
const path = `${DEV}/${LOOSE}`;
|
|
3099
|
+
await admin.api.secrets.set(DEV, { [LOOSE]: {
|
|
3100
|
+
value,
|
|
3101
|
+
sensitivity: "sensitive"
|
|
3102
|
+
} });
|
|
3103
|
+
try {
|
|
3104
|
+
await refused$1("a viewer read a sensitive value", reader.api.secrets.reveal(path));
|
|
3105
|
+
expect((await leaver.api.secrets.list(DEV)).loosenable === false, "a developer on dev is told they make a sensitive value a secret in place");
|
|
3106
|
+
await refused$1("a developer on dev made a sensitive value a secret in place", leaver.api.secrets.set(DEV, { [LOOSE]: { sensitivity: "secret" } }));
|
|
3107
|
+
expect((await admin.api.secrets.list(DEV)).loosenable === true, "the admin, an Owner of the whole instance, is told they do not loosen");
|
|
3108
|
+
const marked = await admin.api.secrets.set(DEV, { [LOOSE]: { sensitivity: "secret" } });
|
|
3109
|
+
expect(!JSON.stringify(marked).includes(value), "the admin's loosening answered the value", marked);
|
|
3110
|
+
expect(JSON.stringify(marked.keys[LOOSE]) === JSON.stringify({
|
|
3111
|
+
version: 2,
|
|
3112
|
+
sensitivity: "secret"
|
|
3113
|
+
}), "the loosening made no new secret version", marked.keys);
|
|
3114
|
+
expect((await reader.api.secrets.reveal(path)).values[LOOSE] === value, "the reader did not read the loosened value as dev's secret");
|
|
3115
|
+
const versions = (await admin.api.secrets.history(path)).versions.map((version) => version.sensitivity);
|
|
3116
|
+
expect(versions.join() === "secret,sensitive", "the loosening changed the old version too, or made none", versions);
|
|
3117
|
+
const logged = (await admin.api.audit.list({
|
|
3118
|
+
path,
|
|
3119
|
+
limit: 50
|
|
3120
|
+
})).entries.filter((entry) => entry.action === "secret.loosen");
|
|
3121
|
+
expect(logged.length === 1 && logged[0].metadata.from === "sensitive" && logged[0].metadata.to === "secret", "the loosening is not its own entry, saying both levels", logged);
|
|
3122
|
+
} finally {
|
|
3123
|
+
await admin.api.secrets.set(DEV, { [LOOSE]: null });
|
|
3124
|
+
}
|
|
3125
|
+
return "the admin makes a sensitive value a secret in place, answered no value, as a new version, logged as secret.loosen; a developer on dev may not";
|
|
3126
|
+
}
|
|
3078
3127
|
/**
|
|
3079
3128
|
* Within a project, key names are not secret; values are. What dev is
|
|
3080
3129
|
* missing is compared with every sibling: the reader, a viewer on dev who
|
|
@@ -3322,11 +3371,16 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
3322
3371
|
"GET /members/:member/access": members.map((member) => ({ params: { member } })),
|
|
3323
3372
|
"GET /members/:member/tokens": services.map((member) => ({ params: { member } })),
|
|
3324
3373
|
"GET /members/:member/bindings": services.map((member) => ({ params: { member } })),
|
|
3374
|
+
"GET /members/:member/bindings/:id/enrollments": services.map((member) => ({ params: {
|
|
3375
|
+
member,
|
|
3376
|
+
id: "00000000-0000-4000-8000-000000000000"
|
|
3377
|
+
} })),
|
|
3325
3378
|
"GET /workloads/lookup": [{
|
|
3326
3379
|
params: {},
|
|
3327
3380
|
input: { github: "acme/api" }
|
|
3328
3381
|
}],
|
|
3329
3382
|
"GET /workloads/repositories": [{ params: {} }],
|
|
3383
|
+
"GET /freezes": [{ params: {} }],
|
|
3330
3384
|
"GET /roles": [{ params: {} }],
|
|
3331
3385
|
"GET /settings": [{ params: {} }],
|
|
3332
3386
|
"GET /sessions": [{ params: {} }],
|
|
@@ -4613,6 +4667,7 @@ const MARKERS = [
|
|
|
4613
4667
|
...[
|
|
4614
4668
|
"audit_chain_head",
|
|
4615
4669
|
"audit_log",
|
|
4670
|
+
"capped_alerts",
|
|
4616
4671
|
"consumed_tokens",
|
|
4617
4672
|
"device_authorizations",
|
|
4618
4673
|
"dismissed_keys",
|
|
@@ -5110,6 +5165,7 @@ async function conform(deployment, options) {
|
|
|
5110
5165
|
await report.check("inheritance", all, ({ people, canaries }) => inheritance(people, canaries));
|
|
5111
5166
|
await report.check("personal configs", { people }, ({ people }) => personalConfigs(deployment, people));
|
|
5112
5167
|
await report.check("references", all, ({ people, canaries }) => references(deployment, people, canaries));
|
|
5168
|
+
await report.check("loosening", { people }, ({ people }) => loosening(people));
|
|
5113
5169
|
await report.check("missing keys", { people }, ({ people }) => missingKeys(people));
|
|
5114
5170
|
await report.check("MCP connect", { people }, ({ people }) => mcpConnect(deployment, people));
|
|
5115
5171
|
await report.check("MCP read", all, ({ people, canaries }) => mcpRead(deployment, people, canaries));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/conformance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Checks a coffre deployment from outside: what it must never do, whatever code it runs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"jose": "6.2.3",
|
|
33
33
|
"pg": "8.16.3",
|
|
34
|
-
"@coffre/cli": "0.
|
|
35
|
-
"@coffre/db": "0.
|
|
34
|
+
"@coffre/cli": "0.12.0",
|
|
35
|
+
"@coffre/db": "0.12.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "26.1.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsdown": "0.23.0",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
43
|
"vite": "8.1.5",
|
|
44
|
-
"@coffre/client": "0.
|
|
44
|
+
"@coffre/client": "0.12.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsdown",
|
package/src/bundle.ts
CHANGED
package/src/checks/audit.ts
CHANGED
|
@@ -110,7 +110,8 @@ export async function checkpoints(deployment: Deployment, { admin }: People): Pr
|
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Every version the app says it stored names the vault's entry for the key
|
|
113
|
-
* it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore
|
|
113
|
+
* it was sealed with, `key.wrap` for a write and `key.rewrap` for a restore,
|
|
114
|
+
* a mark and a loosening:
|
|
114
115
|
* the same member, request and operation, the same secret and version. And
|
|
115
116
|
* every value read is the vault's to log: the app keeps no reads of its own.
|
|
116
117
|
*/
|
|
@@ -123,12 +124,13 @@ export async function writesAgree(deployment: Deployment): Promise<string> {
|
|
|
123
124
|
}>('SELECT * FROM audit_log ORDER BY seq');
|
|
124
125
|
const bySeq = new Map(entries.map((entry) => [String(entry.seq), entry]));
|
|
125
126
|
const writes = entries.filter((entry) => entry.author === 'app' && entry.decision === 'allow'
|
|
126
|
-
&& (entry.action === 'secret.write' || entry.action === 'secret.restore'));
|
|
127
|
+
&& (entry.action === 'secret.write' || entry.action === 'secret.restore' || entry.action === 'secret.loosen'));
|
|
127
128
|
for (const entry of entries.filter((row) => row.author === 'app' && row.decision === 'allow')) {
|
|
128
129
|
expect(entry.action !== 'secret.read', 'the app logged an allowed read of a value', entry);
|
|
129
130
|
}
|
|
130
131
|
for (const entry of writes) {
|
|
131
|
-
|
|
132
|
+
// A write of a new value wraps a new key; a restore, a mark (which says the version it `kept`) and a loosening rewrap one.
|
|
133
|
+
const seal = entry.action === 'secret.write' && JSON.parse(entry.metadata).kept === undefined ? 'key.wrap' : 'key.rewrap';
|
|
132
134
|
const key = entry.related_seq === null ? undefined : bySeq.get(String(entry.related_seq));
|
|
133
135
|
expect(key !== undefined && key.author === 'vault' && key.action === seal && key.decision === 'allow',
|
|
134
136
|
`a ${entry.action} names no ${seal} of the vault's`, { entry, key });
|
|
@@ -238,6 +238,40 @@ export async function references(deployment: Deployment, { admin, reader, leaver
|
|
|
238
238
|
/** A key prod has and dev does not, for the missing-keys check; archived once checked. */
|
|
239
239
|
const PROD_ONLY = 'CONFORMANCE_PROD_ONLY';
|
|
240
240
|
|
|
241
|
+
const LOOSE = 'CONFORMANCE_LOOSENED';
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A sensitive value is made a secret in place by an Owner alone (R30): the
|
|
245
|
+
* leaver, a developer on dev, is refused, and told the listing does not
|
|
246
|
+
* offer it; the admin's mark answers no value, and the reader, a viewer on
|
|
247
|
+
* dev, reads it after, as a secret, its old version still sensitive. Its
|
|
248
|
+
* own `secret.loosen`, which "keys behind writes" holds to the vault's
|
|
249
|
+
* `key.rewrap`. The key is archived after.
|
|
250
|
+
*/
|
|
251
|
+
export async function loosening({ admin, reader, leaver }: People): Promise<string> {
|
|
252
|
+
const value = canary();
|
|
253
|
+
const path = `${DEV}/${LOOSE}`;
|
|
254
|
+
await admin.api.secrets.set(DEV, { [LOOSE]: { value, sensitivity: 'sensitive' } });
|
|
255
|
+
try {
|
|
256
|
+
await refused('a viewer read a sensitive value', reader.api.secrets.reveal(path));
|
|
257
|
+
expect((await leaver.api.secrets.list(DEV)).loosenable === false, 'a developer on dev is told they make a sensitive value a secret in place');
|
|
258
|
+
await refused('a developer on dev made a sensitive value a secret in place', leaver.api.secrets.set(DEV, { [LOOSE]: { sensitivity: 'secret' } }));
|
|
259
|
+
expect((await admin.api.secrets.list(DEV)).loosenable === true, 'the admin, an Owner of the whole instance, is told they do not loosen');
|
|
260
|
+
const marked = await admin.api.secrets.set(DEV, { [LOOSE]: { sensitivity: 'secret' } });
|
|
261
|
+
expect(!JSON.stringify(marked).includes(value), "the admin's loosening answered the value", marked);
|
|
262
|
+
expect(JSON.stringify(marked.keys[LOOSE]) === JSON.stringify({ version: 2, sensitivity: 'secret' }), 'the loosening made no new secret version', marked.keys);
|
|
263
|
+
const read = await reader.api.secrets.reveal(path);
|
|
264
|
+
expect(read.values[LOOSE] === value, "the reader did not read the loosened value as dev's secret");
|
|
265
|
+
const versions = (await admin.api.secrets.history(path)).versions.map((version) => version.sensitivity);
|
|
266
|
+
expect(versions.join() === 'secret,sensitive', 'the loosening changed the old version too, or made none', versions);
|
|
267
|
+
const logged = (await admin.api.audit.list({ path, limit: 50 })).entries.filter((entry) => entry.action === 'secret.loosen');
|
|
268
|
+
expect(logged.length === 1 && logged[0]!.metadata.from === 'sensitive' && logged[0]!.metadata.to === 'secret', 'the loosening is not its own entry, saying both levels', logged);
|
|
269
|
+
} finally {
|
|
270
|
+
await admin.api.secrets.set(DEV, { [LOOSE]: null });
|
|
271
|
+
}
|
|
272
|
+
return 'the admin makes a sensitive value a secret in place, answered no value, as a new version, logged as secret.loosen; a developer on dev may not';
|
|
273
|
+
}
|
|
274
|
+
|
|
241
275
|
/**
|
|
242
276
|
* Within a project, key names are not secret; values are. What dev is
|
|
243
277
|
* missing is compared with every sibling: the reader, a viewer on dev who
|
package/src/draining.ts
CHANGED
|
@@ -25,6 +25,8 @@ export function drainingConfig(server: string): string {
|
|
|
25
25
|
join(server, 'conformance.js'),
|
|
26
26
|
[
|
|
27
27
|
"import app from './index.js';",
|
|
28
|
+
// The app's other exports, its Durable Object classes (`CoffreSockets`), which its config binds by name.
|
|
29
|
+
"export * from './index.js';",
|
|
28
30
|
'export default {',
|
|
29
31
|
' ...app,',
|
|
30
32
|
' async fetch(request, env, ctx) {',
|
package/src/idp/authorize.ts
CHANGED
|
@@ -75,8 +75,9 @@ export function randomToken(): string {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
* The built-in client accepts any loopback URI, because local dev ports vary
|
|
79
|
-
*
|
|
78
|
+
* The built-in client accepts any loopback URI, because local dev ports vary,
|
|
79
|
+
* and any URI under an origin it was given (a tunnel to the app); every other
|
|
80
|
+
* redirect URI must match a registered one exactly.
|
|
80
81
|
*/
|
|
81
82
|
export function allowsRedirect(client: RegisteredClient, uri: string): boolean {
|
|
82
83
|
if (client.redirectUris.includes(uri)) return true;
|
|
@@ -87,13 +88,9 @@ export function allowsRedirect(client: RegisteredClient, uri: string): boolean {
|
|
|
87
88
|
} catch {
|
|
88
89
|
return false;
|
|
89
90
|
}
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
url.username === '' &&
|
|
94
|
-
url.password === '' &&
|
|
95
|
-
!uri.includes('#')
|
|
96
|
-
);
|
|
91
|
+
if (url.username !== '' || url.password !== '' || uri.includes('#')) return false;
|
|
92
|
+
const loopback = url.protocol === 'http:' && (url.hostname === '127.0.0.1' || url.hostname === 'localhost');
|
|
93
|
+
return loopback || client.redirectOrigins.includes(url.origin);
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
/** RFC 7636 §4.6, S256 only. */
|
package/src/idp/idp.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface DevIdpClient {
|
|
|
28
28
|
export interface RegisteredClient extends DevIdpClient {
|
|
29
29
|
/** Accept any http://127.0.0.1 or http://localhost redirect URI, on any port. */
|
|
30
30
|
anyLoopbackRedirect: boolean;
|
|
31
|
+
/** Also accept redirect URIs under these origins (a tunnel to the app). Only for the built-in clients. */
|
|
32
|
+
redirectOrigins: readonly string[];
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export interface DevIdpOptions {
|
|
@@ -37,6 +39,14 @@ export interface DevIdpOptions {
|
|
|
37
39
|
autoApprove?: boolean;
|
|
38
40
|
/** The fake GitHub App's private key, PKCS #1 PEM: made at start unless given. */
|
|
39
41
|
githubAppKey?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The origin a browser reaches this server at, when that is not its loopback
|
|
44
|
+
* address (a tunnel to it): the issuer, and every URL it publishes, name it.
|
|
45
|
+
* It still listens on loopback only.
|
|
46
|
+
*/
|
|
47
|
+
publicOrigin?: string;
|
|
48
|
+
/** Origins besides loopback that the built-in clients may redirect to: the app's, behind the same tunnel. */
|
|
49
|
+
redirectOrigins?: readonly string[];
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
/** Built in, so local dev needs no registration step. */
|
|
@@ -59,6 +69,7 @@ export const DEFAULT_CLIENT = Object.freeze({
|
|
|
59
69
|
export class DevIdp {
|
|
60
70
|
#server: Server | null = null;
|
|
61
71
|
#port = 0;
|
|
72
|
+
#publicOrigin: string | undefined;
|
|
62
73
|
#clients = new Map<string, RegisteredClient>();
|
|
63
74
|
#subjects = new Map<string, string>();
|
|
64
75
|
#gitHubAccounts = new Map<string, GitHubAccount>();
|
|
@@ -85,11 +96,14 @@ export class DevIdp {
|
|
|
85
96
|
|
|
86
97
|
constructor(options: DevIdpOptions = {}) {
|
|
87
98
|
this.autoApprove = options.autoApprove ?? false;
|
|
99
|
+
this.#publicOrigin = options.publicOrigin === undefined ? undefined : new URL(options.publicOrigin).origin;
|
|
100
|
+
const redirectOrigins = (options.redirectOrigins ?? []).map((each) => new URL(each).origin);
|
|
88
101
|
this.githubApp = new FakeGitHubApp(() => this.origin, options.githubAppKey);
|
|
89
102
|
this.#clients.set(DEFAULT_CLIENT.clientId, {
|
|
90
103
|
...DEFAULT_CLIENT,
|
|
91
104
|
redirectUris: [],
|
|
92
105
|
anyLoopbackRedirect: true,
|
|
106
|
+
redirectOrigins,
|
|
93
107
|
});
|
|
94
108
|
for (const client of options.clients ?? []) this.registerClient(client);
|
|
95
109
|
// The GitHub App's own OAuth client, which signs people in as the fake GitHub's do.
|
|
@@ -98,6 +112,7 @@ export class DevIdp {
|
|
|
98
112
|
clientSecret: this.githubApp.clientSecret,
|
|
99
113
|
redirectUris: [],
|
|
100
114
|
anyLoopbackRedirect: true,
|
|
115
|
+
redirectOrigins,
|
|
101
116
|
});
|
|
102
117
|
|
|
103
118
|
const authz = new AuthorizationServer(this);
|
|
@@ -106,7 +121,7 @@ export class DevIdp {
|
|
|
106
121
|
|
|
107
122
|
get origin(): string {
|
|
108
123
|
if (this.#port === 0) throw new Error('DevIdp is not started');
|
|
109
|
-
return `http://127.0.0.1:${this.#port}`;
|
|
124
|
+
return this.#publicOrigin ?? `http://127.0.0.1:${this.#port}`;
|
|
110
125
|
}
|
|
111
126
|
|
|
112
127
|
/** Matches the Cloudflare Access team-domain issuer shape. */
|
|
@@ -185,6 +200,7 @@ export class DevIdp {
|
|
|
185
200
|
clientSecret: client.clientSecret,
|
|
186
201
|
redirectUris: [...client.redirectUris],
|
|
187
202
|
anyLoopbackRedirect: false,
|
|
203
|
+
redirectOrigins: [],
|
|
188
204
|
});
|
|
189
205
|
}
|
|
190
206
|
|
package/src/suite.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { bulkLimit, crossSite, grantScoping, instanceRoles, membersOnly, offboar
|
|
|
7
7
|
import { checkpoints, deletedTail, forgedVaultEntry, missingEntry, noAuditNoValue, revealAudited, rewrittenEntry, verification, writesAgree } from './checks/audit.ts';
|
|
8
8
|
import { earlierCheckpoint } from './checks/checkpoints.ts';
|
|
9
9
|
import { deletion } from './checks/deletion.ts';
|
|
10
|
-
import { folders, forks, inheritance, missingKeys, personalConfigs, references } from './checks/environments.ts';
|
|
10
|
+
import { folders, forks, inheritance, loosening, missingKeys, personalConfigs, references } from './checks/environments.ts';
|
|
11
11
|
import { appLogin, vaultLogin } from './checks/logins.ts';
|
|
12
12
|
import { mcpRead, mcpChanges, mcpConnect, mcpValues } from './checks/mcp.ts';
|
|
13
13
|
import { accessAuthorship, memberTampering, noAuditNoAccess, sealingRace } from './checks/members.ts';
|
|
@@ -42,6 +42,7 @@ export async function conform(deployment: Deployment, options: { bulkLimit: numb
|
|
|
42
42
|
await report.check('inheritance', all, ({ people, canaries }) => inheritance(people, canaries));
|
|
43
43
|
await report.check('personal configs', { people }, ({ people }) => personalConfigs(deployment, people));
|
|
44
44
|
await report.check('references', all, ({ people, canaries }) => references(deployment, people, canaries));
|
|
45
|
+
await report.check('loosening', { people }, ({ people }) => loosening(people));
|
|
45
46
|
await report.check('missing keys', { people }, ({ people }) => missingKeys(people));
|
|
46
47
|
// Before offboarding: the leaver's CLI session is one of the credentials /mcp must refuse.
|
|
47
48
|
await report.check('MCP connect', { people }, ({ people }) => mcpConnect(deployment, people));
|