Repository navigation
feat(service-bridge): Phase C reverse-coupling endpoints + mode-aware hardening + HttpAuthzClient rename - #13
Merged
Merged
Conversation
The east-west service surface (/api/service/*, /api/collab/force-disconnect) was only "inert" in native mode by the accident of a missing service secret; a native deployment that set PLATFORM_AUTHZ_SERVICE_SECRET would have activated the full privileged CCC integration surface. RemoteOnlyGuard (the mirror of NativeAuthModeGuard) 404s the surface for ALL callers whenever AUTHZ_MODE is not remote, ordered before the auth guard so native never consults the secret. The surface is now off by enforcement, not configuration. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… (Groups A/B/C)
Move the platform's direct Docmost-DB access behind scoped, service-secret-guarded
east-west endpoints so Docmost owns its schema again:
- Group A: workspace default + settings, users/resolve, pages/resolve-space
- Group B: /api/service/spaces/* control plane (list/detail/members/create/update/
archive/unarchive/add/change-role/remove); create is one Kysely transaction so the
space + creator-member rows fire the outbox atomically
- Group C: /api/service/content/{pages,spaces}/list (filter-then-retrieve), getSpace,
and pages/:id/permissions; a PRIVILEGED DATA PLANE that trusts the platform's PDP
filter and does NOT re-authorize the supplied id set
New least-privilege ServiceScopes per route; a shared WorkspaceResolver is the single
source of the canonical (oldest non-deleted) workspace. Queries are a faithful `sql`
port of the platform's (soft-delete archive, exact member upsert, ms-truncated keyset),
NOT the fork's own repos (which hard-delete + emit events). Reads use camelCase result
keys because the fork's Kysely runs CamelCasePlugin.
Tests (kysely-spy testkit compiles real SQL): RemoteOnlyGuard, canonical-workspace
invariant, transactional-create rollback, Group C trust model, and scope/guard coverage
for every route.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
It is a transport (a fail-closed HTTP client for the authorization service), not platform-specific — the name now matches the port contract + reference stub. Renames the class and its file (platform-authz.client.ts -> http-authz.client.ts) plus the two sibling specs; updates every fork reference and the port comment. The PLATFORM_AUTHZ_* env vars are read as string literals and are deliberately left unchanged (that rename is prod-coupled and deferred). Zero upstream edits (all under the fork-owned authz/ prefix). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…se C surface - service-bridge.openapi.json: add the workspace / spaces / pages / content operations (17 paths, 20 schemas), the new least-privilege scopes, the RemoteOnlyGuard mode note, and the content-plane trust note; redocly-lint clean. - README: rewrite the inbound section around the endpoint families + the three binding properties (mode-gated, scoped, platform-is-the-authority). - add a provider-side contract test that derives the /api/service/* route set from the spec and asserts the implemented controllers match it (drift fails the build). Co-Authored-By: Claude Opus 4.8 <[email protected]>
… review-round-1 gaps Addresses the /pr-review-comprehensive round-1 findings on docmost#13 / wiki-v2#173: - Cap regression: ContentListDto.ids was @ArrayMaxSize(1000) while the platform forwards up to content.maxListAuthorizedIds (default 10000), so a principal authorized on 1001-10000 objects passed the PDP belt then got a 400 on /v1 lists. Raise the cap to CONTENT_LIST_MAX_IDS (10000) and set the canonical maxItems in service-bridge.openapi.json. The provider contract test now binds the DTO caps (ids + limit) to the spec so the three can never silently diverge. - Add service-workspace.service.spec.ts: proves the settings JSONB coalesce shallow-merge preserves sibling keys. This merge was untested in either repo (the platform docstring wrongly claimed fork coverage). - Pin deleted_at + workspace_id confidentiality predicates in the content service spec, so a future edit dropping either fails CI instead of leaking trashed/cross-workspace content into /v1. Also cover listSpacesByIds, resolvePageSpace (default + includeDeleted), and listPagePermissions. - Tighten scope-coverage to assert the exact least-privilege ServiceScope per route (documents the intentional pages:read vs content:read split), plus a no-stale-entries guard. - Validate ContentCursorDto.updatedAt as ISO-8601 so a malformed cursor is a 400, not a 500. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Phase C of the standalone boundary (wiki-v2 issue docmost#157), fork side: host the east-west endpoints the platform needs so it no longer reaches into Docmost's database, harden the whole service surface to be mode-aware fail-closed, and rename
PlatformAuthzClient->HttpAuthzClient. Pairs with the super PR on cccvu/wiki-v2 (merge THIS fork PR first, then that repoints the submodule to the merge commit).Context
The platform used to reach DIRECTLY into Docmost's Postgres for workspace settings, the space/membership control plane, and the
/v1content read model. Every table/column it hard-coded is an upgrade landmine. This PR adds the fork-owned, service-secret-guarded endpoints that let the platform do all of that over HTTP instead, so Docmost owns its own schema again.Related issues
What changed
RemoteOnlyGuard) — the mirror ofNativeAuthModeGuard. The service surface (/api/service/*,/api/collab/force-disconnect) used to be only "inert" in native mode by the accident of a missing secret; a native deployment that setPLATFORM_AUTHZ_SERVICE_SECRETwould have activated the full privileged CCC surface.RemoteOnlyGuardnow 404s the whole surface for ALL callers unlessAUTHZ_MODE=remote, ordered BEFORE the auth guard so native never consults the secret. Applied to the existing controllers + every new one./api/service/*endpoints (all in the fork-owned, boundary-excludedservice-bridge/module):users/resolve,workspace/default,workspace/settings(GET/PATCH)./api/service/spaces/*control plane (list / detail / members / create / update / archive / unarchive / add / change-role / remove).createruns both inserts in ONE Kysely transaction so the space + creator-member rows fire the outbox atomically.content/pages/list,content/spaces/list,content/spaces/:id,pages/resolve-space,pages/:id/permissions.ServiceScopeper capability (workspace:read,workspace:settings:write,users:resolve,pages:read,spaces:read,spaces:write,content:read).sqltemplates, NOT the fork's own repos (which hard-delete + emitSPACE_DELETEDevents — different semantics that would drift the outbox). Reads use camelCase result keys because the fork's Kysely runsCamelCasePlugin.PlatformAuthzClient->HttpAuthzClient(class + file + specs + all refs + port comment);PLATFORM_AUTHZ_*env vars deliberately unchanged (that rename is prod-coupled, deferred).service-bridge.openapi.json(17 paths, 20 schemas; redocly-clean) + README; a provider contract test asserts the implemented/api/service/*routes match the spec.How this was tested
cd apps/server && pnpm exec jest src/service-bridge src/authz— 31 suites / 263 tests green (baseline.tsxemail failures unchanged). tsc--noEmitclean.RemoteOnlyGuard(native + secret set -> 404); the canonical-workspace invariant (oldest-non-deleted, incl. >1 and 0 cases); the transactional-create rollback (2nd insert fails ->spacesrow rolled back, no partial space — via a spy Kysely that really compiles the SQL and records begin/commit/rollback); the Group C trust model (returns exactly the supplied ids, no re-authorization); scope+guard coverage for every route; the provider contract test.npx @redocly/cli lint docs/integrations/authorization/*.json— clean.Checklist
Scope
Tests
Docs & contracts
service-bridge.openapi.json+ README extended;UPSTREAM_MODIFICATIONS.md(super) updated.Safety (security-first, deny-by-default)
service-bridge/+authz/prefixes; the one config seam (tsconfig.build.jsontest-exclude) is documented as seam fix(collab): bound the Yjs conflict scan one editor's frames can cost (wiki-v2 #816) #89.Housekeeping
Known limitations / follow-ups
PLATFORM_AUTHZ_*env-var rename stays deferred (prod-coupled).sync/trigger-outbox) is NOT part of this PR; its replacement with a fork-owned change-feed is tracked in cccvu/wiki-v2#171.🤖 Generated with Claude Code