@fabrika/provider-cloudflare 0.4.7 → 0.5.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/package.json +10 -9
- package/src/control.ts +13 -1
- package/src/installation/init-options.ts +24 -26
- package/src/installation/init.ts +27 -18
- package/src/installation/installation.ts +14 -6
- package/src/installation/templates/README.md +22 -3
- package/src/installation/templates/platform.yml +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/provider-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,14 +42,15 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"zod": "^3.25.76",
|
|
45
|
-
"@fabrika/app": "0.
|
|
46
|
-
"@fabrika/auth": "0.
|
|
47
|
-
"@fabrika/auth-core": "0.
|
|
48
|
-
"@fabrika/check": "0.
|
|
49
|
-
"@fabrika/
|
|
50
|
-
"@fabrika/
|
|
51
|
-
"@fabrika/
|
|
52
|
-
"@fabrika/
|
|
45
|
+
"@fabrika/app": "0.5.0",
|
|
46
|
+
"@fabrika/auth": "0.5.0",
|
|
47
|
+
"@fabrika/auth-core": "0.5.0",
|
|
48
|
+
"@fabrika/check": "0.5.0",
|
|
49
|
+
"@fabrika/email": "0.5.0",
|
|
50
|
+
"@fabrika/iam-contract": "0.5.0",
|
|
51
|
+
"@fabrika/installation-init": "0.5.0",
|
|
52
|
+
"@fabrika/proxy-core": "0.5.0",
|
|
53
|
+
"@fabrika/provider-contract": "0.5.0",
|
|
53
54
|
"oblaka-iac": "^0.0.18"
|
|
54
55
|
}
|
|
55
56
|
}
|
package/src/control.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ReconcileSchemaError } from '@fabrika/auth'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type AppEnvironment,
|
|
4
|
+
appEnvironmentId,
|
|
5
|
+
type AppSchema,
|
|
6
|
+
isEmailTransportVariable,
|
|
7
|
+
isWorkloadKeyVariable,
|
|
8
|
+
parseAppEnvironmentId,
|
|
9
|
+
} from '@fabrika/auth-core'
|
|
3
10
|
import type {
|
|
4
11
|
ControlProvider,
|
|
5
12
|
JsonValue,
|
|
@@ -279,6 +286,11 @@ const buildJob = async (options: CloudflareControlOptions, input: ProviderDeploy
|
|
|
279
286
|
if (workloadKey !== undefined) {
|
|
280
287
|
throw new Error(`cloudflare: the contract declares a job or a webhook (${workloadKey}); they run on Zerops only`)
|
|
281
288
|
}
|
|
289
|
+
// A dry run hands no workload key, and a mail credential must not land in a plain Worker var either way.
|
|
290
|
+
const mailVariable = Object.keys(input.managedEnvironment).find(isEmailTransportVariable)
|
|
291
|
+
if (mailVariable !== undefined) {
|
|
292
|
+
throw new Error(`cloudflare: the contract declares a job that sends mail through the installation (${mailVariable}); jobs run on Zerops only`)
|
|
293
|
+
}
|
|
282
294
|
const source = await awaitWithSignal(input.signal, () => options.prepareClone(input.app.source, input.signal, input.sourceBinding))
|
|
283
295
|
const listInstallationApps = options.installationApps
|
|
284
296
|
const installationApps = listInstallationApps === undefined
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
// prompts — a missing required value is an error naming both the flag and the variable — so a
|
|
7
7
|
// pipeline or an agent drives init end to end. Its confirmations stay, answered by `--yes`.
|
|
8
8
|
|
|
9
|
+
import { builtinEmailProviders } from '@fabrika/email/providers'
|
|
9
10
|
import {
|
|
10
11
|
CHECKOUT_FLAG,
|
|
11
12
|
type CommandEnv,
|
|
13
|
+
EMAIL_FLAGS,
|
|
14
|
+
type InstallationEmail,
|
|
12
15
|
readEnv,
|
|
13
16
|
readFlag,
|
|
17
|
+
readInstallationEmail,
|
|
14
18
|
requiredSetting,
|
|
15
19
|
setting,
|
|
16
20
|
shellWord,
|
|
@@ -39,10 +43,6 @@ export interface OidcInput {
|
|
|
39
43
|
readonly humanEmailDomains: readonly string[]
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
export type EmailInput =
|
|
43
|
-
| { readonly provider: 'none' }
|
|
44
|
-
| { readonly provider: 'resend'; readonly from: string; /** Environment only. */ readonly apiKey: string }
|
|
45
|
-
|
|
46
46
|
/** Every input `runInit` takes from the operator. */
|
|
47
47
|
export interface InitInput {
|
|
48
48
|
/** Names the GitHub Environment, the installer env file, the default repository and checkout. */
|
|
@@ -58,7 +58,8 @@ export interface InitInput {
|
|
|
58
58
|
/** Absent when OIDC login is not enabled. */
|
|
59
59
|
readonly oidc?: OidcInput
|
|
60
60
|
readonly passwordEnabled: boolean
|
|
61
|
-
|
|
61
|
+
/** IAM's mail transport; the provider's variables come from the environment only. */
|
|
62
|
+
readonly email: InstallationEmail
|
|
62
63
|
/** First-admin emails for the escape hatch, admitted to both control and IAM. */
|
|
63
64
|
readonly bootstrapAdmins: readonly string[]
|
|
64
65
|
/** `--yes`: answer every confirmation yes. */
|
|
@@ -76,8 +77,7 @@ const FLAGS = [
|
|
|
76
77
|
'--oidc-issuer',
|
|
77
78
|
'--oidc-client-id',
|
|
78
79
|
'--human-email-domains',
|
|
79
|
-
|
|
80
|
-
'--email-from',
|
|
80
|
+
...EMAIL_FLAGS,
|
|
81
81
|
CHECKOUT_FLAG,
|
|
82
82
|
] as const
|
|
83
83
|
|
|
@@ -239,22 +239,6 @@ const readOidc = (argv: readonly string[], env: CommandEnv): OidcInput => {
|
|
|
239
239
|
return { issuer, clientId, clientSecret, humanEmailDomains }
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
const readEmail = (argv: readonly string[], env: CommandEnv): EmailInput => {
|
|
243
|
-
const provider = requiredSetting(setting(argv, env, '--email-provider', 'FABRIKA_EMAIL_PROVIDER'), '--email-provider', 'FABRIKA_EMAIL_PROVIDER')
|
|
244
|
-
if (provider === 'none') {
|
|
245
|
-
refuseFlags(argv, ['--email-from'], 'the email provider is none')
|
|
246
|
-
return { provider }
|
|
247
|
-
}
|
|
248
|
-
if (provider !== 'resend') {
|
|
249
|
-
throw new Error(`--email-provider / FABRIKA_EMAIL_PROVIDER must be none or resend, not \`${provider}\``)
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
provider,
|
|
253
|
-
from: requiredSetting(setting(argv, env, '--email-from', 'FABRIKA_EMAIL_FROM'), '--email-from', 'FABRIKA_EMAIL_FROM'),
|
|
254
|
-
apiKey: credential(env, 'FABRIKA_EMAIL_RESEND_API_KEY', 'the Resend API key the email transport sends with'),
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
242
|
const readRepo = (argv: readonly string[], account: string): string => {
|
|
259
243
|
const repo = readFlag(argv, '--repo')
|
|
260
244
|
if (repo === undefined) {
|
|
@@ -289,7 +273,7 @@ export const parseInitArgs = (argv: readonly string[], env: CommandEnv, cwd: str
|
|
|
289
273
|
iam: requiredHost(argv, env, '--iam-host', 'FABRIKA_IAM_HOSTNAME'),
|
|
290
274
|
},
|
|
291
275
|
passwordEnabled: methods.passwordEnabled,
|
|
292
|
-
email:
|
|
276
|
+
email: readInstallationEmail(argv, env, { registry: builtinEmailProviders, required: true }),
|
|
293
277
|
bootstrapAdmins: parseList(
|
|
294
278
|
setting(argv, env, '--admins', 'FABRIKA_CONTROL_BOOTSTRAP_ADMINS'),
|
|
295
279
|
'--admins',
|
|
@@ -301,6 +285,21 @@ export const parseInitArgs = (argv: readonly string[], env: CommandEnv, cwd: str
|
|
|
301
285
|
}
|
|
302
286
|
}
|
|
303
287
|
|
|
288
|
+
const EMAIL_FLAG_VARIABLES = [
|
|
289
|
+
{ flag: '--email-provider', variable: 'FABRIKA_EMAIL_PROVIDER' },
|
|
290
|
+
{ flag: '--email-from', variable: 'FABRIKA_EMAIL_FROM' },
|
|
291
|
+
{ flag: '--email-from-name', variable: 'FABRIKA_EMAIL_FROM_NAME' },
|
|
292
|
+
] as const
|
|
293
|
+
|
|
294
|
+
/** The mail flags that repeat `email`; the provider's own variables stay in the environment. */
|
|
295
|
+
const emailFlags = (email: InstallationEmail): string[] => {
|
|
296
|
+
if (email.kind === 'none') return ['--email-provider=none']
|
|
297
|
+
return EMAIL_FLAG_VARIABLES.flatMap(({ flag, variable }) => {
|
|
298
|
+
const value = email.variables.get(variable)
|
|
299
|
+
return value === undefined ? [] : [`${flag}=${value}`]
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
|
|
304
303
|
/** The command that repeats this run, with every value but the credentials, which stay in the environment. */
|
|
305
304
|
export const rerunCommand = (input: InitInput, accountId: string): string =>
|
|
306
305
|
[
|
|
@@ -318,8 +317,7 @@ export const rerunCommand = (input: InitInput, accountId: string): string =>
|
|
|
318
317
|
...(input.oidc.clientId === PLACEHOLDER_OIDC_CLIENT_ID ? [] : [`--oidc-client-id=${input.oidc.clientId}`]),
|
|
319
318
|
...(input.oidc.humanEmailDomains.length === 0 ? [] : [`--human-email-domains=${input.oidc.humanEmailDomains.join(',')}`]),
|
|
320
319
|
]),
|
|
321
|
-
|
|
322
|
-
...(input.email.provider === 'resend' ? [`--email-from=${input.email.from}`] : []),
|
|
320
|
+
...emailFlags(input.email),
|
|
323
321
|
...(input.bootstrapAdmins.length === 0 ? [] : [`--admins=${input.bootstrapAdmins.join(',')}`]),
|
|
324
322
|
`${CHECKOUT_FLAG}=${input.checkout}`,
|
|
325
323
|
].map(shellWord),
|
package/src/installation/init.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type EnvironmentConfig,
|
|
24
24
|
ghRepoExists,
|
|
25
25
|
info,
|
|
26
|
+
type InstallationEmail,
|
|
26
27
|
ok,
|
|
27
28
|
type ProtectionOutcome,
|
|
28
29
|
step,
|
|
@@ -55,8 +56,8 @@ export interface Collected {
|
|
|
55
56
|
oidcClientId: string
|
|
56
57
|
/** Email domains admitted as a human at IAM login (self-provisioning allowlist). */
|
|
57
58
|
humanEmailDomains: string[]
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
/** IAM's mail transport. */
|
|
60
|
+
email: InstallationEmail
|
|
60
61
|
bootstrapAdmins: string[]
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -108,7 +109,6 @@ export async function runInit(input: InitInput, collaborators: InitCollaborators
|
|
|
108
109
|
const operationsSyncKey = await ensureOperationsSyncKey()
|
|
109
110
|
const signingKeys = await ensureSigningKeys()
|
|
110
111
|
const oidcClientSecret = input.oidc === undefined ? undefined : await ensureOidcClientSecret(input.oidc.clientSecret)
|
|
111
|
-
const emailApiKey = input.email.provider === 'resend' ? await ensureResendApiKey(input.email.apiKey) : undefined
|
|
112
112
|
const runnerKey = await ensureRunnerKey()
|
|
113
113
|
|
|
114
114
|
const { prompts, effects } = collaborators
|
|
@@ -142,7 +142,6 @@ export async function runInit(input: InitInput, collaborators: InitCollaborators
|
|
|
142
142
|
runnerKey,
|
|
143
143
|
signingKeys,
|
|
144
144
|
...(oidcClientSecret === undefined ? {} : { oidcClientSecret }),
|
|
145
|
-
...(emailApiKey === undefined ? {} : { emailApiKey }),
|
|
146
145
|
}),
|
|
147
146
|
}
|
|
148
147
|
info(
|
|
@@ -199,7 +198,6 @@ export interface GeneratedInstallation {
|
|
|
199
198
|
readonly runnerKey: string
|
|
200
199
|
readonly signingKeys: string
|
|
201
200
|
readonly oidcClientSecret?: string
|
|
202
|
-
readonly emailApiKey?: string
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
/**
|
|
@@ -210,6 +208,7 @@ export function environmentPayload(
|
|
|
210
208
|
collected: Collected,
|
|
211
209
|
generated: GeneratedInstallation,
|
|
212
210
|
): { secrets: Record<string, string>; vars: Record<string, string> } {
|
|
211
|
+
const email = collected.email.kind === 'none' ? { secrets: {}, vars: { FABRIKA_EMAIL_PROVIDER: 'none' } } : splitEmail(collected.email)
|
|
213
212
|
return {
|
|
214
213
|
secrets: {
|
|
215
214
|
CLOUDFLARE_ACCOUNT_ID: collected.accountId,
|
|
@@ -222,7 +221,7 @@ export function environmentPayload(
|
|
|
222
221
|
// IAM Stage 1 native-auth secrets (pushed as IAM Worker secrets by the pipeline).
|
|
223
222
|
FABRIKA_IAM_SIGNING_KEYS: generated.signingKeys,
|
|
224
223
|
...(generated.oidcClientSecret === undefined ? {} : { FABRIKA_IAM_OIDC_CLIENT_SECRET: generated.oidcClientSecret }),
|
|
225
|
-
...
|
|
224
|
+
...email.secrets,
|
|
226
225
|
},
|
|
227
226
|
vars: {
|
|
228
227
|
FABRIKA_CONTROL_DOMAIN: collected.controlPlaneDomain,
|
|
@@ -233,7 +232,7 @@ export function environmentPayload(
|
|
|
233
232
|
FABRIKA_IAM_HOSTNAME: collected.iamHostname,
|
|
234
233
|
FABRIKA_IAM_OIDC_ENABLED: String(collected.oidcEnabled),
|
|
235
234
|
FABRIKA_IAM_PASSWORD_ENABLED: String(collected.passwordEnabled),
|
|
236
|
-
|
|
235
|
+
...email.vars,
|
|
237
236
|
...(collected.oidcEnabled
|
|
238
237
|
? {
|
|
239
238
|
FABRIKA_IAM_OIDC_ISSUER: collected.oidcIssuer,
|
|
@@ -241,13 +240,23 @@ export function environmentPayload(
|
|
|
241
240
|
FABRIKA_IAM_HUMAN_EMAIL_DOMAINS: JSON.stringify(collected.humanEmailDomains),
|
|
242
241
|
}
|
|
243
242
|
: {}),
|
|
244
|
-
...(collected.emailProvider === 'resend' ? { FABRIKA_EMAIL_FROM: collected.emailFrom } : {}),
|
|
245
243
|
// The same first-admin emails admit the operator to IAM itself (its own bootstrap hatch).
|
|
246
244
|
FABRIKA_IAM_BOOTSTRAP_ADMINS: JSON.stringify(collected.bootstrapAdmins),
|
|
247
245
|
},
|
|
248
246
|
}
|
|
249
247
|
}
|
|
250
248
|
|
|
249
|
+
/** The provider's secret variables go to the Environment's secrets, the rest to its variables. */
|
|
250
|
+
function splitEmail(email: Extract<InstallationEmail, { kind: 'provider' }>): { secrets: Record<string, string>; vars: Record<string, string> } {
|
|
251
|
+
const secrets: Record<string, string> = {}
|
|
252
|
+
const vars: Record<string, string> = {}
|
|
253
|
+
for (const [name, value] of email.variables) {
|
|
254
|
+
if (email.secretNames.has(name)) secrets[name] = value
|
|
255
|
+
else vars[name] = value
|
|
256
|
+
}
|
|
257
|
+
return { secrets, vars }
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
/**
|
|
252
261
|
* Resolve the account the token deploys into and check the token against it.
|
|
253
262
|
*
|
|
@@ -312,8 +321,7 @@ async function collect(input: InitInput, cfAccount: CfAccount, effects: InitEffe
|
|
|
312
321
|
}
|
|
313
322
|
await persistEnv('FABRIKA_IAM_OIDC_CLIENT_ID', oidc.clientId)
|
|
314
323
|
}
|
|
315
|
-
await
|
|
316
|
-
if (input.email.provider === 'resend') await persistEnv('FABRIKA_EMAIL_FROM', input.email.from)
|
|
324
|
+
await ensureEmailSettings(input.email)
|
|
317
325
|
|
|
318
326
|
return {
|
|
319
327
|
account: input.account,
|
|
@@ -329,8 +337,7 @@ async function collect(input: InitInput, cfAccount: CfAccount, effects: InitEffe
|
|
|
329
337
|
oidcIssuer: oidc?.issuer ?? '',
|
|
330
338
|
oidcClientId: oidc?.clientId ?? '',
|
|
331
339
|
humanEmailDomains: oidc === undefined ? [] : [...oidc.humanEmailDomains],
|
|
332
|
-
|
|
333
|
-
emailFrom: input.email.provider === 'resend' ? input.email.from : '',
|
|
340
|
+
email: input.email,
|
|
334
341
|
bootstrapAdmins: [...input.bootstrapAdmins],
|
|
335
342
|
}
|
|
336
343
|
}
|
|
@@ -467,12 +474,14 @@ async function ensureOidcClientSecret(value: string): Promise<string> {
|
|
|
467
474
|
return value
|
|
468
475
|
}
|
|
469
476
|
|
|
470
|
-
/** Persist
|
|
471
|
-
async function
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
477
|
+
/** Persist every mail setting, credentials included, so a re-run reuses them; logs names, never a value. */
|
|
478
|
+
async function ensureEmailSettings(email: InstallationEmail): Promise<void> {
|
|
479
|
+
if (email.kind === 'none') {
|
|
480
|
+
await persistEnv('FABRIKA_EMAIL_PROVIDER', 'none')
|
|
481
|
+
return
|
|
482
|
+
}
|
|
483
|
+
for (const [name, value] of email.variables) await persistEnv(name, value)
|
|
484
|
+
ok(`Mail transport saved to the installer env file: ${[...email.variables.keys()].join(', ')}.`)
|
|
476
485
|
}
|
|
477
486
|
|
|
478
487
|
/** Trigger the platform workflow (each deploy builds the runner image into this account's registry). */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { builtinEmailProviders } from '@fabrika/email/providers'
|
|
1
2
|
import { IAM_APP_ID, IAM_APP_SCHEMA } from '@fabrika/iam-contract'
|
|
2
3
|
import type { InstallationCli, InstallationCommand } from '@fabrika/provider-contract/installation'
|
|
3
4
|
import { resolve } from 'node:path'
|
|
@@ -7,11 +8,16 @@ import type { PlatformIamTarget } from '../provider'
|
|
|
7
8
|
import { defaultReconcileSchema } from '../schema'
|
|
8
9
|
import { initCommand } from './init'
|
|
9
10
|
|
|
11
|
+
const EMAIL_PROVIDERS = Object.keys(builtinEmailProviders).join(', ')
|
|
12
|
+
const EMAIL_PROVIDER_VARIABLES = Object.values(builtinEmailProviders)
|
|
13
|
+
.flatMap((provider) => provider.variables.map((variable) => variable.name))
|
|
14
|
+
.join(', ')
|
|
15
|
+
|
|
10
16
|
const USAGE = `Cloudflare installation
|
|
11
17
|
|
|
12
18
|
Commands:
|
|
13
19
|
fabrika platform init --provider=cloudflare <account> --console-host=<host> --operations-host=<host> --iam-host=<host>
|
|
14
|
-
--auth-methods=<oidc|password|oidc,password> --email-provider=<none|
|
|
20
|
+
--auth-methods=<oidc|password|oidc,password> --email-provider=<none|provider> [options] [--yes]
|
|
15
21
|
fabrika platform plan --provider=cloudflare --runner-config=<path> --worker-config=<path> [--env=<env>]
|
|
16
22
|
fabrika platform deploy --provider=cloudflare --runner-config=<path> --worker-config=<path> [--env=<env>]
|
|
17
23
|
fabrika platform plan --provider=cloudflare --component-config=<path> [--env=<env>]
|
|
@@ -29,12 +35,14 @@ init prompts for nothing. Every value is a flag or the environment variable besi
|
|
|
29
35
|
--oidc-issuer=<url> FABRIKA_IAM_OIDC_ISSUER default https://accounts.google.com
|
|
30
36
|
--oidc-client-id=<id> FABRIKA_IAM_OIDC_CLIENT_ID absent: a placeholder, human SSO login stays inert
|
|
31
37
|
--human-email-domains=<d,...> FABRIKA_IAM_HUMAN_EMAIL_DOMAINS who may self-provision at login
|
|
32
|
-
--email-provider=<none
|
|
33
|
-
--email-from=<sender> FABRIKA_EMAIL_FROM required
|
|
38
|
+
--email-provider=<name> FABRIKA_EMAIL_PROVIDER none, or one of: ${EMAIL_PROVIDERS}
|
|
39
|
+
--email-from=<sender> FABRIKA_EMAIL_FROM required with a provider
|
|
40
|
+
--email-from-name=<name> FABRIKA_EMAIL_FROM_NAME the sender's display name, optional
|
|
34
41
|
Credentials come from the environment only: CLOUDFLARE_API_TOKEN, FABRIKA_IAM_OIDC_CLIENT_SECRET (a real
|
|
35
|
-
OIDC client)
|
|
36
|
-
The env file resumes
|
|
37
|
-
|
|
42
|
+
OIDC client). So does every variable of the mail provider, under its own name:
|
|
43
|
+
${EMAIL_PROVIDER_VARIABLES}. The account's installer env file resumes all of them.
|
|
44
|
+
The env file resumes the account id, the auth methods, the OIDC issuer and client id, every mail
|
|
45
|
+
setting, and every credential; the hosts, repository, checkout and admins are not saved. An empty flag
|
|
38
46
|
(such as --oidc-client-id=) counts as absent and falls back to that saved value; to return to the
|
|
39
47
|
placeholder client, remove FABRIKA_IAM_OIDC_CLIENT_ID and FABRIKA_IAM_OIDC_CLIENT_SECRET from the env file.
|
|
40
48
|
init confirms before it goes on with a token it could not verify ("Proceed anyway?"), creates or pushes the repository,
|
|
@@ -42,7 +42,7 @@ Run init with the Cloudflare API token in `CLOUDFLARE_API_TOKEN`:
|
|
|
42
42
|
```sh
|
|
43
43
|
fabrika platform init --provider=cloudflare {{ACCOUNT}} \
|
|
44
44
|
--console-host=<host> --operations-host=<host> --iam-host=<host> \
|
|
45
|
-
--auth-methods=<oidc|password|oidc,password> --email-provider=<none|resend>
|
|
45
|
+
--auth-methods=<oidc|password|oidc,password> --email-provider=<none|resend|smartemailing>
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
`fabrika platform init --provider=cloudflare --help` lists the optional flags. It creates this repo,
|
|
@@ -59,8 +59,25 @@ To close the escape hatch once IAM grants you admin, set the `{{ACCOUNT}}` Envir
|
|
|
59
59
|
IAM authentication methods are independent Environment switches: `FABRIKA_IAM_OIDC_ENABLED` and
|
|
60
60
|
`FABRIKA_IAM_PASSWORD_ENABLED`. At least one must be `true`. Password enrollment is managed through
|
|
61
61
|
IAM provisioning and its admin surface. Email delivery is optional; `FABRIKA_EMAIL_PROVIDER=none`
|
|
62
|
-
keeps password enrollment and reset admin-driven
|
|
63
|
-
|
|
62
|
+
keeps password enrollment and reset admin-driven. A provider (`resend` or `smartemailing`) also needs
|
|
63
|
+
the sender variable `FABRIKA_EMAIL_FROM` (optionally `FABRIKA_EMAIL_FROM_NAME`) and its own variables:
|
|
64
|
+
`FABRIKA_EMAIL_RESEND_API_KEY` as a secret for Resend; `FABRIKA_EMAIL_SMARTEMAILING_USERNAME` and
|
|
65
|
+
`FABRIKA_EMAIL_SMARTEMAILING_API_KEY` as secrets and optionally `FABRIKA_EMAIL_SMARTEMAILING_TAG` as a
|
|
66
|
+
variable for SmartEmailing. To change or rotate them, re-run `fabrika platform init` with the new values;
|
|
67
|
+
it rewrites this Environment and triggers the workflow, which redeploys IAM.
|
|
68
|
+
|
|
69
|
+
Switching provider leaves the old provider's values stored: init writes the new ones and deletes none. IAM
|
|
70
|
+
reads only the selected provider's variables, but delete the old credentials so nothing holds them, for
|
|
71
|
+
example after leaving SmartEmailing:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
gh secret delete FABRIKA_EMAIL_SMARTEMAILING_USERNAME --env {{ACCOUNT}}
|
|
75
|
+
gh secret delete FABRIKA_EMAIL_SMARTEMAILING_API_KEY --env {{ACCOUNT}}
|
|
76
|
+
gh variable delete FABRIKA_EMAIL_SMARTEMAILING_TAG --env {{ACCOUNT}}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Remove the same names from the installer env file (init prints its path when it starts), or a later run of
|
|
80
|
+
init resumes them.
|
|
64
81
|
|
|
65
82
|
## Routine redeploy or version bump
|
|
66
83
|
|
|
@@ -70,3 +87,5 @@ and the Resend API key secret.
|
|
|
70
87
|
Both paths rebuild the account-owned runner image from the exact checkout selected by `fabrika.ref`.
|
|
71
88
|
|
|
72
89
|
`fabrika.ref` is operator-owned. `fabrika platform init` creates it once and does not overwrite later version pins.
|
|
90
|
+
A bump does not rewrite this workflow. Re-run `fabrika platform init --provider=cloudflare {{ACCOUNT}}` with the same
|
|
91
|
+
flags to bring `.github/workflows/platform.yml` to the one the current CLI generates.
|
|
@@ -88,7 +88,7 @@ jobs:
|
|
|
88
88
|
|
|
89
89
|
- name: Install fabrika
|
|
90
90
|
working-directory: fabrika-platform
|
|
91
|
-
run: bun install
|
|
91
|
+
run: bun install --frozen-lockfile
|
|
92
92
|
|
|
93
93
|
# The Cloudflare provider spawns a BARE `wrangler` (Bun.spawn), so the workspace bins must be on PATH.
|
|
94
94
|
- name: Put fabrika workspace bins on PATH
|
|
@@ -140,11 +140,16 @@ jobs:
|
|
|
140
140
|
FABRIKA_IAM_OIDC_CLIENT_ID: ${{ vars.FABRIKA_IAM_OIDC_CLIENT_ID }}
|
|
141
141
|
FABRIKA_IAM_OIDC_SCOPES: ${{ vars.FABRIKA_IAM_OIDC_SCOPES }}
|
|
142
142
|
FABRIKA_IAM_OIDC_REQUIRE_VERIFIED_EMAIL: ${{ vars.FABRIKA_IAM_OIDC_REQUIRE_VERIFIED_EMAIL }}
|
|
143
|
+
# Every built-in mail provider's variables: IAM reads only the selected provider's, and an unset one is ''.
|
|
143
144
|
FABRIKA_EMAIL_PROVIDER: ${{ vars.FABRIKA_EMAIL_PROVIDER }}
|
|
144
145
|
FABRIKA_EMAIL_FROM: ${{ vars.FABRIKA_EMAIL_FROM }}
|
|
146
|
+
FABRIKA_EMAIL_FROM_NAME: ${{ vars.FABRIKA_EMAIL_FROM_NAME }}
|
|
147
|
+
FABRIKA_EMAIL_SMARTEMAILING_TAG: ${{ vars.FABRIKA_EMAIL_SMARTEMAILING_TAG }}
|
|
145
148
|
FABRIKA_IAM_SIGNING_KEYS: ${{ secrets.FABRIKA_IAM_SIGNING_KEYS }}
|
|
146
149
|
OIDC_CLIENT_SECRET: ${{ secrets.FABRIKA_IAM_OIDC_CLIENT_SECRET }}
|
|
147
150
|
FABRIKA_EMAIL_RESEND_API_KEY: ${{ secrets.FABRIKA_EMAIL_RESEND_API_KEY }}
|
|
151
|
+
FABRIKA_EMAIL_SMARTEMAILING_USERNAME: ${{ secrets.FABRIKA_EMAIL_SMARTEMAILING_USERNAME }}
|
|
152
|
+
FABRIKA_EMAIL_SMARTEMAILING_API_KEY: ${{ secrets.FABRIKA_EMAIL_SMARTEMAILING_API_KEY }}
|
|
148
153
|
FABRIKA_IAM_PROVISIONING_KEY: ${{ secrets.FABRIKA_IAM_PROVISIONING_KEY }}
|
|
149
154
|
# `platform deploy`, not `app deploy`: IAM's own Worker is a PLATFORM resource name, and only the
|
|
150
155
|
# platform verb may name one. The single-component form deploys just this config.
|