You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d9353b9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-auth): verify-domain answers DOMAIN_VERIFICATION_DISABLED for the disabled condition (#11004)
Both SSO domain-verification bridge routes recognise the same shape - the inner
@better-auth/sso endpoint is unmounted for this env and answers 404 with no code
- and answered it differently. runRequestDomainVerification returns 400 +
DOMAIN_VERIFICATION_DISABLED; runVerifyDomain rewrote only the message and let
the code fall through to the generic failure default, so the response carried
"the feature is off" copy under a code meaning "verification failed".
verify-domain now returns the sibling's answer for that condition: 400 +
DOMAIN_VERIFICATION_DISABLED. The status moves with the code because the inner
404 describes the INNER endpoint, while this bridge route is mounted
unconditionally.
The rewrite stays keyed to the disabled shape (404 WITHOUT a code): a genuine
failure still answers DOMAIN_VERIFICATION_FAILED, and the vendor pass-through
arm is untouched on both routes. Both directions are pinned.
Part of #10859
Claude-Session: https://claude.ai/code/session_01PnJHU45vPJj5UQrxe946Bx
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/plugins/plugin-auth/src/register-sso-provider.ts
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -457,11 +457,21 @@ export async function runVerifyDomain(
457
457
if(resp.ok){
458
458
return{status: 200,body: {success: true,data: { providerId,verified: true,message: 'Domain ownership verified — this provider can now sign users in.'}}};
459
459
}
460
+
// The feature is OFF for this env: `@better-auth/sso` never mounted the inner
461
+
// endpoint, so its `404` describes the INNER route. THIS route is mounted
462
+
// unconditionally, so passing that status through says "no such endpoint"
463
+
// about a resource that exists. Answer the sibling's answer instead — same
464
+
// condition, same code, same status (#10859). Before this, the branch
465
+
// rewrote only the `message` and let the code fall through to the generic
466
+
// default below, so the machine-readable field said "verification failed"
467
+
// while the human-readable one said "the feature is off"; a caller can only
468
+
// act on the first.
469
+
if(resp.status===404&&!parsed?.code){
470
+
return{status: 400,body: {success: false,error: {code: 'DOMAIN_VERIFICATION_DISABLED',message: 'Domain verification is not enabled for this environment (set OS_SSO_DOMAIN_VERIFICATION).'}}};
471
+
}
460
472
// Friendlier copy for the expected failure modes.
Copy file name to clipboardExpand all lines: packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -258,7 +258,7 @@ function expectationsFor(targetUserId: string): Record<string, RouteExpectation>
258
258
'POST /api/v1/auth/admin/sso/verify-domain': {
259
259
bucket: 'objectstack-gate',
260
260
body: {providerId: 'refusal-probe-oidc'},
261
-
note: 'admin passes the gate and lands on 404 DOMAIN_VERIFICATION_FAILED while SSO is off',
261
+
note: 'admin passes the gate and lands on 400 DOMAIN_VERIFICATION_DISABLED while SSO is off (#10859 — it answered 404 DOMAIN_VERIFICATION_FAILED before, out of step with the sibling above)',
262
262
},
263
263
264
264
// ── #9652: ban / unban moved from the vendor to an ObjectStack mount ────
0 commit comments