Skip to content

Commit e8a81f0

Browse files
os-zhuangclaude
andauthored
fix(identity): sys_verification.value must not be UNIQUE — it breaks OIDC authorize (#2333)
better-auth's oauth-provider stores OIDC authorization codes in the verification table with `value` = a JSON blob (keyed by user + client + state) that can legitimately repeat. The UNIQUE index on `value` makes `/api/v1/auth/oauth2/authorize` fail with `UNIQUE constraint failed: sys_verification.value` → HTTP 503, which breaks cloud-as-IdP SSO ("Continue with ObjectStack") entirely — the authorize loops forever. better-auth keys verification lookups on `identifier` (indexed), not `value`, so a non-unique index on `value` is sufficient. Found via a local browser E2E of the env→cloud OIDC SSO flow (ADR-0024 D3). NOTE: existing control-plane DBs already have `uniq_sys_verification_value`; they need a migration to drop it (schema-sync is additive). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 635849f commit e8a81f0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/platform-objects/src/identity/sys-verification.object.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ export const SysVerification = ObjectSchema.create({
6767
},
6868

6969
indexes: [
70-
{ fields: ['value'], unique: true },
70+
// `value` must NOT be unique. better-auth's oauth-provider stores OIDC
71+
// authorization codes in this table with `value` = a JSON blob keyed by
72+
// user+client+state, which can legitimately repeat. A UNIQUE constraint
73+
// makes `/api/v1/auth/oauth2/authorize` fail (`UNIQUE constraint failed:
74+
// sys_verification.value`) → 503, breaking cloud-as-IdP SSO entirely.
75+
// better-auth keys verification lookups on `identifier`, not `value`.
76+
{ fields: ['value'], unique: false },
7177
{ fields: ['identifier'], unique: false },
7278
{ fields: ['expires_at'], unique: false },
7379
],

0 commit comments

Comments
 (0)