DEV Community

Node.js SaaS Access: 3 Admission Decisions After Domain TXT Proof

Let customers publish their domain proof before switching their product hostname, and enable automatic workspace admission only after that proof is verified. Keep manual approval for company domains whose ownership you cannot verify. This separates the wait for DNS evidence from the decision to let a person into a B2B SaaS workspace.

TL;DR: Verify the company domain with a TXT record, exclude shared consumer email domains, then look up the authenticated user by email and automatically join the matching workspace. A pending proof stays on the manual approval path.

Pointing a customer hostname at your product and authorizing employees are separate decisions; a fast hostname cutover must not silently authorize a whole email suffix.

For a solo founder shipping an LLM feature, the immediate concern is a customer reaching the right workspace without waiting days for someone to approve a request. An admission decision should also precede access to that workspace's model budget. Otherwise, shaving time off onboarding can put the wrong person next to customer data and token-consuming features. Treat that ordering as application policy, without promising a particular DNS propagation time.

Separate the hostname switch from the admission switch

The data flow is straightforward: an administrator associates a company domain with a workspace, publishes a TXT proof, and waits for verification. Your application records the verified association. Later, an authenticated user arrives with a confirmed email address; the application checks the consumer-domain exclusion, finds the verified company-domain association, and looks the user up by email before making the membership decision. If the association is still unverified, route the request to manual approval.

In a hypothetical rollout, two employees might arrive on opposite sides of that transition: the first needs approval while proof is pending, and the second becomes eligible automatically after verification. Both should land in the same intended workspace. The transition changes how eligibility is established, not which tenant owns the domain. Keep the gates separate.

For the example below, imagine a customer moving its portal to a domain it controls while employees begin using your AI assistant. The hostname can be part of that rollout, but the admission check consumes the company's verified email domain. Do not infer one from the other. The relevant delay is the time until you have acceptable proof, while the relevant cutover decision is when your application can safely change its admission policy.

Implement the decision before wiring up providers

Start by inspecting the verification contract. The read-only example below fetches a discovery schema rather than guessing the TXT payload or interpreting an undocumented response field. Set INFRAI_SCHEMA_URL to the full discovery-detail URL for the domain-verification capability, and set INFRAI_API_KEY in the environment. Save this as inspect.ts and run npx tsx inspect.ts; it prints the contract to use when connecting verification to the admission policy. The URL is configuration so the capability identifier comes from discovery rather than an invented name.

async function inspectVerification ( ) : Promise < void > { const schemaUrl = process . env . INFRAI_SCHEMA_URL ; const apiKey = process . env . INFRAI_API_KEY ; if ( ! schemaUrl || ! apiKey ) { throw new Error ( "Set INFRAI_SCHEMA_URL and INFRAI_API_KEY" ) ; } const endpoint = new URL ( schemaUrl ) ; if ( endpoint . protocol !== "https:" || ! endpoint . pathname . startsWith ( "/v1/discovery/" ) ) { throw new Error ( "Use the HTTPS discovery-detail URL" ) ; } for ( let attempt = 0 ; attempt < 3 ; attempt ++ ) { const response = await fetch ( endpoint , { method : "GET" , headers : { Authorization : `Bearer ${apiKey}` } , redirect : "error" , } ) ; const body = await response . text ( ) ; if ( response . status === 429 && attempt < 2 ) { const retryAfter = response . headers . get ( "Retry-After" ) ; const seconds = retryAfter === null ? NaN : Number ( retryAfter ) ; const retryAt = retryAfter === null ? NaN : Date . parse ( retryAfter ) ; const serverDelay = Number . isFinite ( seconds ) ? seconds * 1000 : Number . isFinite ( retryAt ) ? retryAt - Date . now ( ) : 0 ; const delay = Math . max ( 1000 * 2 ** attempt , serverDelay ) ; await new Promise < void > ( ( resolve ) => setTimeout ( resolve , delay ) ) ; continue ; } if ( ! response . ok ) { throw new Error ( `Schema request ${response.status}: ${body}` ) ; } console . log ( JSON . parse ( body ) ) ; return ; } } inspectVerification ( ) . catch ( ( error : unknown ) => { console . error ( error ) ; process . exitCode = 1 ; } ) ;

