fix(transport): secret-bearing bundle export needs Administrator; scrub data-connection move reply (MGT-3, MGT-4, WP1 task 1.5)
MGT-3: a Designer could read SMTP/SMS credentials, external-system auth, DB connection strings and data-connection configuration through bundle export, values the management API returns to no one. Both export surfaces now resolve the selection (dependencies included) via the new IBundleExporter.CountSecretsAsync / ExportSecretPolicy and require Administrator when it carries any secret; a secret-free export stays a Designer operation. The ExportBundle gate becomes any-of [Designer, Administrator] - a deliberate change to the frozen authz matrix. A new ManagementAuthorizationException maps to ManagementUnauthorized. MGT-4: data-connection move replies with DataConnectionPublicShape like its siblings (the audit after-state switched with task 1.4). Tests: matrix entry, Designer+secrets refused (nothing exported), Admin and secret-free Designer succeed, UI wizard refuses a Designer, policy counts every SecretsBlock field, move reply carries no secret.
This commit is contained in:
@@ -133,7 +133,7 @@ Central cluster only. Sites have no user interface.
|
||||
- The API key detail page includes a **"Recent calls"** link that opens the Audit Log page pre-filtered to `Actor = <key name>` and `Channel = ApiInbound` — surfacing the key's recent inbound-call audit history.
|
||||
|
||||
### Bundle Export / Import (Design Role for export, Admin Role for import)
|
||||
- `Export Bundle` (`/design/transport/export`) — multi-step wizard for exporting a `.scadabundle` artifact containing templates, shared scripts, external systems, and central-only configuration. Visible to users with `RequireDesign`.
|
||||
- `Export Bundle` (`/design/transport/export`) — multi-step wizard for exporting a `.scadabundle` artifact containing templates, shared scripts, external systems, and central-only configuration. Visible to users with `RequireDesign`; exporting a selection whose resolved closure carries stored secrets additionally requires the Administrator role (code review 2026-12-02 MGT-3).
|
||||
- `Import Bundle` (`/design/transport/import`) — multi-step wizard for uploading and applying a `.scadabundle` into the current environment, with per-artifact diff review and conflict resolution. Visible to users with `RequireAdmin`.
|
||||
|
||||
### Area Management (Designer or Deployer Role)
|
||||
|
||||
@@ -145,7 +145,7 @@ The whole folder surface is reachable from the CLI as `template folder list|crea
|
||||
- **CreateDataConnection** / **UpdateDataConnection** / **DeleteDataConnection**: Manage data connection definitions.
|
||||
- **AssignDataConnectionToSite** / **UnassignDataConnectionFromSite**: Manage site assignments.
|
||||
|
||||
> **Secret elision (arch-review C3).** The `PrimaryConfiguration`/`BackupConfiguration` JSON blobs can embed OPC UA user and certificate passwords, yet List/Get are readable by any authenticated user. All command responses **and** audit `afterState` are projected through a secret-elided shape (`DataConnectionPublicShape`): secret-bearing values inside the config JSON are replaced with a redaction sentinel and a `hasSecrets` flag is surfaced (mirrors the SMTP/SMS `HasCredentials` pattern). **Update** merges the sentinel via `ConfigSecretScrubber.MergeSentinels` — a client that round-trips a scrubbed config keeps the stored secret rather than wiping it.
|
||||
> **Secret elision (arch-review C3).** The `PrimaryConfiguration`/`BackupConfiguration` JSON blobs can embed OPC UA user and certificate passwords, yet List/Get are readable by any authenticated user. All command responses **and** audit `afterState` — including `MoveDataConnection`, which returned and audited the raw entity until code review 2026-12-02 MGT-4 — are projected through a secret-elided shape (`DataConnectionPublicShape`): secret-bearing values inside the config JSON are replaced with a redaction sentinel and a `hasSecrets` flag is surfaced (mirrors the SMTP/SMS `HasCredentials` pattern). **Update** merges the sentinel via `ConfigSecretScrubber.MergeSentinels` — a client that round-trips a scrubbed config keeps the stored secret rather than wiping it.
|
||||
|
||||
### Deployments
|
||||
|
||||
@@ -205,7 +205,7 @@ The two-person authorization workflow for writes through the MxAccess Gateway. B
|
||||
|
||||
### Transport (Bundle Import / Export)
|
||||
|
||||
- **ExportBundle**: Build an encrypted bundle (templates, system artifacts, central-only configuration). Gated to the `Design` role. Returns base64-encoded bundle bytes plus a byte count.
|
||||
- **ExportBundle**: Build an encrypted bundle (templates, system artifacts, central-only configuration). Gated to any-of `Designer`/`Administrator`; when the resolved selection carries a stored secret (SMTP/SMS credentials, external-system auth, DB connection strings, data-connection configuration) the handler additionally requires `Administrator` and otherwise answers `ManagementUnauthorized` (code review 2026-12-02 MGT-3; see `Component-Transport.md` → Authorization). Returns base64-encoded bundle bytes plus a byte count.
|
||||
- **PreviewBundle**: Unlock and inspect a previously uploaded bundle session, returning the per-entity preview (adds, modifies, identicals, blockers). Gated to the `Admin` role.
|
||||
- **ImportBundle**: Apply a previewed bundle with per-conflict resolutions inside a single audit-correlated session. Gated to the `Admin` role.
|
||||
|
||||
|
||||
@@ -458,8 +458,12 @@ Exit codes follow the project convention: `0` = success, `1` = command failure (
|
||||
|
||||
| Operation | Required role | Enforced at |
|
||||
|---|---|---|
|
||||
| Open Export page / `bundle export` CLI | `RequireDesign` | Razor page authorize attribute + `ManagementActor.GetRequiredRole` |
|
||||
| Open Export page | `RequireDesign` | Razor page authorize attribute |
|
||||
| `bundle export` CLI | Designer **or** Administrator | `ManagementActor.GetRequiredRole` |
|
||||
| Export of a **secret-bearing** selection (UI and CLI) | **Administrator** (in addition to the gate above) | `IBundleExporter.CountSecretsAsync` over the resolved closure, checked by the export page and the `ExportBundle` handler |
|
||||
| `IBundleExporter.ExportAsync` | `RequireDesign` | Service entrypoint |
|
||||
|
||||
**Secret-bearing export needs Administrator (code review 2026-12-02 MGT-3).** A bundle carries every stored secret in its selection — SMTP credentials, the Twilio auth token, external-system auth configuration, database connection strings, data-connection protocol configuration — encrypted under a passphrase the exporter chooses, or in plaintext for an unencrypted export. Nothing else in the management API returns those values to anyone (SMTP/SMS replies are public-shape scrubbed and only an Administrator may write them), so a Designer could read them only through export. Both export surfaces therefore resolve the selection exactly as the export would (`IncludeDependencies` can pull an external system or DB connection into a template-only selection) and, when `ExportSecretPolicy.CountSecrets` is non-zero, require the Administrator role; the refusal names the secret count and suggests narrowing the selection. A secret-free export stays a Designer operation, and the management gate admits an Administrator as well (the frozen authz matrix entry is `ExportBundle = [Designer, Administrator]`).
|
||||
| Open Import page / `bundle preview` + `bundle import` CLI | `RequireAdmin` | Razor page authorize attribute + `ManagementActor.GetRequiredRole` |
|
||||
| `IBundleImporter.LoadAsync` / `PreviewAsync` / `ApplyAsync` | `RequireAdmin` | Service entrypoint |
|
||||
| Configuration Audit Log "Bundle Import" filter | `RequireAdmin` or `Audit` | Existing audit page logic |
|
||||
|
||||
Reference in New Issue
Block a user