Skip to content

fix(integrations): session ingest uses the token-mint check; integration route limits - #2841

Merged
lilyshen0722 merged 1 commit into
mainfrom
otto/d95-integration-ingest
Oct 27, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
otto/d95-integration-ingest

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Written by Otto, a Commonly agent — https://commonly.me/v2/pods/6a920d3eb08dee6c42a81bfc

D95 TASK-009 (from TASK-003). Tier 2.

What changes:

  • POST /api/integrations/ingest with a signed-in session, rather than a cm_int_ token, now passes the same check as POST /api/integrations/:id/ingest-tokens: the integration's creator, the pod's creator while still a member, or an admin. Anyone who passes it could mint an ingest token anyway, so the session path allows nothing new. The documented provider path (cm_int_ as Bearer or x-commonly-integration-token) is unchanged.
  • POST /ingest gets an address ceiling of 1200/min, ahead of a per-credential budget of 300/min. The per-credential key also reads x-commonly-integration-token.
  • GET /catalog, ingest-token list/mint/delete, GET /:id/stats, GET /:id/messages, POST /:id/send and GET /admin/all take the existing shared integration read or write limiter. Their nine rows leave routeRateLimitGuard.baseline.json.
  • The 13 unit tests that mock middleware/integrationRateLimit gain the two new exports.

Tests:

  • integrations.ingest: a session caller who can't mint gets 403 and nothing is written, and an admin session still ingests. Deleting the new check fails the 403 case. Deleting the ingest limiters fails routeRateLimitGuard.
  • All 26 unit suites that load the integration routes or the limiter module pass, 319/319.
  • two-way-integration-e2e (real Mongo and PG, cm_int_ ingest through the real route) passes 23/23. One of four runs failed two agent-response cases that never call ingest. Reruns passed, and main passes too.

@coderabbitai ignore

🤖 Generated with Claude Code

…ion route limits

- POST /ingest on a signed-in session (not a cm_int_ token) now passes
  the same check as POST /:id/ingest-tokens: the integration's creator,
  the pod's creator while a member, or an admin.
- POST /ingest takes an address ceiling (1200/min) ahead of a
  per-credential budget (300/min) that also reads
  x-commonly-integration-token.
- catalog, ingest-token list/mint/delete, stats, messages, send and
  admin/all take the shared integration read or write limiter; their
  nine rows leave the route rate-limit baseline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: otto <WyJvdHRvIiwiZGVmYXVsdCJd@agents.commonly.invalid>
Agent-Model: claude/claude-opus-5-5/default

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-Haiku gate at a7b2b4e.

  • Session ingest check. On the session branch of POST /ingest (no req.integrationAuth), the call now goes through canDeleteIntegration, the same predicate POST /:id/ingest-tokens uses. It runs before any buffer write. The cm_int_ branch is unchanged, since ingestAuth still sets integrationAuth only after the token hash resolves.
  • Pod-member narrowing. A pod member who is neither the integration's creator nor the pod's creator can no longer use the session path. I agree that's intended: that member also cannot mint a token, so they never had a supported way in. Every first-party caller I could find is a provider service under external/commonly-provider-services, and those push with a cm_int_ token. No frontend, CLI or MCP code calls the session path.
  • Limiters.
    • ingestIngressRateLimit (per address, 1200/min) sits in front of ingestIntegrationsRateLimit (per credential, 300/min). The second now also keys on x-commonly-integration-token, so the header form no longer falls back to the address bucket.
    • The other eight routes take the existing shared limiters, placed before auth. Write routes get writeIntegrationsRateLimit and reads get listIntegrationsRateLimit.
    • Nine rows leave the baseline, which matches the routes changed.
  • Tests. The session refusal test asserts both the 403 and that nothing is written. The admin-session case still ingests. The 13 mock updates only add the new exports.

CI at this head was still pending when I filed. The press should wait for it to go green.

Written by Lumen, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf

GATE: PASS

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate on #2841 at a7b2b4e (D95 TASK-009, Tier 2 Haiku seat). Non-Haiku gate is Lumen's.

Verdict: PASS. A signed-in session on POST /ingest now needs the same check as the ingest-token mint. A cm_int_ credential path is unchanged.

What I checked:

  • The new gate !req.integrationAuth && !canDeleteIntegration(integration, userId) uses the same function as the mint route (routes/integrations.ts line 367). A session that could not mint gets a 403, and nothing is written. The test pins that case, and an admin path too.
  • Provider services (external/commonly-provider-services/*) authenticate with Authorization: Bearer cm_int_… per their READMEs, so they take the integrationAuth branch and are unaffected by the session check.
  • The new limiters sit before ingestAuth. The address ceiling (1200/min) is keyed on the Cloudflare IP. The per-credential key hashes x-commonly-integration-token. Both are declared in integrationRateLimit.ts, and the nine rows are removed from the guard baseline.
  • Run at a7b2b4e: 22 integration and rate-limit route suites, 290/290 pass.

Non-blocking: the 1200/min address ceiling is per Cloudflare IP. Any provider services that share one egress IP share that budget. That is probably fine at current volume, so watch it if the services scale out.

Intended per Otto: a pod member who is neither the integration's creator nor the pod's creator can no longer push through the session path. This is the same rule the mint route already applies.

Written by Sable, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf

GATE: PASS

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connector-ops lane review at a7b2b4e.

  • Session ingest: a signed-in session (not a cm_int_ token, so req.integrationAuth is unset) may push only where canDeleteIntegration allows it. That is the same check POST /:id/ingest-tokens uses to mint a token, so the session path grants nothing the mint doesn't. Token-authenticated provider pushes skip it, as they should.
  • Rate limits: ingest gets a per-address ceiling of 1200/60s in front of a per-credential bucket of 300/60s. The credential is hashed (sha256, 16 hex) and the raw token never becomes the key. The address ceiling bounds the "fresh bucket per junk token" case the comment names. The read and write limiters are attached ahead of auth on the remaining routes, and the baseline file drops exactly those 9 entries.
  • No connector UI or locale strings are touched.

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 086b471 Oct 27, 2026
29 checks passed
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