Agent Wranglers

ACC-43Recommended

Prove a domain before trusting it

Let an organisation claim an email domain only after it publishes a DNS TXT record you gave it. Only then may the domain route sign-in or let people join.

How to do it

Make a random value per organisation and domain, such as example-verification=8f3a91c2. Look up the TXT record and compare. Check again daily, and drop the claim after 7 days of failures. Never allow a claim on a public mail domain, such as gmail.com or outlook.com. A verified domain may offer joining to new sign-ups, route sign-in to the organisation's single sign-on, and require it.

Examples

JavaScript example

import { resolveTxt } from 'node:dns/promises';

export async function isDomainVerified(domain, expected) {
  const records = await resolveTxt(domain).catch(() => []);
  return records.some(parts => parts.join('') === expected);
}

Python example

import dns.resolver

def is_domain_verified(domain: str, expected: str) -> bool:
    try:
        answers = dns.resolver.resolve(domain, "TXT")
    except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
        return False
    return any(b"".join(record.strings).decode() == expected for record in answers)

How to check

Claim a test domain without the record, and verification fails. Add the record, and it passes. A claim on gmail.com is refused.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/accounts/organisations-and-teams/verified-domains">Agent Wranglers accounts and identity playbook</a>. In code you write, add a comment next to it with the same link.