fix(security): remove unused DEMI sync webhook - #836
Merged
danieltruong merged 1 commit intoAug 4, 2026
Conversation
POST /api/document/sync had no swagger `security:` block, so swagger-security.js treats it as public and injects a synthetic auth payload. Its only gate was `DOCLING_API_KEY || 'eagle-demi-api-key'` compared with !==, and the helm chart defines that secret for dev only — in test and prod the accepted key is the literal committed here. The handler then upserts a caller-supplied _id, hardcodes passedAVCheck:true and grants public read when the caller says isPublished. Nothing calls it. eagle-demi has no code path that posts to eagle-api; its only contact is a read-only seed pull from /api/public/search. The outbound docling extraction path was already removed in 9fcf2ed, the same commit that added this webhook. Also drops that commit's two stale comments, both describing the extraction call that no longer exists. Document schema fields kept on purpose: dev Mongo may still hold rows from the earlier DEMI intake path, and dropping schema fields is data-affecting. Re-land the sync properly when DEMI is ready to push.
danieltruong
marked this pull request as ready for review
August 4, 2026 08:02
danieltruong
requested review from
Ckoelewyn,
tolkamps1 and
tom0827
as code owners
August 4, 2026 08:02
danieltruong
added a commit
to digitalspace/eagle-demi
that referenced
this pull request
Aug 4, 2026
bcgov/eagle-api#836 merged 2026-08-04. The route and its hardcoded key fallback are gone, so there is nothing left to harden on that side.
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.
Why
POST /api/document/syncaccepts a document push from eagle-demi and upserts it into theepicDocument collection. Nothing calls it. eagle-demi has no code path that posts to eagle-api — its
only contact is a read-only seed pull from
/api/public/search. The outbound eagle-api → doclingextraction path was deleted in
9fcf2ed, the same commit that added this webhook, on 2026-07-13.It has been unmodified and uncalled since.
While it sat there unused it was also reachable and permissive:
security:block, andapi/middleware/swagger-security.js:23-31treats that as public — it injects a syntheticpublicauth payload and calls
next().process.env.DOCLING_API_KEY || 'eagle-demi-api-key',compared with
!==rather than a constant-time comparison. The chart defined that secret fordev only (
values-dev.yaml); test and prod have nodemiblock, so the accepted key there wasthe string committed to this repository.
_idwithupsert: true(so create oroverwrite),
passedAVCheck: truehardcoded, andreadgaining'public'whenever the caller sentisPublished.What changed
Removed:
api/controllers/demi.js, the/document/syncswagger path,test/controllers/demi.test.js(4 tests, all of which hardcoded the fallback key), and the
DOCLING_API_KEYwiring fromdeployment.yaml/values.yaml/values-dev.yaml.Also dropped two stale comments left by
9fcf2ed, both describing the extraction call that no longerexists: a
demi-extractjob injobQueue.js(onlyproject-doc-exportis defined) and "required tocall the extraction service" in the Helm template.
Kept deliberately: the DEMI fields on the Document schema (
api/helpers/models/document.js:59-65).They are inert, dev Mongo may still hold rows from the earlier DEMI intake path that shipped before
9fcf2ed, and dropping schema fields is data-affecting.documentSourceis not DEMI-specific at all —it carries
PROJECT/COMMENTand is read by the DAO, four materialized-view reports and theTypesense client.
Verification
npm test— 638 passing.helm templaterenders clean for dev, test and prod, with zeroDOCLING_API_KEYoccurrences.swagger.yamlparses; 87 paths remain,/document/syncgone, no path references thedemicontroller. Worth checking explicitly because the router is built from this file at boot, so a bad
edit is a startup failure rather than a test failure.
demi|doclingreturns only the two schema lines above.Follow-up, not in this PR
The
eagle-demi-api-keysecret in the dev namespace is now unreferenced by eagle-api and can bedeleted — that is an
ocmutation, so it is called out here rather than done here.When DEMI is actually ready to push, the sync should be re-landed with a real gate: its own secret
(not DEMI's outbound docling credential reused inbound), no default value, fail-closed when unset,
and a constant-time comparison.