@reventlessdev/reventless-aws 3.0.0-alpha.345 → 3.0.0-alpha.346
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/CHANGELOG.md +28 -0
- package/package.json +12 -9
- package/run-provision-accounts.mjs +3 -0
- package/run-provision-admin.mjs +3 -0
- package/scripts/ProvisionAccounts.res +325 -0
- package/scripts/ProvisionAccounts.res.mjs +337 -0
- package/scripts/ProvisionAdmin.res +275 -0
- package/scripts/ProvisionAdmin.res.mjs +289 -0
- package/scripts/ProvisionCognito.res +149 -0
- package/scripts/ProvisionCognito.res.mjs +98 -0
- package/scripts/ProvisionIdentity.res +76 -11
- package/scripts/ProvisionIdentity.res.mjs +72 -7
- package/scripts/ProvisionProvider.res +104 -0
- package/scripts/ProvisionProvider.res.mjs +123 -0
- package/src/Platform.res +32 -2
- package/src/Platform.res.mjs +20 -10
- package/src/Platform_Stack.res +119 -9
- package/src/Platform_Stack.res.mjs +42 -4
- package/src/adapter/Auth/Auth_LoginIdentifier.res +66 -0
- package/src/adapter/Auth/Auth_LoginIdentifier.res.mjs +70 -0
- package/src/adapter/Auth/Auth_SignUpMode.res +78 -0
- package/src/adapter/Auth/Auth_SignUpMode.res.mjs +56 -0
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res +5 -0
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res.mjs +5 -1
- package/src/components/Api/AppSync_Adapter.res +56 -72
- package/src/components/Api/AppSync_Adapter.res.mjs +26 -60
- package/src/components/Api/AppSync_SdlDecorate.res +80 -1
- package/src/components/Api/AppSync_SdlDecorate.res.mjs +45 -0
- package/tests/AppSync_AdapterTest.res +83 -0
- package/tests/AppSync_AdapterTest.res.mjs +69 -0
- package/tests/Auth_LoginIdentifierTest.res +51 -0
- package/tests/Auth_LoginIdentifierTest.res.mjs +51 -0
- package/tests/Auth_SignUpModeTest.res +56 -0
- package/tests/Auth_SignUpModeTest.res.mjs +53 -0
- package/tests/ProvisionAccountsTest.res +142 -0
- package/tests/ProvisionAccountsTest.res.mjs +153 -0
- package/tests/ProvisionAdminTest.res +55 -0
- package/tests/ProvisionAdminTest.res.mjs +66 -0
- package/tests/ProvisionIdentityTest.res +89 -3
- package/tests/ProvisionIdentityTest.res.mjs +66 -1
- package/tests/Util_OwnerScopeEnvTest.res +25 -0
- package/tests/Util_OwnerScopeEnvTest.res.mjs +13 -0
package/src/Platform_Stack.res
CHANGED
|
@@ -12,15 +12,24 @@ type cognitoUserPool = {
|
|
|
12
12
|
is declared with the trigger's ARN), while the mutation that writes it is
|
|
13
13
|
provisioned after the API — see [Auth_ActiveRoleStore.res]. */
|
|
14
14
|
activeRoleTable: Auth_ActiveRoleStore.storeTable,
|
|
15
|
+
/** The sign-in attribute this stack created the pool with. `None` in BYO mode:
|
|
16
|
+
the pool's own choice was made elsewhere and no lookup here reads it back,
|
|
17
|
+
so reporting one would be a guess. */
|
|
18
|
+
loginIdentifier: option<Auth_LoginIdentifier.t>,
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* Resolve the Cognito UserPool used by AppSync auth. Two modes:
|
|
19
23
|
*
|
|
20
24
|
* - **Auto**: no `platform:identityProviderId` config — create a fresh UserPool
|
|
21
|
-
* with SPA-friendly defaults (email
|
|
22
|
-
*
|
|
23
|
-
*
|
|
25
|
+
* with SPA-friendly defaults (email sign-in unless `platform:loginIdentifier`
|
|
26
|
+
* says otherwise, 12-char password policy, no MFA, and admin-only user
|
|
27
|
+
* creation unless `platform:signUpMode` says otherwise), plus the
|
|
28
|
+
* administrator group named by [Reventless.AdminGroup] and an elevated-groups
|
|
29
|
+
* default naming it. What it does **not** create is the first administrator:
|
|
30
|
+
* accounts are not stack resources, and a pool full of them is not something a
|
|
31
|
+
* `pulumi destroy` should be able to empty. `provision-admin` makes that one,
|
|
32
|
+
* and no step of this needs the AWS console.
|
|
24
33
|
*
|
|
25
34
|
* - **BYO**: provider ID provided — skip pool creation, look up the existing
|
|
26
35
|
* pool via `aws.cognito.getUserPool` for its ARN. Lookup precedence
|
|
@@ -38,10 +47,21 @@ type cognitoUserPool = {
|
|
|
38
47
|
* Pulumi can destroy without touching the parent pool).
|
|
39
48
|
*
|
|
40
49
|
* Always exports `identityProviderId`, `identityProviderClientId`,
|
|
41
|
-
* `identityProviderArn`, `identityProviderRegion`, `identityProviderManaged
|
|
42
|
-
* `
|
|
43
|
-
*
|
|
44
|
-
*
|
|
50
|
+
* `identityProviderArn`, `identityProviderRegion`, `identityProviderManaged`,
|
|
51
|
+
* `identityProviderLoginIdentifier`, `identityProviderAdminGroup` and
|
|
52
|
+
* `activeRoleStore` as stack outputs so
|
|
53
|
+
* downstream stacks (and Stage D AppSync wiring) can read them via
|
|
54
|
+
* `StackReference` — plus, for one release, the deprecated `cognito*` spellings
|
|
55
|
+
* of the first five.
|
|
56
|
+
*
|
|
57
|
+
* 🚨 In auto mode `platform:loginIdentifier` picks the sign-in attribute, and it
|
|
58
|
+
* is the one setting no later deploy can correct: changing it replaces the pool
|
|
59
|
+
* and empties it. Absent means `email`. See [Auth_LoginIdentifier].
|
|
60
|
+
*
|
|
61
|
+
* `platform:signUpMode` decides whether a stranger may register themselves.
|
|
62
|
+
* Absent means `adminOnly`. It is the opposite kind of setting — an ordinary
|
|
63
|
+
* in-place update, free and reversible on a pool full of accounts — but on a
|
|
64
|
+
* pool shared between stacks the flip is pool-wide. See [Auth_SignUpMode].
|
|
45
65
|
*
|
|
46
66
|
* Also provisions the role-state table and the pre-token-generation trigger that
|
|
47
67
|
* narrows `cognito:groups` to a caller's chosen role. They belong here rather
|
|
@@ -86,6 +106,42 @@ let _identityProviderId = (~cfg: Pulumi.Config.t): option<string> => {
|
|
|
86
106
|
}
|
|
87
107
|
}
|
|
88
108
|
|
|
109
|
+
/** The sign-in attribute for a pool this stack creates, from
|
|
110
|
+
`platform:loginIdentifier` (or `REVENTLESS_LOGIN_IDENTIFIER` / the sidecar).
|
|
111
|
+
|
|
112
|
+
Absent means `email`, which is what every pool so far was created with. An
|
|
113
|
+
unrecognised spelling fails the deploy — see [Auth_LoginIdentifier] for why
|
|
114
|
+
defaulting past a typo here is unrecoverable. */
|
|
115
|
+
let _loginIdentifier = (~cfg: Pulumi.Config.t): Auth_LoginIdentifier.t => {
|
|
116
|
+
let raw = switch Util_LocalConfig.get("loginIdentifier") {
|
|
117
|
+
| Some(_) as v => v
|
|
118
|
+
| None => cfg->Pulumi.Config.get("loginIdentifier")
|
|
119
|
+
}
|
|
120
|
+
switch Auth_LoginIdentifier.parse(raw) {
|
|
121
|
+
| Ok(identifier) => identifier
|
|
122
|
+
| Error(message) => JsError.throwWithMessage(message)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Whether a stranger may create their own account in a pool this stack creates,
|
|
127
|
+
from `platform:signUpMode` (or `REVENTLESS_SIGN_UP_MODE` / the sidecar).
|
|
128
|
+
|
|
129
|
+
Absent means `adminOnly`, which is what every pool so far was created with, so
|
|
130
|
+
an existing stack redeploys unchanged. Unlike the sign-in attribute this is an
|
|
131
|
+
ordinary in-place update on a live pool — but an unrecognised spelling still
|
|
132
|
+
fails the deploy, because defaulting past it would refuse every registration
|
|
133
|
+
while the config read as if it allowed them. See [Auth_SignUpMode]. */
|
|
134
|
+
let _signUpMode = (~cfg: Pulumi.Config.t): Auth_SignUpMode.t => {
|
|
135
|
+
let raw = switch Util_LocalConfig.get("signUpMode") {
|
|
136
|
+
| Some(_) as v => v
|
|
137
|
+
| None => cfg->Pulumi.Config.get("signUpMode")
|
|
138
|
+
}
|
|
139
|
+
switch Auth_SignUpMode.parse(raw) {
|
|
140
|
+
| Ok(mode) => mode
|
|
141
|
+
| Error(message) => JsError.throwWithMessage(message)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
89
145
|
let _resolveUncached = (): cognitoUserPool => {
|
|
90
146
|
let cfg = Pulumi.Config.make(Some("platform"))
|
|
91
147
|
let existingPoolId = _identityProviderId(~cfg)
|
|
@@ -183,11 +239,19 @@ let _resolveUncached = (): cognitoUserPool => {
|
|
|
183
239
|
poolArn: lookup->Pulumi.Output.apply(r => r.arn),
|
|
184
240
|
managed: false,
|
|
185
241
|
activeRoleTable,
|
|
242
|
+
loginIdentifier: None,
|
|
186
243
|
}
|
|
187
244
|
|
|
188
245
|
| None =>
|
|
246
|
+
let loginIdentifier = _loginIdentifier(~cfg)
|
|
247
|
+
let signUpMode = _signUpMode(~cfg)
|
|
248
|
+
// In place, unlike the sign-in attribute below: `AdminCreateUserConfig` is a
|
|
249
|
+
// member of `UpdateUserPoolRequest`, so flipping this on a pool full of
|
|
250
|
+
// accounts is an ordinary update rather than a replacement.
|
|
189
251
|
let adminConfig: PulumiAws.Cognito.UserPool.adminCreateUserConfig = {
|
|
190
|
-
allowAdminCreateUserOnly: Pulumi.Input.make(
|
|
252
|
+
allowAdminCreateUserOnly: Pulumi.Input.make(
|
|
253
|
+
signUpMode->Auth_SignUpMode.allowAdminCreateUserOnly,
|
|
254
|
+
),
|
|
191
255
|
}
|
|
192
256
|
let pwdPolicy: PulumiAws.Cognito.UserPool.passwordPolicy = {
|
|
193
257
|
minimumLength: Pulumi.Input.make(12),
|
|
@@ -204,7 +268,13 @@ let _resolveUncached = (): cognitoUserPool => {
|
|
|
204
268
|
~name="HostUiPool",
|
|
205
269
|
~args={
|
|
206
270
|
adminCreateUserConfig: Pulumi.Input.make(adminConfig),
|
|
207
|
-
|
|
271
|
+
// 🚨 Changing this on a live stack replaces the pool and empties it —
|
|
272
|
+
// Cognito has no update for the sign-in attribute. Chosen once, here.
|
|
273
|
+
usernameAttributes: Pulumi.Input.make(
|
|
274
|
+
loginIdentifier
|
|
275
|
+
->Auth_LoginIdentifier.usernameAttributes
|
|
276
|
+
->Array.map(Pulumi.Input.make),
|
|
277
|
+
),
|
|
208
278
|
passwordPolicy: Pulumi.Input.make(pwdPolicy),
|
|
209
279
|
mfaConfiguration: Pulumi.Input.make("OFF"),
|
|
210
280
|
lambdaConfig: Pulumi.Input.make({
|
|
@@ -219,6 +289,23 @@ let _resolveUncached = (): cognitoUserPool => {
|
|
|
219
289
|
},
|
|
220
290
|
)
|
|
221
291
|
|
|
292
|
+
// The administrator group, declared beside the pool that holds it.
|
|
293
|
+
//
|
|
294
|
+
// Auto mode only, and the restriction is the point: a group is a pool-level
|
|
295
|
+
// fact, and on a pool this stack does not own those are not this stack's to
|
|
296
|
+
// declare. Two stacks pointed at one shared provider would each declare this
|
|
297
|
+
// group, and the second would fail on a name that already exists — the same
|
|
298
|
+
// split, for the same reason, as [Auth_SignUpMode] and the active-role store.
|
|
299
|
+
// The BYO half is `provision-admin`, which creates the group beside the first
|
|
300
|
+
// administrator who needs it.
|
|
301
|
+
//
|
|
302
|
+
// An ordinary child resource: the pool is ours, so this needs no out-of-band
|
|
303
|
+
// call and Pulumi's state stays the authority for whether it exists.
|
|
304
|
+
let _adminGroup = Util_CognitoGroupUser.addUserGroup(
|
|
305
|
+
~name=Reventless.AdminGroup.name,
|
|
306
|
+
~userPoolId=pool.id,
|
|
307
|
+
)
|
|
308
|
+
|
|
222
309
|
let tokenUnits2: PulumiAws.Cognito.UserPoolClient.tokenValidityUnits = {
|
|
223
310
|
accessToken: Pulumi.Input.make("minutes"),
|
|
224
311
|
idToken: Pulumi.Input.make("minutes"),
|
|
@@ -247,6 +334,7 @@ let _resolveUncached = (): cognitoUserPool => {
|
|
|
247
334
|
poolArn: pool.arn,
|
|
248
335
|
managed: true,
|
|
249
336
|
activeRoleTable,
|
|
337
|
+
loginIdentifier: Some(loginIdentifier),
|
|
250
338
|
}
|
|
251
339
|
}
|
|
252
340
|
|
|
@@ -279,11 +367,23 @@ let _resolveUncached = (): cognitoUserPool => {
|
|
|
279
367
|
let managedStr = Pulumi.Output.make(result.managed ? "true" : "false")
|
|
280
368
|
let regionOutput = Pulumi.Output.make(regionStr)
|
|
281
369
|
|
|
370
|
+
// The sign-in attribute is unchangeable after creation, so the value a pool was
|
|
371
|
+
// born with has to be readable somewhere other than the source that has since
|
|
372
|
+
// moved on. `unknown` for a BYO pool: this stack did not choose it and does not
|
|
373
|
+
// read it back.
|
|
374
|
+
let loginIdentifierStr = Pulumi.Output.make(
|
|
375
|
+
switch result.loginIdentifier {
|
|
376
|
+
| Some(identifier) => Auth_LoginIdentifier.toString(identifier)
|
|
377
|
+
| None => "unknown"
|
|
378
|
+
},
|
|
379
|
+
)
|
|
380
|
+
|
|
282
381
|
Pulumi.Pulumi.export("identityProviderId", result.poolId)
|
|
283
382
|
Pulumi.Pulumi.export("identityProviderClientId", result.clientId)
|
|
284
383
|
Pulumi.Pulumi.export("identityProviderArn", result.poolArn)
|
|
285
384
|
Pulumi.Pulumi.export("identityProviderRegion", regionOutput)
|
|
286
385
|
Pulumi.Pulumi.export("identityProviderManaged", managedStr)
|
|
386
|
+
Pulumi.Pulumi.export("identityProviderLoginIdentifier", loginIdentifierStr)
|
|
287
387
|
|
|
288
388
|
// Deprecated spellings — see above.
|
|
289
389
|
Pulumi.Pulumi.export("cognitoUserPoolId", result.poolId)
|
|
@@ -292,6 +392,16 @@ let _resolveUncached = (): cognitoUserPool => {
|
|
|
292
392
|
Pulumi.Pulumi.export("cognitoRegion", regionOutput)
|
|
293
393
|
Pulumi.Pulumi.export("cognitoUserPoolManaged", managedStr)
|
|
294
394
|
|
|
395
|
+
// The group that administers this deployment, readable without reading source.
|
|
396
|
+
// `provision-admin` puts its first user in it, and a deployment overriding who
|
|
397
|
+
// is elevated needs to know which name it is overriding.
|
|
398
|
+
//
|
|
399
|
+
// Exported in both pool modes although only auto mode *declares* the group: the
|
|
400
|
+
// name is what a caller needs either way, and an output that appeared in one
|
|
401
|
+
// mode and not the other would read as "there is no administrator group here"
|
|
402
|
+
// rather than "this stack did not create it".
|
|
403
|
+
Pulumi.Pulumi.export("identityProviderAdminGroup", Pulumi.Output.make(Reventless.AdminGroup.name))
|
|
404
|
+
|
|
295
405
|
// Exported so an operator can read back the store this provider resolved to —
|
|
296
406
|
// the name is derived, not configured, so this is a convenience for checking
|
|
297
407
|
// rather than a value anything is meant to copy into a config.
|
|
@@ -4,10 +4,15 @@ import * as Aws from "@pulumi/aws";
|
|
|
4
4
|
import * as Pulumi$Pulumi from "@reventlessdev/rescript-pulumi-pulumi/src/Pulumi.res.mjs";
|
|
5
5
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
6
|
import * as Pulumi from "@pulumi/pulumi";
|
|
7
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
8
|
+
import * as AdminGroup$Reventless from "@reventlessdev/reventless-spec/src/types/AdminGroup.res.mjs";
|
|
7
9
|
import * as Logger$ReventlessCore from "@reventlessdev/reventless-core/src/util/Logger.res.mjs";
|
|
8
10
|
import * as AWS_Tags$ReventlessAws from "./adapter/AWS_Tags.res.mjs";
|
|
11
|
+
import * as Auth_SignUpMode$ReventlessAws from "./adapter/Auth/Auth_SignUpMode.res.mjs";
|
|
9
12
|
import * as Util_LocalConfig$ReventlessAws from "./util/Util_LocalConfig.res.mjs";
|
|
10
13
|
import * as Auth_ActiveRoleStore$ReventlessAws from "./adapter/Auth/Auth_ActiveRoleStore.res.mjs";
|
|
14
|
+
import * as Auth_LoginIdentifier$ReventlessAws from "./adapter/Auth/Auth_LoginIdentifier.res.mjs";
|
|
15
|
+
import * as Util_CognitoGroupUser$ReventlessAws from "./util/Util_CognitoGroupUser.res.mjs";
|
|
11
16
|
import * as Auth_ActiveRoleTrigger$ReventlessAws from "./adapter/Auth/Auth_ActiveRoleTrigger.res.mjs";
|
|
12
17
|
import * as Auth_ActiveRolePoolAttachment$ReventlessAws from "./adapter/Auth/Auth_ActiveRolePoolAttachment.res.mjs";
|
|
13
18
|
|
|
@@ -35,6 +40,28 @@ function _identityProviderId(cfg) {
|
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
function _loginIdentifier(cfg) {
|
|
44
|
+
let v = Util_LocalConfig$ReventlessAws.get("loginIdentifier");
|
|
45
|
+
let raw = v !== undefined ? v : cfg.get("loginIdentifier");
|
|
46
|
+
let identifier = Auth_LoginIdentifier$ReventlessAws.parse(raw);
|
|
47
|
+
if (identifier.TAG === "Ok") {
|
|
48
|
+
return identifier._0;
|
|
49
|
+
} else {
|
|
50
|
+
return Stdlib_JsError.throwWithMessage(identifier._0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _signUpMode(cfg) {
|
|
55
|
+
let v = Util_LocalConfig$ReventlessAws.get("signUpMode");
|
|
56
|
+
let raw = v !== undefined ? v : cfg.get("signUpMode");
|
|
57
|
+
let mode = Auth_SignUpMode$ReventlessAws.parse(raw);
|
|
58
|
+
if (mode.TAG === "Ok") {
|
|
59
|
+
return mode._0;
|
|
60
|
+
} else {
|
|
61
|
+
return Stdlib_JsError.throwWithMessage(mode._0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
38
65
|
function _resolveUncached() {
|
|
39
66
|
let cfg = new Pulumi.Config("platform");
|
|
40
67
|
let existingPoolId = _identityProviderId(cfg);
|
|
@@ -77,11 +104,14 @@ function _resolveUncached() {
|
|
|
77
104
|
clientId: client.id,
|
|
78
105
|
poolArn: lookup.apply(r => r.arn),
|
|
79
106
|
managed: false,
|
|
80
|
-
activeRoleTable: activeRoleTable
|
|
107
|
+
activeRoleTable: activeRoleTable,
|
|
108
|
+
loginIdentifier: undefined
|
|
81
109
|
};
|
|
82
110
|
} else {
|
|
111
|
+
let loginIdentifier = _loginIdentifier(cfg);
|
|
112
|
+
let signUpMode = _signUpMode(cfg);
|
|
83
113
|
let adminConfig = {
|
|
84
|
-
allowAdminCreateUserOnly:
|
|
114
|
+
allowAdminCreateUserOnly: Auth_SignUpMode$ReventlessAws.allowAdminCreateUserOnly(signUpMode)
|
|
85
115
|
};
|
|
86
116
|
let pwdPolicy_minimumLength = 12;
|
|
87
117
|
let pwdPolicy_requireLowercase = true;
|
|
@@ -98,11 +128,12 @@ function _resolveUncached() {
|
|
|
98
128
|
preTokenGeneration: activeRoleTrigger.functionArn
|
|
99
129
|
},
|
|
100
130
|
adminCreateUserConfig: adminConfig,
|
|
101
|
-
usernameAttributes:
|
|
131
|
+
usernameAttributes: Auth_LoginIdentifier$ReventlessAws.usernameAttributes(loginIdentifier).map(prim => prim),
|
|
102
132
|
passwordPolicy: pwdPolicy,
|
|
103
133
|
mfaConfiguration: "OFF",
|
|
104
134
|
tags: AWS_Tags$ReventlessAws.make("HostUiPool", "Platform", "Auth", "Platform", undefined, undefined, undefined, undefined)
|
|
105
135
|
});
|
|
136
|
+
Util_CognitoGroupUser$ReventlessAws.addUserGroup(AdminGroup$Reventless.name, pool.id);
|
|
106
137
|
let tokenUnits2_accessToken = "minutes";
|
|
107
138
|
let tokenUnits2_idToken = "minutes";
|
|
108
139
|
let tokenUnits2_refreshToken = "days";
|
|
@@ -129,23 +160,28 @@ function _resolveUncached() {
|
|
|
129
160
|
clientId: client$1.id,
|
|
130
161
|
poolArn: pool.arn,
|
|
131
162
|
managed: true,
|
|
132
|
-
activeRoleTable: activeRoleTable
|
|
163
|
+
activeRoleTable: activeRoleTable,
|
|
164
|
+
loginIdentifier: loginIdentifier
|
|
133
165
|
};
|
|
134
166
|
}
|
|
135
167
|
Auth_ActiveRoleTrigger$ReventlessAws.grantInvoke(activeRoleTrigger, result.poolArn, undefined, {});
|
|
136
168
|
let regionStr = Stdlib_Option.getOr(new Pulumi.Config("aws").get("region"), "unknown");
|
|
137
169
|
let managedStr = Pulumi.output(result.managed ? "true" : "false");
|
|
138
170
|
let regionOutput = Pulumi.output(regionStr);
|
|
171
|
+
let identifier = result.loginIdentifier;
|
|
172
|
+
let loginIdentifierStr = Pulumi.output(identifier !== undefined ? Auth_LoginIdentifier$ReventlessAws.toString(identifier) : "unknown");
|
|
139
173
|
Pulumi$Pulumi.$$export("identityProviderId", result.poolId);
|
|
140
174
|
Pulumi$Pulumi.$$export("identityProviderClientId", result.clientId);
|
|
141
175
|
Pulumi$Pulumi.$$export("identityProviderArn", result.poolArn);
|
|
142
176
|
Pulumi$Pulumi.$$export("identityProviderRegion", regionOutput);
|
|
143
177
|
Pulumi$Pulumi.$$export("identityProviderManaged", managedStr);
|
|
178
|
+
Pulumi$Pulumi.$$export("identityProviderLoginIdentifier", loginIdentifierStr);
|
|
144
179
|
Pulumi$Pulumi.$$export("cognitoUserPoolId", result.poolId);
|
|
145
180
|
Pulumi$Pulumi.$$export("cognitoUserPoolClientId", result.clientId);
|
|
146
181
|
Pulumi$Pulumi.$$export("cognitoUserPoolArn", result.poolArn);
|
|
147
182
|
Pulumi$Pulumi.$$export("cognitoRegion", regionOutput);
|
|
148
183
|
Pulumi$Pulumi.$$export("cognitoUserPoolManaged", managedStr);
|
|
184
|
+
Pulumi$Pulumi.$$export("identityProviderAdminGroup", Pulumi.output(AdminGroup$Reventless.name));
|
|
149
185
|
Pulumi$Pulumi.$$export("activeRoleStore", result.activeRoleTable.name);
|
|
150
186
|
return result;
|
|
151
187
|
}
|
|
@@ -168,6 +204,8 @@ export {
|
|
|
168
204
|
log,
|
|
169
205
|
_deprecatedPoolIdKey,
|
|
170
206
|
_identityProviderId,
|
|
207
|
+
_loginIdentifier,
|
|
208
|
+
_signUpMode,
|
|
171
209
|
_resolveUncached,
|
|
172
210
|
_cached,
|
|
173
211
|
resolveCognitoUserPool,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The attribute a person signs in with. One definition, two consumers: the auto
|
|
2
|
+
// pool the platform stack declares, and the provisioning script that makes a
|
|
3
|
+
// pool no stack owns. Free of Pulumi and of the AWS SDK so both can import it.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Which attribute identifies a person at sign-in.
|
|
7
|
+
|
|
8
|
+
🚨 **Fixed at pool creation, and no later deploy can change it.** `CreateUserPool`
|
|
9
|
+
accepts `UsernameAttributes`; `UpdateUserPool` has no such member, so nothing can
|
|
10
|
+
change it in place and every provider replaces the pool instead. A replaced pool
|
|
11
|
+
is an empty one — Cognito exports no password material, so every account
|
|
12
|
+
re-registers. A deployment that will ever want phone sign-in has to say so on its
|
|
13
|
+
first deploy.
|
|
14
|
+
*/
|
|
15
|
+
type t =
|
|
16
|
+
| Email
|
|
17
|
+
| Phone
|
|
18
|
+
| EmailOrPhone
|
|
19
|
+
|
|
20
|
+
/** What every pool has been created with so far, so an existing stack redeploys
|
|
21
|
+
unchanged. */
|
|
22
|
+
let default = Email
|
|
23
|
+
|
|
24
|
+
let all: array<t> = [Email, Phone, EmailOrPhone]
|
|
25
|
+
|
|
26
|
+
/** The config spelling, and the stack output. */
|
|
27
|
+
let toString = (identifier: t): string =>
|
|
28
|
+
switch identifier {
|
|
29
|
+
| Email => "email"
|
|
30
|
+
| Phone => "phone"
|
|
31
|
+
| EmailOrPhone => "emailOrPhone"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let fromString = (value: string): option<t> => all->Array.find(i => toString(i) == value)
|
|
35
|
+
|
|
36
|
+
/** Cognito's `usernameAttributes`. */
|
|
37
|
+
let usernameAttributes = (identifier: t): array<string> =>
|
|
38
|
+
switch identifier {
|
|
39
|
+
| Email => ["email"]
|
|
40
|
+
| Phone => ["phone_number"]
|
|
41
|
+
| EmailOrPhone => ["email", "phone_number"]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
The deploy-time choice, or why the deploy cannot proceed.
|
|
46
|
+
|
|
47
|
+
An unrecognised spelling refuses rather than falling back to the default: a typo
|
|
48
|
+
that defaulted would create a pool signing in on the wrong attribute, which is
|
|
49
|
+
the one property no later deploy can correct.
|
|
50
|
+
*/
|
|
51
|
+
let parse = (value: option<string>): result<t, string> =>
|
|
52
|
+
switch value {
|
|
53
|
+
| None => Ok(default)
|
|
54
|
+
| Some(raw) =>
|
|
55
|
+
switch fromString(raw) {
|
|
56
|
+
| Some(identifier) => Ok(identifier)
|
|
57
|
+
| None =>
|
|
58
|
+
Error(
|
|
59
|
+
`loginIdentifier "${raw}" is not one of ${all
|
|
60
|
+
->Array.map(toString)
|
|
61
|
+
->Array.join(
|
|
62
|
+
", ",
|
|
63
|
+
)}. It fixes the sign-in attribute at pool creation and no later deploy can change it, so an unrecognised spelling refuses rather than defaulting.`,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
let all = [
|
|
5
|
+
"Email",
|
|
6
|
+
"Phone",
|
|
7
|
+
"EmailOrPhone"
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function toString(identifier) {
|
|
11
|
+
switch (identifier) {
|
|
12
|
+
case "Email" :
|
|
13
|
+
return "email";
|
|
14
|
+
case "Phone" :
|
|
15
|
+
return "phone";
|
|
16
|
+
case "EmailOrPhone" :
|
|
17
|
+
return "emailOrPhone";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function fromString(value) {
|
|
22
|
+
return all.find(i => toString(i) === value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function usernameAttributes(identifier) {
|
|
26
|
+
switch (identifier) {
|
|
27
|
+
case "Email" :
|
|
28
|
+
return ["email"];
|
|
29
|
+
case "Phone" :
|
|
30
|
+
return ["phone_number"];
|
|
31
|
+
case "EmailOrPhone" :
|
|
32
|
+
return [
|
|
33
|
+
"email",
|
|
34
|
+
"phone_number"
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function parse(value) {
|
|
40
|
+
if (value === undefined) {
|
|
41
|
+
return {
|
|
42
|
+
TAG: "Ok",
|
|
43
|
+
_0: "Email"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let identifier = fromString(value);
|
|
47
|
+
if (identifier !== undefined) {
|
|
48
|
+
return {
|
|
49
|
+
TAG: "Ok",
|
|
50
|
+
_0: identifier
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
return {
|
|
54
|
+
TAG: "Error",
|
|
55
|
+
_0: `loginIdentifier "` + value + `" is not one of ` + all.map(toString).join(", ") + `. It fixes the sign-in attribute at pool creation and no later deploy can change it, so an unrecognised spelling refuses rather than defaulting.`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let $$default = "Email";
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
$$default as default,
|
|
64
|
+
all,
|
|
65
|
+
toString,
|
|
66
|
+
fromString,
|
|
67
|
+
usernameAttributes,
|
|
68
|
+
parse,
|
|
69
|
+
}
|
|
70
|
+
/* No side effect */
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Whether a stranger can create their own account. One definition, two consumers:
|
|
2
|
+
// the auto pool the platform stack declares, and the provisioning script that
|
|
3
|
+
// makes a pool no stack owns. Free of Pulumi and of the AWS SDK so both can
|
|
4
|
+
// import it — the same shape, and the same drift it prevents, as
|
|
5
|
+
// [Auth_LoginIdentifier].
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
Who may create a principal in this pool.
|
|
9
|
+
|
|
10
|
+
Unlike the sign-in attribute, this **is** updatable in place: `AdminCreateUserConfig`
|
|
11
|
+
is a member of `UpdateUserPoolRequest`, so a pool full of accounts can be flipped
|
|
12
|
+
either way at any time, for free and reversibly. It is a setting, not a
|
|
13
|
+
first-deploy-or-never decision.
|
|
14
|
+
|
|
15
|
+
🚨 **On a shared pool the flip is pool-wide, not stack-wide.** The setting belongs
|
|
16
|
+
to the pool and the pool has one of it, so every stack pointed at that pool gets
|
|
17
|
+
self-service the moment one deployment turns it on. A deployment that must never
|
|
18
|
+
self-register cannot rely on its own config to prevent it, and should not share a
|
|
19
|
+
pool with one that does.
|
|
20
|
+
*/
|
|
21
|
+
type t =
|
|
22
|
+
/** Only an administrator creates principals — what every pool so far was
|
|
23
|
+
created with, and what a deployment with no registration flow wants. */
|
|
24
|
+
| AdminOnly
|
|
25
|
+
/** A stranger can register themselves. */
|
|
26
|
+
| SelfService
|
|
27
|
+
|
|
28
|
+
/** What every pool has been created with so far, so an existing stack redeploys
|
|
29
|
+
unchanged. Closed is also the right default on its own terms: a deployment that
|
|
30
|
+
has not asked for self-registration should not acquire it by upgrading. */
|
|
31
|
+
let default = AdminOnly
|
|
32
|
+
|
|
33
|
+
let all: array<t> = [AdminOnly, SelfService]
|
|
34
|
+
|
|
35
|
+
/** The config spelling. */
|
|
36
|
+
let toString = (mode: t): string =>
|
|
37
|
+
switch mode {
|
|
38
|
+
| AdminOnly => "adminOnly"
|
|
39
|
+
| SelfService => "selfService"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let fromString = (value: string): option<t> => all->Array.find(m => toString(m) == value)
|
|
43
|
+
|
|
44
|
+
/** Cognito's `allowAdminCreateUserOnly`, which asks the negative of what this
|
|
45
|
+
type asks. Converting in one place is the point: a bool named for the negative
|
|
46
|
+
is easy to read backwards at a call site. */
|
|
47
|
+
let allowAdminCreateUserOnly = (mode: t): bool =>
|
|
48
|
+
switch mode {
|
|
49
|
+
| AdminOnly => true
|
|
50
|
+
| SelfService => false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
The deploy-time choice, or why the deploy cannot proceed.
|
|
55
|
+
|
|
56
|
+
An unrecognised spelling refuses rather than falling back to the default, and the
|
|
57
|
+
reason is *not* [Auth_LoginIdentifier]'s — this setting is correctable at any
|
|
58
|
+
time. It is that the mistake would be silent. The default is closed, so a typo
|
|
59
|
+
fails safe, but it fails safe *invisibly*: the deploy is green, the config says
|
|
60
|
+
what the operator meant, and the symptom is every registration being refused,
|
|
61
|
+
which surfaces far from the misspelling that caused it.
|
|
62
|
+
*/
|
|
63
|
+
let parse = (value: option<string>): result<t, string> =>
|
|
64
|
+
switch value {
|
|
65
|
+
| None => Ok(default)
|
|
66
|
+
| Some(raw) =>
|
|
67
|
+
switch fromString(raw) {
|
|
68
|
+
| Some(mode) => Ok(mode)
|
|
69
|
+
| None =>
|
|
70
|
+
Error(
|
|
71
|
+
`signUpMode "${raw}" is not one of ${all
|
|
72
|
+
->Array.map(toString)
|
|
73
|
+
->Array.join(
|
|
74
|
+
", ",
|
|
75
|
+
)}. It decides whether a stranger can create an account. An unrecognised spelling refuses rather than defaulting, because defaulting would deploy green and refuse every registration, with nothing pointing back at the spelling.`,
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
let all = [
|
|
5
|
+
"AdminOnly",
|
|
6
|
+
"SelfService"
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
function toString(mode) {
|
|
10
|
+
if (mode === "AdminOnly") {
|
|
11
|
+
return "adminOnly";
|
|
12
|
+
} else {
|
|
13
|
+
return "selfService";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fromString(value) {
|
|
18
|
+
return all.find(m => toString(m) === value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function allowAdminCreateUserOnly(mode) {
|
|
22
|
+
return mode === "AdminOnly";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function parse(value) {
|
|
26
|
+
if (value === undefined) {
|
|
27
|
+
return {
|
|
28
|
+
TAG: "Ok",
|
|
29
|
+
_0: "AdminOnly"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
let mode = fromString(value);
|
|
33
|
+
if (mode !== undefined) {
|
|
34
|
+
return {
|
|
35
|
+
TAG: "Ok",
|
|
36
|
+
_0: mode
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
return {
|
|
40
|
+
TAG: "Error",
|
|
41
|
+
_0: `signUpMode "` + value + `" is not one of ` + all.map(toString).join(", ") + `. It decides whether a stranger can create an account. An unrecognised spelling refuses rather than defaulting, because defaulting would deploy green and refuse every registration, with nothing pointing back at the spelling.`
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let $$default = "AdminOnly";
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
$$default as default,
|
|
50
|
+
all,
|
|
51
|
+
toString,
|
|
52
|
+
fromString,
|
|
53
|
+
allowAdminCreateUserOnly,
|
|
54
|
+
parse,
|
|
55
|
+
}
|
|
56
|
+
/* No side effect */
|
|
@@ -328,6 +328,11 @@ let capabilities = (): Reventless.Capabilities.t => {
|
|
|
328
328
|
~text,
|
|
329
329
|
),
|
|
330
330
|
messaging: messagingEmailProvider(),
|
|
331
|
+
// Refusing until the Cognito backend lands. The pool is provisioned, but the
|
|
332
|
+
// store mapping a domain user id to a provider handle is not, and creating a
|
|
333
|
+
// principal before that exists would write a handle with nowhere to live.
|
|
334
|
+
identityProvider: Reventless.Capabilities.none.identityProvider,
|
|
335
|
+
secrets: ReventlessCore.Secrets_Node_Backend.provider,
|
|
331
336
|
}
|
|
332
337
|
|
|
333
338
|
// ── Phase-1/phase-2 pipelines ───────────────────────────────────────────────
|
|
@@ -12,9 +12,11 @@ import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/compon
|
|
|
12
12
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
13
13
|
import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
|
|
14
14
|
import * as Message$ReventlessCore from "@reventlessdev/reventless-core/src/Message.res.mjs";
|
|
15
|
+
import * as Capabilities$Reventless from "@reventlessdev/reventless-spec/src/semantic/Capabilities.res.mjs";
|
|
15
16
|
import * as EffectLogger$ReventlessCore from "@reventlessdev/reventless-core/src/util/EffectLogger.res.mjs";
|
|
16
17
|
import * as DynamoDb_Error$ReventlessAws from "../../errors/DynamoDb_Error.res.mjs";
|
|
17
18
|
import * as Messaging_Ses_Backend$ReventlessAws from "../Messaging/Messaging_Ses_Backend.res.mjs";
|
|
19
|
+
import * as Secrets_Node_Backend$ReventlessCore from "@reventlessdev/reventless-core/src/adapter/Secrets/Secrets_Node_Backend.res.mjs";
|
|
18
20
|
import * as Util_DynamoDb_Runtime$ReventlessAws from "../../util/Util_DynamoDb_Runtime.res.mjs";
|
|
19
21
|
import * as Messaging_Log_Backend$ReventlessCore from "@reventlessdev/reventless-core/src/adapter/Messaging/Messaging_Log_Backend.res.mjs";
|
|
20
22
|
import * as AutomationSlice_Callback$ReventlessCore from "@reventlessdev/reventless-core/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs";
|
|
@@ -199,7 +201,9 @@ function messagingEmailProvider() {
|
|
|
199
201
|
function capabilities() {
|
|
200
202
|
return {
|
|
201
203
|
geocode: text => Geocoder_AwsLocation_Backend$ReventlessAws.search(Stdlib_Option.getOr(process.env["PLACE_INDEX_NAME"], ""), text, undefined),
|
|
202
|
-
messaging: messagingEmailProvider()
|
|
204
|
+
messaging: messagingEmailProvider(),
|
|
205
|
+
identityProvider: Capabilities$Reventless.none.identityProvider,
|
|
206
|
+
secrets: Secrets_Node_Backend$ReventlessCore.provider
|
|
203
207
|
};
|
|
204
208
|
}
|
|
205
209
|
|