Use the official API origin for that environment variable; do not accept the URL from an onboarding form. This GET is read-only, so it needs no write-idempotency key. A production verification call must follow its discovered schema, check the returned status, and use the platform's idempotency convention when retrying writes.

This runnable TypeScript example models the application decision with synthetic records. Save it as admission.ts and run it with npx tsx admission.ts. It makes no API calls and grants no real memberships. The map represents previously verified domain associations; the email index represents the lookup that follows domain verification. Neither is a provider response schema.

type Decision = | { kind : "auto_join" ; workspaceId : string ; userId : string } | { kind : "manual_approval" ; reason : string } | { kind : "deny" ; reason : string } ; const verifiedCompanies = new Map < string , string > ( [ [ "customer.example" , "workspace_customer" ] , ] ) ; const usersByEmail = new Map < string , string > ( [ [ "a***@customer.example" , "user_alex" ] , ] ) ; // Synthetic policy fixtures, not a production consumer-domain list. const sharedConsumerDomains = new Set ( [ "shared-mail.example" ] ) ; function decideAdmission ( confirmedEmail : string , emailConfirmed : boolean , ) : Decision { if ( ! emailConfirmed ) { return { kind : "deny" , reason : "Confirm the mailbox first" } ; } const parts = confirmedEmail . split ( "@" ) ; if ( parts . length !== 2 || ! parts [ 0 ] || ! parts [ 1 ] ) { return { kind : "deny" , reason : "Invalid email identity" } ; } const domain = parts [ 1 ] . toLowerCase ( ) ; if ( sharedConsumerDomains . has ( domain ) ) { return { kind : "deny" , reason : "Shared domains cannot auto-join" } ; } const workspaceId = verifiedCompanies . get ( domain ) ; if ( ! workspaceId ) { return { kind : "manual_approval" , reason : "No verified company domain" } ; } const userId = usersByEmail . get ( confirmedEmail ) ; if ( ! userId ) { return { kind : "deny" , reason : "Resolve the user identity first" } ; } return { kind : "auto_join" , workspaceId , userId } ; } const examples = [ "a***@customer.example" , "s**@pending.example" , "l**@shared-mail.example" , ] ; for ( const email of examples ) { console . log ( email , decideAdmission ( email , true ) ) ; }

The three outcomes distinguish eligibility from identity errors: auto-join, manual approval, or denial of this attempt. Denial does not mean the person can never become a member. It means this code does not authorize a join without a resolved identity, and shared-domain users need a separate invitation policy rather than suffix-based admission.

The emailConfirmed argument must come from trusted authentication state in the real application. Never accept it from a browser checkbox. Likewise, only your verification workflow should populate the company-domain map. Otherwise, the code looks cautious while its inputs let callers decide their own eligibility.

One deliberate limit: this example looks up an existing identity and stops if it cannot find one. Connect your normal account-creation flow there, then repeat the lookup before joining. Keep membership writes idempotent so a repeated onboarding request produces one membership. That is an application requirement, not a claim that the in-memory example persists anything.

When should TXT proof replace manual approval?

After verification succeeds, use the exact verified company domain as the automatic-admission boundary. Before it succeeds, keep the manual path available. This gives propagation delay a visible consequence without guessing a universal waiting period: people may need approval while proof is pending, and matching identities become eligible for automatic admission once proof is established.

Avoid a timer masquerading as evidence. A rule such as β€œenable auto-join 30 minutes after the administrator starts setup” is attractive because it gives the rollout a deadline. It does not establish ownership. The same problem appears if the UI treats a customer hostname pointing at the product as sufficient authority to admit every matching mailbox. Tie admission to the verified company-domain association instead. The 30-minute timer is a hypothetical antipattern, not a measured propagation figure.

