@fabrika/provider-zerops 0.9.0-dev.10 → 0.9.0-dev.12
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/package.json +11 -11
- package/src/installation/deploy-options.ts +9 -0
- package/src/installation/deploy.ts +16 -1
- package/src/installation/guide.md +28 -9
- package/src/installation/index.ts +7 -0
- package/src/installation/plain-credentials.ts +91 -0
- package/src/installation/templates/README.md +13 -12
- package/src/installation/templates/platform.yml +3 -0
- package/src/installation/topology/setups.ts +10 -4
- package/src/installation/topology/topology.ts +1 -1
- package/src/manifest.ts +10 -1
- package/src/namespace/claims.ts +14 -4
- package/src/namespace/manifest.ts +41 -15
- package/src/namespace/provisioning.ts +2 -1
- package/src/plain-credentials.ts +90 -0
- package/src/types.ts +6 -0
- package/types/src/installation/deploy-options.d.ts +5 -0
- package/types/src/installation/plain-credentials.d.ts +20 -0
- package/types/src/namespace/codec.d.ts +4 -4
- package/types/src/namespace/manifest.d.ts +6 -1
- package/types/src/plain-credentials.d.ts +7 -0
- package/types/src/types.d.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/provider-zerops",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"typecheck": "
|
|
42
|
+
"typecheck": "tsrs --build tsconfig.test.json",
|
|
43
43
|
"test": "bun test",
|
|
44
44
|
"gen:schema": "bun scripts/generate-zerops-types.ts"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"zod": "^3.25.76",
|
|
48
|
-
"@fabrika/app": "0.9.0-dev.
|
|
49
|
-
"@fabrika/auth": "0.9.0-dev.
|
|
50
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
51
|
-
"@fabrika/email": "0.9.0-dev.
|
|
52
|
-
"@fabrika/iam-contract": "0.9.0-dev.
|
|
53
|
-
"@fabrika/installation-init": "0.9.0-dev.
|
|
54
|
-
"@fabrika/operations-contract": "0.9.0-dev.
|
|
55
|
-
"@fabrika/provider-contract": "0.9.0-dev.
|
|
56
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
48
|
+
"@fabrika/app": "0.9.0-dev.12",
|
|
49
|
+
"@fabrika/auth": "0.9.0-dev.12",
|
|
50
|
+
"@fabrika/auth-core": "0.9.0-dev.12",
|
|
51
|
+
"@fabrika/email": "0.9.0-dev.12",
|
|
52
|
+
"@fabrika/iam-contract": "0.9.0-dev.12",
|
|
53
|
+
"@fabrika/installation-init": "0.9.0-dev.12",
|
|
54
|
+
"@fabrika/operations-contract": "0.9.0-dev.12",
|
|
55
|
+
"@fabrika/provider-contract": "0.9.0-dev.12",
|
|
56
|
+
"@fabrika/proxy-core": "0.9.0-dev.12",
|
|
57
57
|
"yaml": "^2.9.1"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
// error naming both the flag and the variable that would supply it.
|
|
14
14
|
|
|
15
15
|
import { describeArgument, type McpClient, parseMcpClientsJson, readEnv, requiredSetting, setting } from '@fabrika/installation-init'
|
|
16
|
+
import { PLATFORM_DEPLOY_ORDER } from './deploy'
|
|
16
17
|
import { parsePlatformHosts, parsePlatformScheme } from './placement-options'
|
|
18
|
+
import { parsePlainVariables } from './plain-credentials'
|
|
17
19
|
import { readInstallationSourceDir } from './source-options'
|
|
18
20
|
|
|
19
21
|
/** How the project this installation lives in is named. */
|
|
@@ -39,6 +41,11 @@ export interface PlatformDeployInput {
|
|
|
39
41
|
readonly mcpClients?: readonly McpClient[]
|
|
40
42
|
/** IAM-issued `px_` admin key, used only to reconcile the console's schema. Environment only. */
|
|
41
43
|
readonly iamAdminKey: string
|
|
44
|
+
/**
|
|
45
|
+
* Readable service variables, as `<service>/<KEY>`, the operator has checked are not credentials. The deploy refuses
|
|
46
|
+
* every other readable variable that looks like one (`plain-credentials.ts`).
|
|
47
|
+
*/
|
|
48
|
+
readonly plainVariables?: ReadonlySet<string>
|
|
42
49
|
/** Read everything, write nothing, trigger nothing. */
|
|
43
50
|
readonly dryRun: boolean
|
|
44
51
|
}
|
|
@@ -54,6 +61,7 @@ const FLAGS = [
|
|
|
54
61
|
'--scheme',
|
|
55
62
|
'--source-dir',
|
|
56
63
|
'--mcp-clients',
|
|
64
|
+
'--plain-variables',
|
|
57
65
|
] as const
|
|
58
66
|
|
|
59
67
|
const assertKnownArguments = (argv: readonly string[]): void => {
|
|
@@ -128,6 +136,7 @@ export const parsePlatformDeployArgs = (
|
|
|
128
136
|
? readEnv(env, 'FABRIKA_IAM_PROVISIONING_KEY') ?? ''
|
|
129
137
|
: requiredSetting(readEnv(env, 'FABRIKA_IAM_PROVISIONING_KEY'), '(no flag)', 'FABRIKA_IAM_PROVISIONING_KEY'),
|
|
130
138
|
scheme,
|
|
139
|
+
plainVariables: parsePlainVariables(setting(argv, env, '--plain-variables', 'FABRIKA_PLATFORM_PLAIN_VARIABLES'), PLATFORM_DEPLOY_ORDER),
|
|
131
140
|
dryRun,
|
|
132
141
|
...(hosts === undefined ? {} : { hosts }),
|
|
133
142
|
sourceDir,
|
|
@@ -84,6 +84,7 @@ import {
|
|
|
84
84
|
validateInstallationSetups,
|
|
85
85
|
} from './installation-source'
|
|
86
86
|
import type { DeployLog } from './log'
|
|
87
|
+
import { plainCredentialRefusal, plainCredentialVariables } from './plain-credentials'
|
|
87
88
|
import { archiveWithDataFile } from './platform-archive'
|
|
88
89
|
import type { PreparedPlatformSource } from './platform-source'
|
|
89
90
|
import { type PlatformUploadFetch, uploadPlatformArchive } from './platform-upload'
|
|
@@ -804,9 +805,23 @@ export const deployPreparedPlatform = async (
|
|
|
804
805
|
controlTableDigest,
|
|
805
806
|
input.iamAdminKey,
|
|
806
807
|
)
|
|
808
|
+
// Every service's environment is read, and checked, before the first write: a refusal leaves nothing half-written.
|
|
809
|
+
const liveEnv = new Map<PlatformDeployService, LiveServiceEnv>()
|
|
810
|
+
for (const hostname of PLATFORM_DEPLOY_ORDER) {
|
|
811
|
+
liveEnv.set(hostname, hostname === PLATFORM_PROXY_SERVICE ? proxyEnv : await readServiceEnv(serviceOf(services, hostname).id, collaborators))
|
|
812
|
+
}
|
|
813
|
+
const plain = PLATFORM_DEPLOY_ORDER.flatMap((hostname) =>
|
|
814
|
+
plainCredentialVariables(
|
|
815
|
+
hostname,
|
|
816
|
+
liveEnv.get(hostname) ?? new Map(),
|
|
817
|
+
new Set(desired.get(hostname)?.keys() ?? []),
|
|
818
|
+
input.plainVariables ?? new Set(),
|
|
819
|
+
)
|
|
820
|
+
)
|
|
821
|
+
if (plain.length > 0) throw plainCredentialRefusal(plain)
|
|
807
822
|
for (const hostname of PLATFORM_DEPLOY_ORDER) {
|
|
808
823
|
const service = serviceOf(services, hostname)
|
|
809
|
-
const live = hostname
|
|
824
|
+
const live = liveEnv.get(hostname) ?? new Map<string, ZeropsServiceEnv>()
|
|
810
825
|
const keys = desired.get(hostname) ?? new Map<string, string>()
|
|
811
826
|
const liveOAuthConfig = live.get(IAM_OAUTH_CONFIG_VARIABLE)
|
|
812
827
|
const oauthStillSet = liveOAuthConfig !== undefined && (liveOAuthConfig.sensitive || liveOAuthConfig.content.trim() !== '')
|
|
@@ -383,6 +383,15 @@ forwarding a caller's `px_` key to the application (`docs/reference/deployment-n
|
|
|
383
383
|
service variable, which Zerops caps at about 32 KB: when a deploy fails with `serviceEnvValueTooLarge`, this is
|
|
384
384
|
the fix, and it also accepts a namespace in `failed`.
|
|
385
385
|
|
|
386
|
+
The platform services install only the workspace packages (`bun install --frozen-lockfile --filter './packages/*'`
|
|
387
|
+
in the generated `zerops.yaml`), not the repository's own tooling. An installation from before that change keeps the
|
|
388
|
+
tooling in each service's cached `node_modules`, because neither the filtered install nor a changed build command
|
|
389
|
+
clears the Zerops build cache. Nothing fails without clearing it. To shrink the artifacts of `iam`, `control` and
|
|
390
|
+
`operations` by about 160 MB each, invalidate their build cache once (service → Pipelines & CI/CD Settings →
|
|
391
|
+
Invalidate build cache); the next deploy of each builds clean. The platform `proxy` and each namespace's `proxy`
|
|
392
|
+
deploy no `node_modules`, so only their build cache would shrink; invalidating it is optional and costs one full
|
|
393
|
+
build of Caddy.
|
|
394
|
+
|
|
386
395
|
## Set or rotate the mail transport
|
|
387
396
|
|
|
388
397
|
The installation's mail transport lives on the `iam` and `control` services. Zerops is its record (ADR-0004),
|
|
@@ -392,20 +401,30 @@ existing installation, change the provider, or rotate a key:
|
|
|
392
401
|
No `fabrika` command does this: `platform upgrade` and `platform deploy` write no `FABRIKA_EMAIL_*` and remove
|
|
393
402
|
none, and `install` cannot be re-run.
|
|
394
403
|
|
|
395
|
-
1.
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
1. Pick a provider the RUNNING release accepts. The installation runs the tag in its sidecar's `fabrika.ref`; from a
|
|
405
|
+
checkout of that tag, `fabrika platform install --provider=zerops --help` lists the accepted providers on its
|
|
406
|
+
`--email-provider` line, and each provider's variables below it. A provider that only a newer release accepts needs
|
|
407
|
+
`platform upgrade --to=<that tag>` first: IAM refuses to start on a provider its release does not know.
|
|
408
|
+
2. Set the `FABRIKA_EMAIL_*` variables on `control` first, in the Zerops GUI or with `zcli`: `FABRIKA_EMAIL_PROVIDER`,
|
|
409
|
+
`FABRIKA_EMAIL_FROM`, optionally `FABRIKA_EMAIL_FROM_NAME`, and the provider's variables. Store the credentials
|
|
410
|
+
(every variable that help marks secret) as SENSITIVE variables: a readable one is read by every member of the
|
|
411
|
+
project, and `platform deploy` refuses to run while one is readable. A variable already stored readable does not
|
|
412
|
+
become sensitive through `zops env set --sensitive`, which leaves an existing variable as it was: delete it and add
|
|
413
|
+
it again as a secret one in the GUI. Delete the variables of a provider you leave.
|
|
414
|
+
3. Restart `control` and read its log. Control starts either way; an invalid transport prints
|
|
415
|
+
`control: the installation's mail transport is invalid, …` naming the invalid variables, and every deploy that needs
|
|
416
|
+
the transport is refused. Fix the values and restart until no such line appears.
|
|
417
|
+
4. Only then set the same variables on `iam` as in step 2 (credentials SENSITIVE, the old provider's variables deleted)
|
|
418
|
+
and restart it. IAM reads the transport at boot and refuses to start on an invalid one, so an `iam` restart with
|
|
419
|
+
values Control has not accepted takes sign-in down.
|
|
420
|
+
5. Redeploy every environment whose contract uses `installation` mail and whose application pins a framework release
|
|
402
421
|
older than 0.7. Such an application holds its own copy of the transport and gets the new one only at its next
|
|
403
422
|
deploy. Until then it sends with the old one, and a revoked key fails its mail with `provider_unauthorized`. An
|
|
404
|
-
application on 0.7 or newer sends through Control's relay, which uses the new transport once step
|
|
423
|
+
application on 0.7 or newer sends through Control's relay, which uses the new transport once step 3 restarted
|
|
405
424
|
Control: it needs no redeploy.
|
|
406
425
|
|
|
407
426
|
Without a transport, a contract whose job declares `mailer: 'installation'` still deploys. On a release older than 0.7
|
|
408
|
-
its jobs see that mail is not available and leave their messages queued, and after step
|
|
427
|
+
its jobs see that mail is not available and leave their messages queued, and after step 5 the next run sends them. On
|
|
409
428
|
0.7 or newer the relay accepts and holds the messages, and Control sends them once it has a transport.
|
|
410
429
|
|
|
411
430
|
## When something fails
|
|
@@ -228,6 +228,7 @@ Options (a flag beats the environment variable beside it):
|
|
|
228
228
|
--scheme=<http|https> FABRIKA_PLATFORM_SCHEME default https
|
|
229
229
|
--source-dir=<checkout> required clean full checkout running this CLI
|
|
230
230
|
--mcp-clients=<json> FABRIKA_PLATFORM_MCP_CLIENTS_JSON MCP authoring clients; unset = off
|
|
231
|
+
--plain-variables=<svc/KEY,...> FABRIKA_PLATFORM_PLAIN_VARIABLES readable variables that are not credentials
|
|
231
232
|
--dry-run read everything, change nothing
|
|
232
233
|
|
|
233
234
|
Naming NO host derives all three from the proxy service's Zerops subdomains and makes this a
|
|
@@ -250,6 +251,12 @@ process listing:
|
|
|
250
251
|
(a --dry-run does not need it)
|
|
251
252
|
FABRIKA_ZEROPS_API_URL optional region API base, when not the default
|
|
252
253
|
|
|
254
|
+
Before it writes anything, the deploy reads the environment of every platform service and refuses a
|
|
255
|
+
READABLE variable that looks like a credential (a mail provider's secret, a name with TOKEN, SECRET,
|
|
256
|
+
PASSWORD or a KEY, a value that reads like a token): every member of the Zerops project can read it.
|
|
257
|
+
Store such a variable sensitive. One checked and found not to be a credential is named in
|
|
258
|
+
--plain-variables as <service>/<KEY>.
|
|
259
|
+
|
|
253
260
|
This command writes one credential, derived from FABRIKA_IAM_PROVISIONING_KEY: the secret the proxy
|
|
254
261
|
proves its requests to IAM with. Every other secret an installation holds is placed at bring-up.
|
|
255
262
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// `platform deploy` refuses an installation whose platform services hold a credential as a READABLE variable.
|
|
2
|
+
//
|
|
3
|
+
// A readable service variable is read by every member of the Zerops project, and Zerops keeps no record of who read it.
|
|
4
|
+
// Nothing Fabrika writes is one: `install` writes the generated secrets and the mail credentials sensitive, and the
|
|
5
|
+
// deploy writes only configuration readable. But the guide's own procedures (setting or rotating the mail transport)
|
|
6
|
+
// are manual writes in the Zerops GUI or `zcli`, where `sensitive` is a checkbox. An installation was found holding its
|
|
7
|
+
// mail provider's token readable on `iam` and `control`, written that way. The deploy reads every service's environment
|
|
8
|
+
// anyway, and every upgrade runs it, so it is where such a variable is caught.
|
|
9
|
+
//
|
|
10
|
+
// The check is `plainCredentialFinding`'s heuristic plus the mail providers' own declarations, and it errs towards
|
|
11
|
+
// refusing, so `FABRIKA_PLATFORM_PLAIN_VARIABLES` names the variables an operator has checked are not credentials.
|
|
12
|
+
|
|
13
|
+
import { builtinEmailProviders } from '@fabrika/email/providers'
|
|
14
|
+
import { plainCredentialFinding } from '@fabrika/provider-contract'
|
|
15
|
+
import type { LiveServiceEnv, PlatformDeployService } from './deploy'
|
|
16
|
+
|
|
17
|
+
/** One readable variable that looks like a credential. Names only; the value is never carried. */
|
|
18
|
+
export interface PlainCredentialVariable {
|
|
19
|
+
readonly service: PlatformDeployService
|
|
20
|
+
readonly key: string
|
|
21
|
+
readonly because: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Every mail provider variable the provider itself declares secret, whichever provider an installation uses. */
|
|
25
|
+
const DECLARED_SECRET_EMAIL_VARIABLES: ReadonlySet<string> = new Set(
|
|
26
|
+
Object.values(builtinEmailProviders).flatMap((provider) =>
|
|
27
|
+
provider.variables.filter((variable) => variable.secret).map((variable) => variable.name)
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
/** `<service>/<KEY>`, the form an operator names an exception in. */
|
|
32
|
+
export const plainVariableId = (service: string, key: string): string => `${service}/${key}`
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The readable variables of one service that look like credentials.
|
|
36
|
+
*
|
|
37
|
+
* `written` are the keys this deploy writes itself, readable by design and about to be overwritten: they are its own
|
|
38
|
+
* configuration, never a credential. `allowed` are the `<service>/<KEY>` exceptions the operator named.
|
|
39
|
+
*/
|
|
40
|
+
export const plainCredentialVariables = (
|
|
41
|
+
service: PlatformDeployService,
|
|
42
|
+
live: LiveServiceEnv,
|
|
43
|
+
written: ReadonlySet<string>,
|
|
44
|
+
allowed: ReadonlySet<string>,
|
|
45
|
+
): PlainCredentialVariable[] => {
|
|
46
|
+
const found: PlainCredentialVariable[] = []
|
|
47
|
+
for (const [key, record] of live) {
|
|
48
|
+
// A record the platform owns (`type: SYSTEM`) is not the operator's to make sensitive, so it is not refused.
|
|
49
|
+
if (record.sensitive || record.type === 'SYSTEM' || written.has(key) || allowed.has(plainVariableId(service, key))) continue
|
|
50
|
+
if (DECLARED_SECRET_EMAIL_VARIABLES.has(key) && record.content.trim() !== '') {
|
|
51
|
+
found.push({ service, key, because: 'its mail provider declares it secret' })
|
|
52
|
+
continue
|
|
53
|
+
}
|
|
54
|
+
const finding = plainCredentialFinding(key, record.content)
|
|
55
|
+
if (finding !== null) found.push({ service, key, because: finding.because })
|
|
56
|
+
}
|
|
57
|
+
return found
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The refusal: each variable by name and reason, where it belongs instead, and the opt-out. Never a value. */
|
|
61
|
+
export const plainCredentialRefusal = (found: readonly PlainCredentialVariable[]): Error =>
|
|
62
|
+
new Error(
|
|
63
|
+
[
|
|
64
|
+
`${found.length} readable service variable(s) look like credentials, and every member of the Zerops project can read them:`,
|
|
65
|
+
...found.map((entry) => ` ${plainVariableId(entry.service, entry.key)}: ${entry.because}`),
|
|
66
|
+
'Store each one as a SENSITIVE variable of the same service, then restart that service: in the Zerops GUI, delete',
|
|
67
|
+
'the variable and add it again as a secret one. `zops env set --sensitive` does not change an existing variable.',
|
|
68
|
+
'Nothing has been written or deployed.',
|
|
69
|
+
'A variable that is not a credential: name it in FABRIKA_PLATFORM_PLAIN_VARIABLES (or --plain-variables) as',
|
|
70
|
+
'`<service>/<KEY>`, comma-separated, and deploy again.',
|
|
71
|
+
].join('\n'),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
/** Parse the operator's exceptions: comma-separated `<service>/<KEY>`, each naming a platform service. */
|
|
75
|
+
export const parsePlainVariables = (raw: string | undefined, services: readonly string[]): ReadonlySet<string> => {
|
|
76
|
+
const allowed = new Set<string>()
|
|
77
|
+
if (raw === undefined) return allowed
|
|
78
|
+
for (const [index, entry] of raw.split(',').map((item) => item.trim()).filter((item) => item !== '').entries()) {
|
|
79
|
+
const slash = entry.indexOf('/')
|
|
80
|
+
const service = slash === -1 ? '' : entry.slice(0, slash)
|
|
81
|
+
const key = slash === -1 ? '' : entry.slice(slash + 1)
|
|
82
|
+
if (!services.includes(service) || !/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(key)) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
// The entry is not echoed: a value pasted there by mistake would land in a CI log.
|
|
85
|
+
`--plain-variables / FABRIKA_PLATFORM_PLAIN_VARIABLES: entry ${index + 1} is not \`<service>/<KEY>\` with a service of ${services.join(', ')}`,
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
allowed.add(plainVariableId(service, key))
|
|
89
|
+
}
|
|
90
|
+
return allowed
|
|
91
|
+
}
|
|
@@ -81,16 +81,17 @@ installation already holds.
|
|
|
81
81
|
|
|
82
82
|
**Variables** — the rest of the configuration, all non-secret.
|
|
83
83
|
|
|
84
|
-
| Variable | Required | What it is
|
|
85
|
-
| ----------------------------------- | -------- |
|
|
86
|
-
| `FABRIKA_ZEROPS_PROJECT_ID` | yes | The Zerops project holding the four platform runtime services.
|
|
87
|
-
| `FABRIKA_PLATFORM_ENVIRONMENT` | yes | The name this installation calls itself; written to every service as `ENVIRONMENT`. Never `local`.
|
|
88
|
-
| `FABRIKA_PLATFORM_SCHEME` | yes | `https` for anything reachable from a browser.
|
|
89
|
-
| `FABRIKA_PLATFORM_IAM_HOST` | no | Where IAM answers publicly.
|
|
90
|
-
| `FABRIKA_PLATFORM_CONSOLE_HOST` | no | Where the console answers publicly.
|
|
91
|
-
| `FABRIKA_PLATFORM_OPERATIONS_HOST` | no | Where Operations ingest answers publicly.
|
|
92
|
-
| `FABRIKA_ZEROPS_API_URL` | no | Region API base, when this installation is not on the default one.
|
|
93
|
-
| `FABRIKA_PLATFORM_MCP_CLIENTS_JSON` | no | The MCP clients that may author applications (JSON array). Unset leaves MCP authoring off.
|
|
84
|
+
| Variable | Required | What it is |
|
|
85
|
+
| ----------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| `FABRIKA_ZEROPS_PROJECT_ID` | yes | The Zerops project holding the four platform runtime services. |
|
|
87
|
+
| `FABRIKA_PLATFORM_ENVIRONMENT` | yes | The name this installation calls itself; written to every service as `ENVIRONMENT`. Never `local`. |
|
|
88
|
+
| `FABRIKA_PLATFORM_SCHEME` | yes | `https` for anything reachable from a browser. |
|
|
89
|
+
| `FABRIKA_PLATFORM_IAM_HOST` | no | Where IAM answers publicly. |
|
|
90
|
+
| `FABRIKA_PLATFORM_CONSOLE_HOST` | no | Where the console answers publicly. |
|
|
91
|
+
| `FABRIKA_PLATFORM_OPERATIONS_HOST` | no | Where Operations ingest answers publicly. |
|
|
92
|
+
| `FABRIKA_ZEROPS_API_URL` | no | Region API base, when this installation is not on the default one. |
|
|
93
|
+
| `FABRIKA_PLATFORM_MCP_CLIENTS_JSON` | no | The MCP clients that may author applications (JSON array). Unset leaves MCP authoring off. |
|
|
94
|
+
| `FABRIKA_PLATFORM_PLAIN_VARIABLES` | no | Readable service variables checked and found not to be credentials, as `<service>/<KEY>`, comma-separated. |
|
|
94
95
|
|
|
95
96
|
The three host variables go together: **all three, or none.** Naming none derives them from the
|
|
96
97
|
proxy's generated Zerops subdomains, and the deploy publishes that subdomain. Naming all three makes
|
|
@@ -98,8 +99,8 @@ this a custom-domain installation — the domains are bound to the project balan
|
|
|
98
99
|
deploy publishes no subdomain, because that would add a second public address nobody asked for.
|
|
99
100
|
|
|
100
101
|
`FABRIKA_PLATFORM_MCP_CLIENTS_JSON` turns on MCP authoring (ADR-0049). A workflow generated before
|
|
101
|
-
that variable existed does not forward it
|
|
102
|
-
this line to the `env:` of the _Deploy the platform_ step in `.github/workflows/platform.yml`:
|
|
102
|
+
that variable existed does not forward it. `platform upgrade` rewrites such a workflow at its next roll; to forward it
|
|
103
|
+
sooner, add this line to the `env:` of the _Deploy the platform_ step in `.github/workflows/platform.yml`:
|
|
103
104
|
|
|
104
105
|
```yaml
|
|
105
106
|
FABRIKA_PLATFORM_MCP_CLIENTS_JSON: ${{ vars.FABRIKA_PLATFORM_MCP_CLIENTS_JSON }}
|
|
@@ -152,6 +152,9 @@ jobs:
|
|
|
152
152
|
FABRIKA_ZEROPS_API_URL: ${{ vars.FABRIKA_ZEROPS_API_URL }}
|
|
153
153
|
# MCP authoring (ADR-0049): a JSON array of the MCP clients this installation trusts. Unset = off.
|
|
154
154
|
FABRIKA_PLATFORM_MCP_CLIENTS_JSON: ${{ vars.FABRIKA_PLATFORM_MCP_CLIENTS_JSON }}
|
|
155
|
+
# The deploy refuses a readable service variable that looks like a credential. Comma-separated
|
|
156
|
+
# `<service>/<KEY>` names the ones checked and found not to be. Unset = none.
|
|
157
|
+
FABRIKA_PLATFORM_PLAIN_VARIABLES: ${{ vars.FABRIKA_PLATFORM_PLAIN_VARIABLES }}
|
|
155
158
|
run: fabrika platform deploy --provider=zerops --source-dir=. ${{ inputs.dry_run && '--dry-run' || '' }}
|
|
156
159
|
|
|
157
160
|
- name: Summary
|
|
@@ -160,6 +160,12 @@ const READINESS_IMMEDIATE: Omit<ZeropsReadinessCheckSpec, 'httpGet' | 'exec'> =
|
|
|
160
160
|
*/
|
|
161
161
|
const WORKSPACE_DEPLOY_FILES = ['package.json', 'bun.lock', 'node_modules', 'packages']
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* The install of every platform service: the workspace packages, without the root package's own tooling (checkers,
|
|
165
|
+
* linters, browsers), which no service builds or runs with. The quotes keep the build shell from expanding the glob.
|
|
166
|
+
*/
|
|
167
|
+
const WORKSPACE_INSTALL = "bun install --frozen-lockfile --filter './packages/*'"
|
|
168
|
+
|
|
163
169
|
/**
|
|
164
170
|
* The IAM service — identity, tokens, audit, and the private admin API.
|
|
165
171
|
*
|
|
@@ -192,7 +198,7 @@ const iam: ZeropsYamlSetupSpec = {
|
|
|
192
198
|
build: {
|
|
193
199
|
// Bun on Alpine. `build.os` is deprecated in the published schema — the OS is part of the base id.
|
|
194
200
|
base: ['alpine/bun@1.3'],
|
|
195
|
-
buildCommands: [
|
|
201
|
+
buildCommands: [WORKSPACE_INSTALL],
|
|
196
202
|
deployFiles: WORKSPACE_DEPLOY_FILES,
|
|
197
203
|
cache: ['node_modules'],
|
|
198
204
|
},
|
|
@@ -265,7 +271,7 @@ const control: ZeropsYamlSetupSpec = {
|
|
|
265
271
|
setup: 'control',
|
|
266
272
|
build: {
|
|
267
273
|
base: ['alpine/bun@1.3'],
|
|
268
|
-
buildCommands: [
|
|
274
|
+
buildCommands: [WORKSPACE_INSTALL, 'bun run --filter @fabrika/dashboard build'],
|
|
269
275
|
deployFiles: WORKSPACE_DEPLOY_FILES,
|
|
270
276
|
cache: ['node_modules'],
|
|
271
277
|
},
|
|
@@ -307,7 +313,7 @@ const operations: ZeropsYamlSetupSpec = {
|
|
|
307
313
|
setup: 'operations',
|
|
308
314
|
build: {
|
|
309
315
|
base: ['alpine/bun@1.3'],
|
|
310
|
-
buildCommands: [
|
|
316
|
+
buildCommands: [WORKSPACE_INSTALL],
|
|
311
317
|
deployFiles: WORKSPACE_DEPLOY_FILES,
|
|
312
318
|
cache: ['node_modules'],
|
|
313
319
|
},
|
|
@@ -412,7 +418,7 @@ const proxy: ZeropsYamlSetupSpec = {
|
|
|
412
418
|
// CGO off makes the binary static, which is what lets it run on Alpine/musl.
|
|
413
419
|
prepareCommands: ['CGO_ENABLED=0 GOBIN=/tmp/gobin go install github.com/caddyserver/caddy/v2/cmd/caddy@v2.10.2'],
|
|
414
420
|
buildCommands: [
|
|
415
|
-
|
|
421
|
+
WORKSPACE_INSTALL,
|
|
416
422
|
// The archive's data file (see the header). Missing/malformed JSON fails the build; an empty app list
|
|
417
423
|
// emits only deny/404 routes.
|
|
418
424
|
`bun run packages/proxy/src/generate-config.ts ./proxy.manifest.json ./caddy.json --auth-upstream 127.0.0.1:9000 --listen ${
|
|
@@ -364,7 +364,7 @@ const lightPlatformTopology = (options: TopologyOptions, publicAccess: PublicAcc
|
|
|
364
364
|
priority: 30,
|
|
365
365
|
public: publicAccess === 'zerops-subdomain',
|
|
366
366
|
// Still the only publicly routed service (ADR-0022). One container is a real availability
|
|
367
|
-
// trade
|
|
367
|
+
// trade (the operator guide prices it against `standard`); it is not a relaxation of the rule
|
|
368
368
|
// about WHICH service faces the internet.
|
|
369
369
|
minContainers: 1,
|
|
370
370
|
maxContainers: 2,
|
package/src/manifest.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type ZeropsRuntimePackage,
|
|
23
23
|
} from './execution'
|
|
24
24
|
import { assertAuthoredManagedDocument, assertAuthoredManagedInputs } from './managed-env'
|
|
25
|
+
import { assertNoAuthoredPlainCredential } from './plain-credentials'
|
|
25
26
|
import { allowedReferenceHosts, foreignReferenceHost, platformOnlyServiceReference } from './service-references'
|
|
26
27
|
import type { ZeropsAppConfig, ZeropsNamespaceResourceRequirement, ZeropsProxySpec, ZeropsSharedPostgresBinding } from './types'
|
|
27
28
|
|
|
@@ -663,7 +664,15 @@ export function compileFabrikaManifest(config: ZeropsAppConfig, env: string, sou
|
|
|
663
664
|
},
|
|
664
665
|
}
|
|
665
666
|
// The JSON copy is the artifact's own form: authored objects lose inherited fields and undefined keys once, here.
|
|
666
|
-
|
|
667
|
+
const manifest = parseFabrikaManifest(jsonValue(candidate), { appId: config.id, env })
|
|
668
|
+
// After the parse, whose refusals are more precise (a Fabrika-managed name), and at build only: a stored manifest is
|
|
669
|
+
// never refused for it when decoded, so an application built by an older release keeps deploying.
|
|
670
|
+
assertNoAuthoredPlainCredential(
|
|
671
|
+
jsonValue(manifest.target.importDocument),
|
|
672
|
+
parseZeropsDescriptor(manifest.target.sourceDescriptor.contents).document,
|
|
673
|
+
config.target.notSecret ?? [],
|
|
674
|
+
)
|
|
675
|
+
return manifest
|
|
667
676
|
} finally {
|
|
668
677
|
for (const name of declaredVars) {
|
|
669
678
|
const value = prior[name]
|
package/src/namespace/claims.ts
CHANGED
|
@@ -13,6 +13,12 @@ import { decodeEnvelope } from './codec'
|
|
|
13
13
|
import { ZEROPS_NAMESPACE_POSTGRES_HOSTNAME, ZEROPS_NAMESPACE_PROXY_HOSTNAME } from './constants'
|
|
14
14
|
import { asNamespaceError } from './errors'
|
|
15
15
|
|
|
16
|
+
/** Refused for an app service whatever the target records now: any namespace may add a sandbox host later. */
|
|
17
|
+
const RESERVED_HOSTNAMES: ReadonlySet<string> = new Set([ZEROPS_NAMESPACE_PROXY_HOSTNAME, SANDBOX_HOST_HOSTNAME])
|
|
18
|
+
|
|
19
|
+
/** A shared namespace also keeps `postgres`, because adopting its project refuses an undeclared `postgres` service. */
|
|
20
|
+
const SHARED_RESERVED_HOSTNAMES: ReadonlySet<string> = new Set([...RESERVED_HOSTNAMES, ZEROPS_NAMESPACE_POSTGRES_HOSTNAME])
|
|
21
|
+
|
|
16
22
|
export const namespaceResourceClaims = (namespace: ProviderDeploymentNamespace): string[] => {
|
|
17
23
|
const target = decodeEnvelope(namespace.target)
|
|
18
24
|
return [
|
|
@@ -70,13 +76,17 @@ export const registrationResourceClaims = (registration: ProviderRegistration):
|
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
const hostnames = manifestServiceHostnames(manifest)
|
|
79
|
+
const shared = namespace.exclusiveAppId === undefined
|
|
80
|
+
const reserved = shared ? SHARED_RESERVED_HOSTNAMES : RESERVED_HOSTNAMES
|
|
73
81
|
for (const hostname of hostnames) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
if (namespaceClaims.has(`service:${hostname}`) || reserved.has(hostname)) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Zerops service hostname \`${hostname}\` is reserved by the namespace: rename the service `
|
|
85
|
+
+ '(docs/reference/deployment-namespaces.md, "Renaming a reserved service")',
|
|
86
|
+
)
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
|
-
if (
|
|
89
|
+
if (shared) {
|
|
80
90
|
const prefix = zeropsSharedServicePrefix(registration.app.id)
|
|
81
91
|
for (const hostname of hostnames) {
|
|
82
92
|
if (!hostname.startsWith(prefix) || hostname.length === prefix.length) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { appEnvironmentId } from '@fabrika/auth-core'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
decodeEnvelope,
|
|
4
|
+
type ProviderApprovedAccess,
|
|
5
|
+
type ProviderNamespaceMember,
|
|
6
|
+
type ProviderNamespaceMemberRouting,
|
|
7
|
+
} from '@fabrika/provider-contract'
|
|
3
8
|
import { contractProxyEntry, contractProxyTable, devSandboxEntryId, type ProxyManifest } from '@fabrika/proxy-core/manifest'
|
|
4
9
|
import { assertFabrikaManifestCoordinates, zeropsArtifactCodec } from '../manifest'
|
|
5
10
|
import { SANDBOX_UPSTREAM } from '../sandbox-host'
|
|
@@ -22,7 +27,7 @@ export function compileNamespaceProxyManifest(namespaceId: string, members: read
|
|
|
22
27
|
const audience = appEnvironmentId(member.appId, member.env)
|
|
23
28
|
for (const sandbox of member.devSandboxes) {
|
|
24
29
|
const id = devSandboxEntryId(member.appId, sandbox.workspaceId)
|
|
25
|
-
const host = sandbox
|
|
30
|
+
const host = sandboxHost(sandbox)
|
|
26
31
|
claim(id, host)
|
|
27
32
|
apps.push(contractProxyEntry({
|
|
28
33
|
id,
|
|
@@ -38,25 +43,16 @@ export function compileNamespaceProxyManifest(namespaceId: string, members: read
|
|
|
38
43
|
}
|
|
39
44
|
continue
|
|
40
45
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const access =
|
|
44
|
-
if (access === undefined) continue
|
|
45
|
-
const manifest = decodeEnvelope('artifact', 'zerops', member.artifact, zeropsArtifactCodec)
|
|
46
|
-
assertFabrikaManifestCoordinates(manifest.app, { appId: member.appId, env: member.env })
|
|
47
|
-
const proxy = manifest.target.proxy
|
|
48
|
-
if (proxy === undefined) continue
|
|
49
|
-
if (member.domain === undefined || member.domain === '') {
|
|
50
|
-
throw new Error(`Zerops proxy target ${member.appId}/${member.env} requires a public domain`)
|
|
51
|
-
}
|
|
52
|
-
const host = member.domain.toLowerCase()
|
|
46
|
+
const routed = routedContractMember(member)
|
|
47
|
+
if (routed === undefined) continue
|
|
48
|
+
const { host, upstream, access } = routed
|
|
53
49
|
// The proxy mints for the IAM application id of this environment (ADR-0022 rule 6).
|
|
54
50
|
const id = appEnvironmentId(member.appId, member.env)
|
|
55
51
|
claim(id, host)
|
|
56
52
|
apps.push(contractProxyEntry({
|
|
57
53
|
id,
|
|
58
54
|
hosts: [host],
|
|
59
|
-
upstream
|
|
55
|
+
upstream,
|
|
60
56
|
// A Zerops public domain is always served over the project's TLS-terminating L7 balancer, so the
|
|
61
57
|
// browser speaks https even though the proxy itself is reached over plain HTTP (ADR-0022).
|
|
62
58
|
scheme: 'https',
|
|
@@ -67,3 +63,33 @@ export function compileNamespaceProxyManifest(namespaceId: string, members: read
|
|
|
67
63
|
}
|
|
68
64
|
return { apps }
|
|
69
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The hosts the namespace proxy routes one member on, lower-cased: a dev member's workspace sandbox hosts, otherwise its
|
|
69
|
+
* domain once Control approved a contract for a manifest with a proxy target. The compiler above routes by the same rule.
|
|
70
|
+
*/
|
|
71
|
+
export function namespaceMemberHosts(member: ProviderNamespaceMemberRouting): string[] {
|
|
72
|
+
if (member.devSandboxes !== undefined) return member.devSandboxes.map(sandboxHost)
|
|
73
|
+
const routed = routedContractMember(member)
|
|
74
|
+
return routed === undefined ? [] : [routed.host]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const sandboxHost = (sandbox: { readonly host: string }): string => sandbox.host.toLowerCase()
|
|
78
|
+
|
|
79
|
+
/** A member that is not a dev member, routed on its domain; undefined when the proxy does not route it. */
|
|
80
|
+
function routedContractMember(
|
|
81
|
+
member: ProviderNamespaceMemberRouting,
|
|
82
|
+
): { readonly host: string; readonly upstream: string; readonly access: ProviderApprovedAccess } | undefined {
|
|
83
|
+
// Only Control decides what routes a member (ADR-0050): its approved contract's endpoint table. A member without
|
|
84
|
+
// one is not routed, and its artifact is not decoded, so a legacy one cannot stop the others' republish.
|
|
85
|
+
const access = member.access
|
|
86
|
+
if (access === undefined) return undefined
|
|
87
|
+
const manifest = decodeEnvelope('artifact', 'zerops', member.artifact, zeropsArtifactCodec)
|
|
88
|
+
assertFabrikaManifestCoordinates(manifest.app, { appId: member.appId, env: member.env })
|
|
89
|
+
const proxy = manifest.target.proxy
|
|
90
|
+
if (proxy === undefined) return undefined
|
|
91
|
+
if (member.domain === undefined || member.domain === '') {
|
|
92
|
+
throw new Error(`Zerops proxy target ${member.appId}/${member.env} requires a public domain`)
|
|
93
|
+
}
|
|
94
|
+
return { host: member.domain.toLowerCase(), upstream: proxy.upstream, access }
|
|
95
|
+
}
|
|
@@ -13,7 +13,7 @@ import { claimedResources, namespaceResourceClaims, projectExists, registrationR
|
|
|
13
13
|
import { checkpoint, decodeEnvelope, normalizedNamespace, normalizeTarget } from './codec'
|
|
14
14
|
import { ZEROPS_NAMESPACE_POSTGRES_HOSTNAME, ZEROPS_NAMESPACE_PROXY_HOSTNAME } from './constants'
|
|
15
15
|
import { asNamespaceError, namespaceError } from './errors'
|
|
16
|
-
import { compileNamespaceProxyManifest } from './manifest'
|
|
16
|
+
import { compileNamespaceProxyManifest, namespaceMemberHosts } from './manifest'
|
|
17
17
|
import { createZeropsNamespaceOperator } from './operator'
|
|
18
18
|
import { republishProxy } from './proxy-attempt'
|
|
19
19
|
import { assertNamespaceProxyAcceptsSandboxes } from './proxy-reads'
|
|
@@ -445,6 +445,7 @@ export const createZeropsNamespaceCapabilities = (options: ZeropsNamespaceOption
|
|
|
445
445
|
provision: (input) => mutateNamespace(input, options, 'provision'),
|
|
446
446
|
reconcile: (input) => mutateNamespace(input, options, 'reconcile'),
|
|
447
447
|
republish: (input) => republishNamespace(input, options),
|
|
448
|
+
memberHosts: namespaceMemberHosts,
|
|
448
449
|
claimedResources: (input) => claimedResources(options.api, input),
|
|
449
450
|
updates: createZeropsNamespaceUpdates(options),
|
|
450
451
|
operator: createZeropsNamespaceOperator({ proxySource: options.proxySource }),
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// `fabrika app build` refuses an application configuration that writes a credential where everyone can read it.
|
|
2
|
+
//
|
|
3
|
+
// Every `envVariables` value a Zerops application authors (in any setup of its `zerops.yaml`; the compiled import of
|
|
4
|
+
// `fabrika.config.ts` is checked the same way, though its types offer none today) becomes a READABLE service variable,
|
|
5
|
+
// read by every member of the project, and sits in the repository in clear. A `run.routing.headers` value is sent to every visitor. A credential belongs in `pipeline.secrets`, set with
|
|
6
|
+
// `fabrika control apps secrets put`, which Zerops stores sensitive. The check runs at build only, never when a stored
|
|
7
|
+
// manifest is decoded: an application meets it when it raises its own pin, as with any framework API change.
|
|
8
|
+
//
|
|
9
|
+
// The heuristic errs towards refusing, so `target.notSecret` names the variables and headers the author has checked.
|
|
10
|
+
|
|
11
|
+
import type { JsonValue } from '@fabrika/provider-contract'
|
|
12
|
+
import { plainCredentialFinding } from '@fabrika/provider-contract'
|
|
13
|
+
|
|
14
|
+
/** One authored value that looks like a credential: where it is, and why. Never the value. */
|
|
15
|
+
interface AuthoredPlainCredential {
|
|
16
|
+
readonly path: string
|
|
17
|
+
readonly name: string
|
|
18
|
+
readonly because: string
|
|
19
|
+
readonly header: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const isMapping = (value: JsonValue | undefined): value is { readonly [key: string]: JsonValue } =>
|
|
23
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
24
|
+
|
|
25
|
+
/** Every `envVariables` entry and every `routing.headers[].values` entry of a document, at any depth. */
|
|
26
|
+
const authoredPlainCredentials = (document: JsonValue, root: string, notSecret: ReadonlySet<string>): AuthoredPlainCredential[] => {
|
|
27
|
+
const found: AuthoredPlainCredential[] = []
|
|
28
|
+
const check = (path: string, name: string, value: JsonValue, header: boolean): void => {
|
|
29
|
+
// A header name is case-insensitive, as HTTP has it; a variable name is exact.
|
|
30
|
+
const listed = header ? [...notSecret].some((entry) => entry.toLowerCase() === name.toLowerCase()) : notSecret.has(name)
|
|
31
|
+
if (typeof value !== 'string' || listed) return
|
|
32
|
+
const finding = plainCredentialFinding(name, value)
|
|
33
|
+
if (finding !== null) found.push({ path, name, because: finding.because, header })
|
|
34
|
+
}
|
|
35
|
+
const visit = (value: JsonValue, path: string): void => {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
value.forEach((item, index) => visit(item, `${path}[${index}]`))
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (!isMapping(value)) return
|
|
41
|
+
for (const [key, item] of Object.entries(value)) {
|
|
42
|
+
const at = `${path}.${key}`
|
|
43
|
+
if (key === 'envVariables' && isMapping(item)) {
|
|
44
|
+
for (const [name, text] of Object.entries(item)) check(`${at}.${name}`, name, text, false)
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
if (key === 'routing' && isMapping(item) && Array.isArray(item['headers'])) {
|
|
48
|
+
item['headers'].forEach((rule, index) => {
|
|
49
|
+
const values = isMapping(rule) ? rule['values'] : undefined
|
|
50
|
+
if (!isMapping(values)) return
|
|
51
|
+
for (const [name, text] of Object.entries(values)) check(`${at}.headers[${index}].values.${name}`, name, text, true)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
visit(item, at)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
visit(document, root)
|
|
58
|
+
return found
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Refuse every authored plain value that looks like a credential, naming each by its path and reason, never by value.
|
|
63
|
+
*
|
|
64
|
+
* `importDocument` is the compiled import of `fabrika.config.ts`; `descriptor` the parsed `zerops.yaml`, every setup.
|
|
65
|
+
*/
|
|
66
|
+
export function assertNoAuthoredPlainCredential(
|
|
67
|
+
importDocument: JsonValue,
|
|
68
|
+
descriptor: JsonValue,
|
|
69
|
+
notSecret: readonly string[],
|
|
70
|
+
): void {
|
|
71
|
+
const allowed = new Set(notSecret)
|
|
72
|
+
const found = [
|
|
73
|
+
...authoredPlainCredentials(importDocument, 'fabrika.config.ts', allowed),
|
|
74
|
+
...authoredPlainCredentials(descriptor, 'zerops.yaml', allowed),
|
|
75
|
+
]
|
|
76
|
+
if (found.length === 0) return
|
|
77
|
+
const lines = found.map((entry) => ` ${entry.path}: ${entry.because}`)
|
|
78
|
+
const remedies = [
|
|
79
|
+
found.some((entry) => !entry.header)
|
|
80
|
+
? 'An `envVariables` value is a readable service variable, which every member of the Zerops project can read, and it '
|
|
81
|
+
+ 'sits in the repository in clear. Declare a credential in `pipeline.secrets` instead and set it with '
|
|
82
|
+
+ '`fabrika control apps secrets put --app=<id> --name=<NAME>` (the value on stdin); Zerops stores it sensitive.'
|
|
83
|
+
: '',
|
|
84
|
+
found.some((entry) => entry.header)
|
|
85
|
+
? 'A `routing.headers` value is sent to every visitor. A credential has no place there.'
|
|
86
|
+
: '',
|
|
87
|
+
'A value that is not a credential: list its variable or header name in `target.notSecret` of fabrika.config.ts.',
|
|
88
|
+
].filter((line) => line !== '')
|
|
89
|
+
throw new Error(['fabrika app build: plain configuration that looks like a credential:', ...lines, ...remedies].join('\n'))
|
|
90
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -119,6 +119,12 @@ export interface ZeropsSourceTarget {
|
|
|
119
119
|
runtimePackages?: ZeropsRuntimePackage[]
|
|
120
120
|
services: (ctx: ZeropsResourceContext) => ZeropsServiceSpec[]
|
|
121
121
|
project?: ZeropsProjectSpec
|
|
122
|
+
/**
|
|
123
|
+
* Variable and header names whose plain value is not a credential. `fabrika app build` refuses an `envVariables` or
|
|
124
|
+
* `routing.headers` value that looks like one (its name says `TOKEN`, `PASSWORD`, `SECRET`, a key, or its value reads
|
|
125
|
+
* like a token); a name listed here is stored as written. A real credential goes in `pipeline.secrets`.
|
|
126
|
+
*/
|
|
127
|
+
notSecret?: readonly string[]
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
export interface ZeropsAppConfig extends AppConfigBase {
|
|
@@ -30,6 +30,11 @@ export interface PlatformDeployInput {
|
|
|
30
30
|
readonly mcpClients?: readonly McpClient[];
|
|
31
31
|
/** IAM-issued `px_` admin key, used only to reconcile the console's schema. Environment only. */
|
|
32
32
|
readonly iamAdminKey: string;
|
|
33
|
+
/**
|
|
34
|
+
* Readable service variables, as `<service>/<KEY>`, the operator has checked are not credentials. The deploy refuses
|
|
35
|
+
* every other readable variable that looks like one (`plain-credentials.ts`).
|
|
36
|
+
*/
|
|
37
|
+
readonly plainVariables?: ReadonlySet<string>;
|
|
33
38
|
/** Read everything, write nothing, trigger nothing. */
|
|
34
39
|
readonly dryRun: boolean;
|
|
35
40
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LiveServiceEnv, PlatformDeployService } from './deploy';
|
|
2
|
+
/** One readable variable that looks like a credential. Names only; the value is never carried. */
|
|
3
|
+
export interface PlainCredentialVariable {
|
|
4
|
+
readonly service: PlatformDeployService;
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly because: string;
|
|
7
|
+
}
|
|
8
|
+
/** `<service>/<KEY>`, the form an operator names an exception in. */
|
|
9
|
+
export declare const plainVariableId: (service: string, key: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* The readable variables of one service that look like credentials.
|
|
12
|
+
*
|
|
13
|
+
* `written` are the keys this deploy writes itself, readable by design and about to be overwritten: they are its own
|
|
14
|
+
* configuration, never a credential. `allowed` are the `<service>/<KEY>` exceptions the operator named.
|
|
15
|
+
*/
|
|
16
|
+
export declare const plainCredentialVariables: (service: PlatformDeployService, live: LiveServiceEnv, written: ReadonlySet<string>, allowed: ReadonlySet<string>) => PlainCredentialVariable[];
|
|
17
|
+
/** The refusal: each variable by name and reason, where it belongs instead, and the opt-out. Never a value. */
|
|
18
|
+
export declare const plainCredentialRefusal: (found: readonly PlainCredentialVariable[]) => Error;
|
|
19
|
+
/** Parse the operator's exceptions: comma-separated `<service>/<KEY>`, each naming a platform service. */
|
|
20
|
+
export declare const parsePlainVariables: (raw: string | undefined, services: readonly string[]) => ReadonlySet<string>;
|
|
@@ -128,11 +128,11 @@ export declare const namespaceUpdatePayloadSchema: z.ZodObject<{
|
|
|
128
128
|
host: z.ZodString;
|
|
129
129
|
port: z.ZodNumber;
|
|
130
130
|
}, "strip", z.ZodTypeAny, {
|
|
131
|
-
port: number;
|
|
132
131
|
host: string;
|
|
133
|
-
}, {
|
|
134
132
|
port: number;
|
|
133
|
+
}, {
|
|
135
134
|
host: string;
|
|
135
|
+
port: number;
|
|
136
136
|
}>, "many">>>;
|
|
137
137
|
sandboxHost: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
138
138
|
serviceId: z.ZodString;
|
|
@@ -281,8 +281,8 @@ export declare const namespaceUpdatePayloadSchema: z.ZodObject<{
|
|
|
281
281
|
proxyBaselineSequence?: number | undefined;
|
|
282
282
|
proxyAppVersionId?: string | undefined;
|
|
283
283
|
proxyHosts?: {
|
|
284
|
-
port: number;
|
|
285
284
|
host: string;
|
|
285
|
+
port: number;
|
|
286
286
|
}[] | undefined;
|
|
287
287
|
sandboxHost?: {
|
|
288
288
|
serviceId: string;
|
|
@@ -335,8 +335,8 @@ export declare const namespaceUpdatePayloadSchema: z.ZodObject<{
|
|
|
335
335
|
proxyBaselineSequence?: number | undefined;
|
|
336
336
|
proxyAppVersionId?: string | undefined;
|
|
337
337
|
proxyHosts?: {
|
|
338
|
-
port: number;
|
|
339
338
|
host: string;
|
|
339
|
+
port: number;
|
|
340
340
|
}[] | undefined;
|
|
341
341
|
sandboxHost?: {
|
|
342
342
|
serviceId: string;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { type ProviderNamespaceMember } from '@fabrika/provider-contract';
|
|
1
|
+
import { type ProviderNamespaceMember, type ProviderNamespaceMemberRouting } from '@fabrika/provider-contract';
|
|
2
2
|
import { type ProxyManifest } from '@fabrika/proxy-core/manifest';
|
|
3
3
|
/** Compile every public member of one deployment namespace into its strict proxy manifest. */
|
|
4
4
|
export declare function compileNamespaceProxyManifest(namespaceId: string, members: readonly ProviderNamespaceMember[]): ProxyManifest;
|
|
5
|
+
/**
|
|
6
|
+
* The hosts the namespace proxy routes one member on, lower-cased: a dev member's workspace sandbox hosts, otherwise its
|
|
7
|
+
* domain once Control approved a contract for a manifest with a proxy target. The compiler above routes by the same rule.
|
|
8
|
+
*/
|
|
9
|
+
export declare function namespaceMemberHosts(member: ProviderNamespaceMemberRouting): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JsonValue } from '@fabrika/provider-contract';
|
|
2
|
+
/**
|
|
3
|
+
* Refuse every authored plain value that looks like a credential, naming each by its path and reason, never by value.
|
|
4
|
+
*
|
|
5
|
+
* `importDocument` is the compiled import of `fabrika.config.ts`; `descriptor` the parsed `zerops.yaml`, every setup.
|
|
6
|
+
*/
|
|
7
|
+
export declare function assertNoAuthoredPlainCredential(importDocument: JsonValue, descriptor: JsonValue, notSecret: readonly string[]): void;
|
package/types/src/types.d.ts
CHANGED
|
@@ -88,6 +88,12 @@ export interface ZeropsSourceTarget {
|
|
|
88
88
|
runtimePackages?: ZeropsRuntimePackage[];
|
|
89
89
|
services: (ctx: ZeropsResourceContext) => ZeropsServiceSpec[];
|
|
90
90
|
project?: ZeropsProjectSpec;
|
|
91
|
+
/**
|
|
92
|
+
* Variable and header names whose plain value is not a credential. `fabrika app build` refuses an `envVariables` or
|
|
93
|
+
* `routing.headers` value that looks like one (its name says `TOKEN`, `PASSWORD`, `SECRET`, a key, or its value reads
|
|
94
|
+
* like a token); a name listed here is stored as written. A real credential goes in `pipeline.secrets`.
|
|
95
|
+
*/
|
|
96
|
+
notSecret?: readonly string[];
|
|
91
97
|
}
|
|
92
98
|
export interface ZeropsAppConfig extends AppConfigBase {
|
|
93
99
|
target: ZeropsSourceTarget;
|