Repository navigation
feat(member): self-service domain add+verify via WorkOS DNS challenge - #4440
Merged
Merged
Conversation
Adds POST /api/me/organization/domains (issue WorkOS DNS-TXT challenge) and POST /:domain/verify (confirm + flip verified=true) so owners/admins can attach and verify a new domain without admin intervention. The existing PUT /:domain/primary then accepts the row because source='workos' matches the member self-service gate. Closes the gap that forced admin handling for Santhosh @ Affinity Answers: once verified by the member, the Public visibility toggle on the agent card unblocks automatically (no admin role flip required). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
H1 (security blocker): At POST issue time there was no DNS proof yet, but the route called upsertWorkosDomain which has documented ownership-transfer- on-conflict semantics. A cross-org local-only row (source='manual' or 'import') for the same domain would be silently transferred to the caller's org. Now: pre-check for a cross-org row and 409 cleanly; switch the issue- time local write to linkDomain (refuses transfer); keep upsertWorkosDomain only on the verify path where WorkOS confirms DNS proof. M1: Added a 60s per-(org,domain) verify cooldown to stop agentic loops that poll on still_pending from burning WorkOS quota. Mirrors brand-claim.ts. Cleared on successful verify so follow-up "verify then set primary" isn't penalized. Product blockers: Linked Domains section now shows for owner/admin viewers even when domains.length === 0 (orgs with no rows had no entry point at all). Add-a-domain card is hidden client-side for non-admin members so they don't see a button that 403s. Nit: agent-card "primary brand domain" hint deep-links to /member-profile#linked-domains-section, the actual flow. Tests: cross-tenant safety (H1), message-regex collision fallback, broken- pending delete-and-recreate, verify cooldown. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
Author
Expert reviews resolvedSecurity review (H1 ship-blocker):
Code review:
Product/UX review:
Ready for merge once CI clears. |
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 14, 2026
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
POST /api/me/organization/domains(issue WorkOS DNS-TXT challenge) andPOST /:domain/verifyso owners/admins can attach and verify a new domain without admin intervention.source='workos', which the existingPUT /:domain/primaryalready accepts — once primary, the Public visibility toggle on the agent dashboard unblocks automatically./member-profilegets an "Add a domain" form + per-row Verify button.Why
Today, admins are paged whenever a member wants to publicly list an MCP agent on a domain not auto-promoted from WorkOS SSO. The dashboard's Public toggle is gated on
organization_domains.is_primary=truewithsource='workos'— the member self-service set-primary endpoint hard-codesrequireSource: ['workos']. Without a member-issued WorkOS challenge, the only path was admin override.Active escalation: Santhosh @ Affinity Answers wants to make his MCP agent Public;
affinityanswers.comis admin-attached so he can't promote it himself. With this change he runs the DNS challenge in the UI and unblocks himself.Security model
The verify path keeps the documented
upsertWorkosDomainownership-transfer-on-conflict semantic — DNS proof is in hand, so a same-domain row on another org is correctly overridden. The issue path explicitly does NOT have DNS proof yet, so it:linkDomain(refuses transfer on conflict) instead ofupsertWorkosDomainfor the local write.Verify is rate-limited with the same 60s per-(org,domain) cooldown as
brand-claim.tsto stop agentic loops from burning WorkOS quota onstill_pending.What changed
server/src/routes/me-organization-domains.ts— two new owner/admin-gated routes; in-process verify cooldown; cross-org pre-check;linkDomainat issue time.server/public/member-profile.html— Add-domain form with TXT record callout (host + token + copy button) and Verify DNS button; pending rows in the list get a per-row Verify button. Section shows for owner/admin even when 0 domains. Add card hidden client-side for non-admin viewers.server/public/dashboard-agents.html— "primary brand domain" hint deep-links to#linked-domains-section.server/tests/integration/me-organization-domains.test.ts— 14 new tests including cross-tenant safety, message-regex collision fallback, broken-pending recreate, verify cooldown, and an end-to-end seam (issue → verify → set-primary by an owner with no admin in the loop).Test plan
npx vitest run tests/integration/me-organization-domains.test.ts— 20/20npx vitest run tests/integration/{organization-domains-db,brand-domain-resolver,me-organization-domains}.test.ts— 53/53🤖 Generated with Claude Code