[PR #5910] feat(sso): add domain verification for SSO providers #14560

Closed
opened 2026-04-13 09:31:44 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5910

State: closed
Merged: Yes


Closes: #5543


Summary by cubic

Adds domain verification for SSO providers. Domains must prove ownership via a DNS TXT token before sign-in is allowed.

  • New Features

    • Added POST /sso/request-domain-verification and POST /sso/verify-domain with DNS TXT validation and ownership checks (configurable tokenPrefix).
    • Provider registration now issues and returns a 1-week verification token stored in the Verification table.
    • Added domainVerified to the ssoProvider schema and enforce verification across sign-in, callback, and ACS flows.
    • Client plugin now supports domainVerification.enabled and infers server types accordingly.
    • Updated docs with setup and DNS steps; added comprehensive tests.
    • request-domain-verification returns the existing active token when available.
  • Migration

    • Enable domainVerification in both server (sso) and client (ssoClient).
    • Run npx @better-auth/cli migrate and npx @better-auth/cli generate.
    • Add a TXT record: host better-auth-token-{providerId} (or {tokenPrefix}-{providerId}), value = issued token.
    • Submit verification via auth.api.verifyDomain; request a token via auth.api.requestDomainVerification.
    • Default SSO providers are treated as verified.

Written for commit ec20fc3e8b. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5910 **State:** closed **Merged:** Yes --- Closes: #5543 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds domain verification for SSO providers. Domains must prove ownership via a DNS TXT token before sign-in is allowed. - **New Features** - Added POST /sso/request-domain-verification and POST /sso/verify-domain with DNS TXT validation and ownership checks (configurable tokenPrefix). - Provider registration now issues and returns a 1-week verification token stored in the Verification table. - Added domainVerified to the ssoProvider schema and enforce verification across sign-in, callback, and ACS flows. - Client plugin now supports domainVerification.enabled and infers server types accordingly. - Updated docs with setup and DNS steps; added comprehensive tests. - request-domain-verification returns the existing active token when available. - **Migration** - Enable domainVerification in both server (sso) and client (ssoClient). - Run npx @better-auth/cli migrate and npx @better-auth/cli generate. - Add a TXT record: host better-auth-token-{providerId} (or {tokenPrefix}-{providerId}), value = issued token. - Submit verification via auth.api.verifyDomain; request a token via auth.api.requestDomainVerification. - Default SSO providers are treated as verified. <sup>Written for commit ec20fc3e8b0753a80a9468510bb6526d224a0bf7. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14560