@ampless/backend 1.0.0-alpha.47 → 1.0.0-alpha.49

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -434,11 +434,25 @@ function amplessSchemaModels(a, opts = {}) {
434
434
  // never flows back to the browser.
435
435
  //
436
436
  // Authorization design:
437
- // - admin / editor: NO direct AppSync access. All writes go
438
- // through the plugin-secret-handler Lambda mutation.
439
- // - IAM (Lambda): full read+write. Both the plugin-secret-handler
440
- // (writes ciphertext) and the trusted-processor (reads +
441
- // decrypts) use IAM-signed DDB SDK calls.
437
+ // - admin / editor: NO AppSync access. The model uses a
438
+ // placeholder group (`__ampless_internal__`) that no Cognito
439
+ // user belongs to. Amplify Gen 2 requires every model to have
440
+ // at least one auth rule, and this is the minimum-viable one
441
+ // that synthesizes cleanly while denying all AppSync access.
442
+ // - plugin-secret-handler Lambda: full DDB access via the
443
+ // `grantReadWriteData` IAM grant in `backend.ts`. It calls
444
+ // the DDB SDK directly (NOT through AppSync), so the model's
445
+ // @auth rule is irrelevant to its actual write path.
446
+ // - trusted-processor Lambda: read-only DDB access via the
447
+ // `grantReadData` IAM grant in `backend.ts`. Same pattern —
448
+ // bypasses AppSync entirely.
449
+ // - Lambda `allow.resource(...)` is unavailable at the model
450
+ // level in `@aws-amplify/data-schema` (the `resource` helper
451
+ // is destructured out of `allow` before model-level callbacks
452
+ // run; see line 141 in this file). Schema-level resource auth
453
+ // would grant the Lambda AppSync access to ALL models — too
454
+ // broad for our needs. The DDB-SDK direct path keeps the
455
+ // access scoped to the table the Lambda needs.
442
456
  //
443
457
  // Storage key convention:
444
458
  // siteId = 'default' (single-site architecture)
@@ -467,11 +481,10 @@ function amplessSchemaModels(a, opts = {}) {
467
481
  // trusted plugin co-located in the same Lambda.
468
482
  value: a.string().required()
469
483
  }).identifier(["siteId", "sk"]).authorization((allow) => [
470
- // IAM only no Cognito group has any AppSync access.
471
- // plugin-secret-handler Lambda writes (PutItem / DeleteItem).
472
- // trusted-processor Lambda reads (GetItem, read-only grant
473
- // in backend.ts via grantReadData).
474
- allow.authenticated("iam").to(["read", "create", "update", "delete"])
484
+ // Deny-all-via-AppSync sentinel. See the comment above this
485
+ // model for why this is a non-existent group name and how the
486
+ // real Lambda access path works (DDB SDK + IAM grants).
487
+ allow.groups(["__ampless_internal__"])
475
488
  ]),
476
489
  // Existence-only indicator for PluginSecret rows.
477
490
  //
@@ -496,10 +509,14 @@ function amplessSchemaModels(a, opts = {}) {
496
509
  // every write. Admin UI may show this as "last updated" hint.
497
510
  lastSetAt: a.datetime().required()
498
511
  }).identifier(["siteId", "sk"]).authorization((allow) => [
499
- // Admin/editor can read and write (write needed for clear).
500
- allow.groups(["ampless-admin", "ampless-editor"]),
501
- // plugin-secret-handler Lambda also writes via IAM.
502
- allow.authenticated("iam").to(["read", "create", "update", "delete"])
512
+ // Admin/editor have AppSync read for `hasPluginSecret` and
513
+ // direct write+delete as a recovery path. The Lambda is the
514
+ // normal write path (it calls the DDB SDK directly with IAM,
515
+ // not through AppSync — same pattern as PluginSecret above),
516
+ // but allowing admin write here lets a clear-retry after a
517
+ // partial dual-write failure heal the inconsistency from the
518
+ // admin side without redeploying.
519
+ allow.groups(["ampless-admin", "ampless-editor"])
503
520
  ]),
504
521
  // Custom return type for public post reads. Decoupling from `Post` lets
505
522
  // AppSync skip the model-level (admin-only) auth check on fields.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/backend",
3
- "version": "1.0.0-alpha.47",
3
+ "version": "1.0.0-alpha.49",
4
4
  "description": "Amplify Gen 2 backend factories for ampless: auth, data, storage, event processors, API key renewer",
5
5
  "license": "MIT",
6
6
  "type": "module",