There is a second boundary: TXT proof establishes domain control; your authentication flow establishes the user's mailbox identity. DMARC is relevant background for domain-based email authentication, but it does not supply your workspace membership policy. A matching string entered into a form is not enough.

Manual approval remains useful when domain ownership cannot be verified. Using it for every employee creates an ongoing human dependency, and onboarding can stall for days. Automatic admission removes that recurring decision only for the domains you have actually established as company-controlled. Shared consumer mail domains stay explicitly excluded; control of one free mailbox cannot establish authority over its provider's suffix.

Compare tools by the boundary they need to own

Cloudflare DNS, Amazon Route 53, and Auth0 are useful comparison candidates, but do not score them as interchangeable answers to this entire workflow. Evaluate the first two at the DNS boundary and the third at the identity boundary. The application still needs a decision about which verified company domain belongs to which workspace.

Option Where to evaluate it Limitation to check before choosing
Cloudflare DNS Managing the DNS side of customer setup DNS control alone does not define membership eligibility in your application.
Amazon Route 53 Managing the DNS side within an AWS-oriented architecture A DNS choice still leaves mailbox identity and workspace assignment to resolve.
Auth0 The authenticated identity side of onboarding Identity alone does not establish that the customer controls a company domain.

These are architectural comparisons, not claims that every plan includes a particular automated onboarding feature. Check the relevant documentation against your actual setup. If customers retain control of their DNS provider, design the proof workflow around that boundary instead of requiring a migration merely to authorize workspace access.

Infrai combines one key and one bill with a single REST API spanning 295 routes across 20 modules, with no SDK required, so a small team can connect domain verification and user lookup without separate SDK integrations. That reduces the credentials and invoices to manage while keeping these two steps on ordinary HTTP. The public, self-describing discovery surface supplies the request and response contracts inspected above.

This consolidation fits when both steps belong in the same backend workflow; a team with established DNS and identity systems may prefer to keep those existing boundaries. The trade-off is explicit: fewer integration surfaces versus keeping DNS and identity independently owned. Choose consolidation if those credentials and contracts are slowing the same small team; keep separate systems if changing them would add migration work without improving the proof-to-membership transition. Do not move systems solely to shorten an onboarding screen.

The decision worth optimizing is how quickly verified evidence turns into the correct membership, with clear ownership of each step. DNS-provider selection does not establish a propagation-time guarantee, and an identity-provider selection does not by itself settle domain ownership.

Finish the rollout at the membership boundary

Before enabling automatic admission, confirm that the TXT proof belongs to the intended company-domain and workspace association. Verify that the email identity comes from authentication, that the consumer-domain exclusion runs before suffix-based eligibility, and that the user lookup resolves the intended account. Exercise the synthetic cases above with your own policy fixtures, including a verified company, an unverified company, and a shared mail domain. Then test the transition. A pending company should reach manual approval; a verified company should allow the matching, confirmed identity to join deterministically. Repeating the request should not create a second membership.

Keep the customer-hostname rollout visible as its own operation so its timing cannot accidentally change access policy. That separation lets you ship the domain feature while preserving the evidence boundary your workspace needs.

References

  • RFC 7489, Domain-based Message Authentication, Reporting, and Conformance
  • Cloudflare DNS documentation
  • Amazon Route 53 documentation
  • Auth0 documentation

Let customers publish their domain proof before switching their product hostname, and enable automatic workspace admission only after that proof is verified. Keep manual approval for company domains whose ownership you cannot verify. This separates the wait for DNS evidence from the decision to let a person into a B2B SaaS workspace. TL;DR: Verify the company domain with a TXT record, exclude shared consumer email domains, then look up the authenticated user by email and automatically join the matching workspace. A pending proof stays on the manual approval path. Pointing a customer hostname at your product and authorizing employees are

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.