@ampless/backend 1.0.0-alpha.47 → 1.0.0-alpha.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -436,9 +436,18 @@ function amplessSchemaModels(a, opts = {}) {
|
|
|
436
436
|
// Authorization design:
|
|
437
437
|
// - admin / editor: NO direct AppSync access. All writes go
|
|
438
438
|
// through the plugin-secret-handler Lambda mutation.
|
|
439
|
-
// -
|
|
440
|
-
//
|
|
441
|
-
//
|
|
439
|
+
// - `allow.resource(pluginSecretHandlerFunction)`: grants the
|
|
440
|
+
// plugin-secret-handler Lambda AppSync access to this model
|
|
441
|
+
// (used internally by the mutation's resolver path).
|
|
442
|
+
// - trusted-processor Lambda reads directly via DDB SDK with the
|
|
443
|
+
// `grantReadData` IAM grant in `backend.ts`, bypassing AppSync
|
|
444
|
+
// entirely — no `@auth` rule needed for that path.
|
|
445
|
+
// - Fallback (when `pluginSecretHandlerFunction` is not provided
|
|
446
|
+
// by the caller): admin-only Cognito group. Encryption renders
|
|
447
|
+
// ciphertext meaningless without the env-var key, but the
|
|
448
|
+
// feature won't actually work without the handler — this
|
|
449
|
+
// fallback only exists to keep CDK synth from failing in a
|
|
450
|
+
// partially-wired deployment.
|
|
442
451
|
//
|
|
443
452
|
// Storage key convention:
|
|
444
453
|
// siteId = 'default' (single-site architecture)
|
|
@@ -466,13 +475,17 @@ function amplessSchemaModels(a, opts = {}) {
|
|
|
466
475
|
// / deploy artifact access, NOT defeated for a malicious
|
|
467
476
|
// trusted plugin co-located in the same Lambda.
|
|
468
477
|
value: a.string().required()
|
|
469
|
-
}).identifier(["siteId", "sk"]).authorization((allow) =>
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
478
|
+
}).identifier(["siteId", "sk"]).authorization((allow) => {
|
|
479
|
+
const rules = [];
|
|
480
|
+
if (opts.pluginSecretHandlerFunction) {
|
|
481
|
+
rules.push(
|
|
482
|
+
allow.resource(opts.pluginSecretHandlerFunction).to(["read", "create", "update", "delete"])
|
|
483
|
+
);
|
|
484
|
+
} else {
|
|
485
|
+
rules.push(allow.groups(["ampless-admin"]));
|
|
486
|
+
}
|
|
487
|
+
return rules;
|
|
488
|
+
}),
|
|
476
489
|
// Existence-only indicator for PluginSecret rows.
|
|
477
490
|
//
|
|
478
491
|
// Admin/editor Cognito users cannot read from PluginSecret at all
|
|
@@ -495,12 +508,22 @@ function amplessSchemaModels(a, opts = {}) {
|
|
|
495
508
|
// ISO 8601 datetime string — set by plugin-secret-handler on
|
|
496
509
|
// every write. Admin UI may show this as "last updated" hint.
|
|
497
510
|
lastSetAt: a.datetime().required()
|
|
498
|
-
}).identifier(["siteId", "sk"]).authorization((allow) =>
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
511
|
+
}).identifier(["siteId", "sk"]).authorization((allow) => {
|
|
512
|
+
const rules = [
|
|
513
|
+
// Admin/editor have AppSync read for `hasPluginSecret` and
|
|
514
|
+
// direct write+delete as a fallback path (the Lambda is the
|
|
515
|
+
// normal write path, but allowing admin write here keeps the
|
|
516
|
+
// indicator and ciphertext aligned if a clear operation is
|
|
517
|
+
// retried after a partial failure).
|
|
518
|
+
allow.groups(["ampless-admin", "ampless-editor"])
|
|
519
|
+
];
|
|
520
|
+
if (opts.pluginSecretHandlerFunction) {
|
|
521
|
+
rules.push(
|
|
522
|
+
allow.resource(opts.pluginSecretHandlerFunction).to(["read", "create", "update", "delete"])
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
return rules;
|
|
526
|
+
}),
|
|
504
527
|
// Custom return type for public post reads. Decoupling from `Post` lets
|
|
505
528
|
// AppSync skip the model-level (admin-only) auth check on fields.
|
|
506
529
|
//
|
package/package.json
CHANGED