Repository navigation
feat(content): connect a brand's Webflow site for Send to CMS (Send to CMS #1331, phase 2 part 1: Webflow connection) - #1503
Merged
Conversation
…o CMS ansvisor#1331, phase 2 part 1: Webflow connection) A brand connects its Webflow site with a site token, kept by Composio as an API-key connected account under the brand's own Composio user, picks the collection pages go to and which of its fields takes the body, meta title, meta description and JSON-LD. 00283 adds brand_cms_connections (members read; the server writes for admins and managers). Routes under /api/cms/brands/:brandId/webflow connect, list collections and fields with a suggested map, save the map and disconnect. The token is never stored, logged or sent back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…refusals narrowly (pre-push review) - A new token is a second Composio account until the first is removed, so connect with allowMultiple; once the new one is saved, the brand's other Webflow accounts go (forgetWebflowAccounts), and a disconnect removes them all, keeping the row when Composio can't. - Writes are tied to the account the request read: a map checked with a token replaced meanwhile isn't saved (409 changed), a late refusal marks only its own token, and a disconnect leaves a token connected meanwhile. - Only a 401 or a missing Composio account is auth_failed; a 403 is no_access and changes nothing; a successful read connects a refused connection again. - A collection's fields are given only for one on a site the token reaches. - A missing brand answers not_found; a required field can't be the JSON-LD's. - Unused exports dropped; composio.test.js covers the Webflow helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 25, 2026
gkhngyk
approved these changes
Oct 25, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups to fix before it's turned on.
What I checked:
- 00283's table and grants.
- RLS is on. anon and authenticated lose the default grants, authenticated gets
selectback, and service_role writes. - The one policy lets a member read the rows of their own workspace's brands, as
integration_connections(00045) does. With no write policy, only the server writes. - Members can read the Composio account and user ids through it, as they can on
integration_connections. They're of no use without the server's Composio key. if not existsanddrop policy if existsmake it safe to run again.schema.sqlis the build script's output.
- RLS is on. anon and authenticated lose the default grants, authenticated gets
- Who can call what.
- Every route checks that the brand is in the caller's workspace (
assertBrandAccess) before it reads by brand id. - Reading the connection is open to any member. Connecting, listing collections and fields, saving the map and disconnecting are for admins and managers only.
- The brand id must be a guid, and site and collection ids must match
[A-Za-z0-9_-]{1,100}, before any of them reaches a Composio tool. - Every call that reaches Composio is behind
cmsLimiter(60 per user per 15 minutes).
- Every route checks that the brand is in the caller's workspace (
- The token's path.
- The token arrives once in the POST body and goes straight to
connectedAccounts.initiate. It isn't written to our tables, sent back or logged. - Composio and Webflow failures are logged by error name only. Their text is read to pick a code (
run()), then dropped, and the answer is in our own words. - No answer carries Composio's ids, and the request logger doesn't log bodies.
- The token arrives once in the POST body and goes straight to
- One Composio account per brand.
- The account is made under the brand's own Composio user (
brand_<id>, apart from Search Console'sorg_<id>). Only the server keeps its id, on the brand's row. Every tool call runs with that row's user and account. - A token Webflow refuses, or one that reaches no site, is removed again and never saved. Once a new token is saved, the brand's other Webflow accounts are removed.
- Disconnect removes the accounts at Composio before the row. If Composio can't remove them, the row stays and the answer is 502.
- The account is made under the brand's own Composio user (
- A refused token.
- Only a 401 or an account that's gone sets
auth_failed, and only on the account the refusal came back for. - A 403 (a site or collection the token doesn't reach) leaves the status alone. A later read that works sets it back to
connected.
- Only a 401 or an account that's gone sets
- The map.
- The site must be one the token reaches, and the collection must be on it.
- Each part must go to a field of the right type, and the collection must require nothing that Send to CMS doesn't fill.
- The map is written only while the row still has the account it was checked with.
- Without the setting.
- Without
COMPOSIO_WEBFLOW_AUTH_CONFIG_ID, reading the connection answersconfigured: falseand every other route answersnot_configured. - Nothing else reads the table, and phase 1 is untouched.
- Without
- Merge. It merges on current main with a conflict only in
schema.sql.
Follow-ups (please fix before Webflow is turned on):
server/src/lib/brand-delete.js:36-47: deleting a brand removes itsbrand_cms_connectionsrow through the cascade. Its Webflow account stays at Composio, though, holding a site token that can write to the brand's CMS, under a Composio user nothing points to anymore. Inrun(), remove the brand's Webflow accounts before the brand row goes: callforgetWebflowAccounts(`brand_${brandId}`)whenisWebflowConfigured(), best effort, and log a failure by name. Add a test.server/src/lib/composio.js:294-301:forgetWebflowAccountsdeletes every account the list returns and relies on Composio'suserIdsfilter alone. Check that each account's user isentityIdbefore deleting it, and skip it otherwise. Then a filter the API ever ignores can't remove another brand's token.
7 of 12 tasks
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.
Summary
#1331, phase 2 (native connectors), part 1: connecting a brand's Webflow site. Webflow goes first because www.ansvisor.com runs on it. This PR is server only. It adds the connection and where pages go, not the sending, which is the next PR.
It follows the route planned on #1331: Composio with API-key auth. Webflow has no Composio-managed OAuth app, so a brand pastes a Webflow site token.
Connection (00283,
brand_cms_connections)brand_<id>). We keep the account id, asintegration_connectionsdoes for GSC.field_map, which says which collection field takes each part of a page (body→ a RichText field;metaTitle,metaDescriptionandjsonLd→ PlainText fields). An item's name and slug always go to Webflow's ownnameandslug.statusisauth_failedwhen Webflow refuses the saved token.Routes (
/api/cms/brands/:brandId/webflow, rate-limited withcmsLimiter):GET: the connection, for any member (Settings and the Send dialog). Composio's ids are never sent.POST { token }: connect, or replace the token. Admins and managers only.initiaterefuses a second active account withoutallowMultiple). So it's connected withallowMultiple, and once it's saved, the brand's other Webflow accounts are removed: the replaced token's and any a failed removal left.GET /collections?siteId=: the site's collections.GET /collections/:collectionId?siteId=: the collection's editable fields, plus a suggested map read from field slugs and names (post-body,post-summary,seo-title,meta-description,schema…). It answers only for a collection on a site the token reaches.PUT { siteId?, collectionId, fieldMap }: saves where pages go. It's checked against Webflow:changed.DELETE: removes the brand's Webflow accounts at Composio, then the row.auth_failedis set only for a 401 or a Composio account that's gone. It marks only the token that got the refusal. A later successful read sets the connection back toconnected.Errors come back with a
codethe web names to the person:not_configured,invalid,forbidden,not_in_workspace,not_found,not_connected,auth_failed,missing_scopes(the token needs Sites read and CMS read/write),no_access(a 403: a site or collection the token doesn't reach; the status isn't changed),no_site,invalid_map(withproblems),changedandfailed.Composio (
lib/composio.js) adds four functions. Webflow is kept out ofPROVIDERS, whose shared connect flow is the workspace's OAuth.isWebflowConfigured.connectWebflowToken:connectedAccounts.initiatewithAuthScheme.APIKeyandallowMultiple.initiatestill serves non-OAuth schemes after the 2026link()change.forgetWebflowAccounts.executeWebflowTool: runs on the brand's own connected account, with toolkit version20260826_00.composio.test.jscovers them with a mocked SDK.Webflow (
lib/cms/webflow.js):listSites,listCollections,getCollection,suggestFieldMapandcheckFieldMap. They read Composio's answer whether it's wrapped or bare.What's yours (needs a key)
Create a Composio auth config for the Webflow toolkit with API key auth. Set
COMPOSIO_WEBFLOW_AUTH_CONFIG_IDon the API; seeserver/.env.example. Without it, everything answersnot_configuredand phase 1 works as before.Run a real test with a site token (scopes: Sites read, CMS read and write), on ansvisor.com's site if you like:
These come from Composio's Webflow docs and haven't been tried against a live account: the connection field
api_key, and the tool argument namessite_idandcollection_id.feat(catalog): connect a store with its own sign-in, kept encrypted by the API, with a connector harness and CONNECTORS.md (00282, #1263 part 3) #1501 adds an encrypted connector credential store. If you'd rather keep the site token there and call Webflow's Data API directly than use Composio, the Webflow calls are all in
lib/cms/webflow.js, so that's a one-file swap. Say which you prefer before part 2 lands.Next in the stack
external_id.content_draft_deliveries.target.Deploy order
Related issue
Part of #1331 (phase 2, Webflow).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
server/, runnpx vitest run src/routes/cms.test.js src/lib/cms/webflow.test.js.GET /api/cms/brands/<brand>/webflowgives{ configured: false, connection: null }without the env var.POSTa site token: you get back the site andcollectionId: null;GET .../collections, thenGET .../collections/<id>: you get the fields and a suggested map;PUTthe map: the connection now shows the collection. A wrong type returnsinvalid_mapwithproblems;DELETE: the row is gone, and the connected account is gone in Composio.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): no web changeyarn typecheckpasses (run fromweb/): no web changeyarn format:checkpasses (run fromweb/): no web changeA pre-push review found the second-account refusal, three races and the 403 reading. Its fixes are the last commit.
Server:
npm run format,npm run lintandnpm test(2,622 passed) pass.bash supabase/build-schema.shwas run. 00283 is applied on the dev database.npm run version:checkreports the compose images at 0.2.0, as it does on main.🤖 Generated with Claude Code