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

Closed
opened 2026-03-13 12:54:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5910
Author: @jonathansamines
Created: 11/11/2025
Status: Merged
Merged: 11/19/2025
Merged by: @Bekacru

Base: canaryHead: feat/sso-provider-domain-verification


📝 Commits (10+)

  • fbf660c feat(sso): add provider domain verification support
  • f2a59c2 feat(sso): add domain verification client support
  • e7ff1f5 chore(sso): add domain verification tests
  • 0427531 chore(sso): remove unnecessary domain verification conditionals
  • ef4522c chore(sso): simplify ownership logic
  • 425024e docs(sso): improve documentation
  • 89fc6f4 chore(sso): return existing verification token
  • a3d7dce chore(sso): remove unnecessary spaces
  • 4846e13 chore(sso): dynamically load dns and fail server requests
  • 13a6f1f Merge branch 'canary' into feat/sso-provider-domain-verification

📊 Changes

7 files changed (+1181 additions, -33 deletions)

View changed files

📝 docs/content/docs/plugins/sso.mdx (+144 -1)
📝 packages/sso/src/client.ts (+20 -3)
packages/sso/src/domain-verification.test.ts (+550 -0)
📝 packages/sso/src/index.ts (+57 -11)
packages/sso/src/routes/domain-verification.ts (+275 -0)
📝 packages/sso/src/routes/sso.ts (+107 -15)
📝 packages/sso/src/types.ts (+28 -3)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5910 **Author:** [@jonathansamines](https://github.com/jonathansamines) **Created:** 11/11/2025 **Status:** ✅ Merged **Merged:** 11/19/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `feat/sso-provider-domain-verification` --- ### 📝 Commits (10+) - [`fbf660c`](https://github.com/better-auth/better-auth/commit/fbf660cc37b678cffd3e6ca9b3f5b6bf5b707ece) feat(sso): add provider domain verification support - [`f2a59c2`](https://github.com/better-auth/better-auth/commit/f2a59c20f8b1764192f1ead260427bfddb8e2e14) feat(sso): add domain verification client support - [`e7ff1f5`](https://github.com/better-auth/better-auth/commit/e7ff1f581c1220a1893063aa45faeebbcaed4156) chore(sso): add domain verification tests - [`0427531`](https://github.com/better-auth/better-auth/commit/0427531191a9d48307f041c468fe63e32a5465d9) chore(sso): remove unnecessary domain verification conditionals - [`ef4522c`](https://github.com/better-auth/better-auth/commit/ef4522cb3abd94dfaf922e7b5516712de4ae6675) chore(sso): simplify ownership logic - [`425024e`](https://github.com/better-auth/better-auth/commit/425024e6b35e04c57bc6c57ecc57eec1c773e924) docs(sso): improve documentation - [`89fc6f4`](https://github.com/better-auth/better-auth/commit/89fc6f4c4c52b1726568fdaf2e6f32df6420a092) chore(sso): return existing verification token - [`a3d7dce`](https://github.com/better-auth/better-auth/commit/a3d7dceac28b0074a1485720ed20e85990c562ae) chore(sso): remove unnecessary spaces - [`4846e13`](https://github.com/better-auth/better-auth/commit/4846e136a5e9c3e85c2f30b0555cfc716ffb8c1e) chore(sso): dynamically load dns and fail server requests - [`13a6f1f`](https://github.com/better-auth/better-auth/commit/13a6f1f898f9161c4195685569c27697303b8080) Merge branch 'canary' into feat/sso-provider-domain-verification ### 📊 Changes **7 files changed** (+1181 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/sso.mdx` (+144 -1) 📝 `packages/sso/src/client.ts` (+20 -3) ➕ `packages/sso/src/domain-verification.test.ts` (+550 -0) 📝 `packages/sso/src/index.ts` (+57 -11) ➕ `packages/sso/src/routes/domain-verification.ts` (+275 -0) 📝 `packages/sso/src/routes/sso.ts` (+107 -15) 📝 `packages/sso/src/types.ts` (+28 -3) </details> ### 📄 Description 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. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:54:30 -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#6313