Skip to content

[Superseded] feat(signing): lay groundwork for configured external integrations (#9596) - #9610

Closed
vitormattos wants to merge 31 commits into
mainfrom
feat/9596-external-signing-storage
Closed

vitormattos wants to merge 31 commits into
mainfrom
feat/9596-external-signing-storage

Conversation

@vitormattos

@vitormattos vitormattos commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Superseded by #9611 (consolidated, self-contained PR). The implementation from this draft is now included in #9611, whose branch contains the CSC catalog, persistence and administrative API before CI runs. This draft is closed to prevent redundant reviews and unavoidable CI failures caused by missing dependencies. Original signed commits and this branch are retained. No merge or squash was performed.


Scope

Implements the persistence and metadata-driven administration service for configured external signing integrations. Tracks #9596 and depends on the declarative provider catalog in #9611 (#9595). This PR remains draft and must not be merged until the actual catalog and administrative OCS contract are integrated and verified.

Implemented

  • Versioned database migration supporting multiple instances of the same driver, stable opaque IDs, revision checks, keyset pagination and audit tombstones.
  • Configuration storage with optimistic concurrency and explicit encryption of credentials using Nextcloud ICrypto.
  • Shared ExternalIntegrationAdministration service for create, inspect, list, update, enable, disable and soft-delete operations. No catalog classes were copied from the pending dependency.
  • Declarative input validation for csc-v1 metadata (baseUrl and optional secret accessToken), rejecting unknown fields and secrets in public configuration; HTTPS URL checks exclude credentials, fragments, query strings, local hostnames and literal IP targets.
  • Read model with secretFields: [{ key, isConfigured }], without plaintext secret values. Omitted secret changes preserve ciphertext; explicit replacement or clearing uses the existing optimistic revision.
  • Deletion atomically disables the integration, clears configuration and erases encrypted credentials while retaining identifying metadata for audit. This branch has no active signing-session consumer.
  • Regression tests for persistence, cryptographic failure handling, redaction, malformed configuration, lifecycle, concurrency and administrative service state transitions.
  • Cleanup of source comments: current behavior and invariants only, without issue/PR numbers or speculative feature roadmaps.

Security boundaries

  • No HTTP requests or signing sessions are initiated by this PR. HTTPS configuration validation does not provide runtime DNS-rebinding, redirect or destination protection; those controls belong to the actual outbound connection implementation.
  • Backend authorization and global experimental-feature gating must be applied in the administrative OCS controller, which is not implemented here.
  • Future sessions must not depend on credentials of a deleted integration. The existing deletion contract is immediate credential removal, with no indefinite secret retention.

Administrative read model proposed for #9598

The following is an example of service output, not a live OCS endpoint:

{
  "id": "c0ffeec0ffeec0ffeec0ffeec0ffeec0",
  "driverId": "csc-v1",
  "name": "Corporate CSC",
  "configuration": { "baseUrl": "https://csc.example.org" },
  "enabled": false,
  "hasSecrets": true,
  "revision": 2,
  "secretFields": [{ "key": "accessToken", "isConfigured": true }],
  "driverAvailable": true
}

driverAvailable reports adapter availability and does not imply that a remote service is operational.

Checks and remaining work

  • Previous commit 991025d3: PHP-CS-Fixer, OpenAPI, type checking, REUSE, info.xml and stylelint passed. Other workflows may have been superseded by later commits; do not carry their results forward.
  • HEAD 09535938bacd3ef8884ab1c41072d4ae72ebec27: 21 workflows found, 0 succeeded, 0 failed, 21 still awaiting results at this checkpoint.
  • Signed and DCO-verified commits through Git Signing MCP.
  • Before removing draft: integrate feat(signing): consolidate CSC driver catalog, encrypted configuration and admin OCS API #9611 without duplicating its classes; implement and test the shared administrative OCS CRUD routes, server-side authorization (anonymous/user/group-admin denials), experimental gate, final OpenAPI/TypeScript contract, and combined SQLite/PostgreSQL/MariaDB matrix. Review the final combined diff.
  • No merge or squash performed.

Test coverage audit — 22 Nov 2026

Scope: ExternalIntegrationFieldValidator, ExternalIntegrationAdministration, and existing external integration test classes. Signed DCO commits: 055f1cd7, 4a3f0fa5, 765fa1d6, 354d1ee9. The code diff from 09535938 to 354d1ee91 modifies test files only.

  • Expanded named validator datasets to cover the independent driver-metadata rejection conditions (keys, required/secret flags, types, validation schema, duplicate fields), acceptable HTTPS endpoints, invalid URL types/schemes/hosts/query/fragment and byte-size bounds, incorrect public/secret field placement, create-vs-update semantics and optional/required secrets. Includes positive controls for valid HTTPS, optional fields and 8192-byte tokens.
  • Added administration DB regression tests for malformed catalog metadata, enable/disable and optimistic revision checks, unavailable-driver disablement, deletion with audited tombstone and credential erasure, stale secret updates, required-secret preservation, invalid patch atomicity and redacted mismatched-driver access.
  • Verified existing ExternalIntegrationSecretsTest already has extensive data providers for encryption/decryption, invalid authenticated maps, ciphertext preservation and confidential exception traces; ExternalIntegrationAvailabilityTest exercises all eight boolean flag combinations; store tests cover encryption, CAS, pagination, lifecycle and malformed persistence. Avoided duplicating these cases.
  • Negative create fixtures now record any unexpectedly accepted integration in a finally block for test-owned DB cleanup, even when a regression causes the intended exception not to occur.
  • Verification boundary: evidence of all these paths requires PHPUnit to run successfully on this HEAD. At last inspection, 21 workflows were registered: {"queued":7,"pending":14}. No file-specific line/branch or mutation coverage percentage is asserted without an actual coverage artifact and completed tests. Successful older SHAs are not evidence for this diff.
  • HTTP administrator permission tests remain part of the pending OCS controller integration, not a property unit tests can currently establish. The PR remains draft; do not merge.

CI diagnosis: policy target selector (Playwright)

  • At 0bca6f13, the only failing workflow was Playwright E2E (95 passing tests, one failing): footer-policy-hierarchy-ui.spec.ts exceeded 120 s in selectTarget(). The failing screenshot shows the Create rule dialog without a group selector; the helper used an unguarded ArrowDown/Enter fallback that could switch focus to an unrelated control and leave locator.fill() waiting on a disappeared field. The same test source passed in earlier workflows on this PR (17.8 s and 14.6 s), so this is a harness-interaction issue, not a confirmed CSC persistence regression.
  • Signed DCO commit bdf1d06d removes blind keyboard selection, waits for a matching ARIA/floating option, and asserts the selected target with bounded timeouts. It does not alter runtime application behavior.
  • The newly triggered CI on bdf1d06da54d889c8f704d5b0cd362a19f73431b had 21 workflows registered at the checkpoint; a complete Playwright pass on the new HEAD is still needed before calling the failure resolved. No rerun was used to disguise the original failure.

Lay down the encrypted, revisioned and retained storage foundation without duplicating the pending driver catalog from #9595.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add unit tests for redaction, secret replacement and rollout matrix, plus isolated DB integration fixtures for multiple instances and tombstone retention.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Code Metrics Report

Note: Metrics describe the revision analyzed by the successful PHPUnit run. Newer commits with pending, canceled or failed checks may not yet be represented in this report.

main (bc40b5a) #9610 (112fec8) +/-
Coverage 77.7% 77.9% +0.1%
Test Execution Time 3m13s 4m35s +1m22s
Details
  |                     | main (bc40b5a) | #9610 (112fec8) |  +/-   |
  |---------------------|----------------|-----------------|--------|
+ | Coverage            |          77.7% |           77.9% |  +0.1% |
  |   Files             |            525 |             532 |     +7 |
  |   Lines             |          29495 |           29781 |   +286 |
+ |   Covered           |          22940 |           23222 |   +282 |
- | Test Execution Time |          3m13s |           4m35s | +1m22s |

Code coverage of files in pull request scope (0.0% → 98.6%, patch 98.6%)

Files Coverage +/- Patch Coverage Status
lib/Exception/ExternalIntegrationSecretException.php 100.0% +100.0% 100.0% added
lib/Service/Signing/ExternalIntegrationAdministration.php 97.7% +97.7% 97.7% added
lib/Service/Signing/ExternalIntegrationAvailability.php 100.0% +100.0% 100.0% added
lib/Service/Signing/ExternalIntegrationFieldValidator.php 100.0% +100.0% 100.0% added
lib/Service/Signing/ExternalIntegrationRecord.php 100.0% +100.0% 100.0% added
lib/Service/Signing/ExternalIntegrationSecrets.php 100.0% +100.0% 100.0% added
lib/Service/Signing/ExternalIntegrationStore.php 97.7% +97.7% 97.7% added

Reported by octocov

Use documented Nextcloud column comment support, while SQLite discards unsupported metadata. Apply existing PHP-CS-Fixer constructor formatting.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Preserve Nextcloud ICrypto, translate expected cryptographic or corrupt-payload errors into safe domain failures, validate updates before decrypting, and cover real credential boundary cases with named PHPUnit data providers.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Cover rejected inputs, concurrent/stale secrets, encrypted replacement, disable and deletion retention, and pagination beyond 100 synthetic integrations across the Nextcloud DB test suites. Resolve the previously failing PHP-CS-Fixer import.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Mark secret-carrying arguments as SensitiveParameter to protect stack traces and apply the import ordering required by PHP-CS-Fixer.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Remove redundant crypto commentary; require encrypted secret payloads to be JSON objects, preserve object-shaped empty configuration, and validate Unicode display name lengths against the database character limit. Cover each case with focused PHPUnit tests.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Protect the private shape validator with SensitiveParameter, normalize invalid UTF-8 JSON errors without retaining sensitive causes, and verify stack traces under argument-enabled PHP settings.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Reject malformed top-level configuration maps and corrupt persisted JSON; verify redaction in both read and list paths and stale lifecycle revisions. Guarantee parent teardown on fixture cleanup failures, and replace a misleading secret-redaction assertion with the exact public record contract.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…tions

Track every created synthetic integration centrally so validation regressions that unexpectedly allow persistence cannot leave test rows behind. Preserve per-test cleanup even when assertions fail.

Refs: #9596

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…eletion lifecycle

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…catalog duplication

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…credential redaction

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…ion traces

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…eries

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…ions

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…nches

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…variants

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…cases

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…options

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos changed the title feat(signing): lay groundwork for configured external integrations (#9596) [Superseded] feat(signing): lay groundwork for configured external integrations (#9596) Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant