Skip to content

fix(runtime): SSO handoff value must be unique (embed token) — opening same env twice 500s#1585

Merged
xuyushun441-sys merged 1 commit into
mainfrom
fix/sso-handoff-value-unique
Jun 5, 2026
Merged

fix(runtime): SSO handoff value must be unique (embed token) — opening same env twice 500s#1585
xuyushun441-sys merged 1 commit into
mainfrom
fix/sso-handoff-value-unique

Conversation

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

Bug

The cloud-minted SSO handoff (sso_as_owner / the "Open" / "打开" button) writes a sys_verification row via AuthProxyPlugin's POST /api/v1/auth/sso-handoff-issue. The unique handoff token lives in identifier (sso-handoff:<token>), while value held a static JSON payload {email,name,by,envId}.

But sys_verification.value carries a UNIQUE index (it's the OTP/token column for email-verification flows — see platform-objects/.../sys-verification.object.ts). So issuing a handoff for the same owner+env twice produces identical value JSON and the second one fails:

UNIQUE constraint failed: sys_verification.value

→ An operator who opens the same environment a second time gets a 500.

Fix

Embed the unique handoff token (t) in the value payload so every issuance is distinct. The sso-exchange consumer only reads email/name from the parsed value, so the extra field is inert.

Verified (local 2-process stack)

sso_as_owner minted 3× in a row → all 200 with distinct tokens (previously: 1st 200, 2nd+ 500). Browser handoff then lands the owner authenticated in the env console home.

The cloud control plane has a mirror of this write (single-process/preview path) — fixed in the cloud repo alongside the harness build fix.

The cloud-minted SSO handoff (`sso_as_owner` / 'Open' button) writes a
`sys_verification` row whose unique token lives in `identifier`
(`sso-handoff:<token>`) while `value` held a static JSON payload
{email,name,by,envId}. But `sys_verification.value` carries a UNIQUE index
(it is the OTP/token column for email-verification flows), so opening the
SAME environment twice as the same owner produced identical value JSON and
the second issuance failed with:
  UNIQUE constraint failed: sys_verification.value
i.e. an operator opening their env a second time got a 500.

Embed the unique handoff token (`t`) in the value payload so each issuance
is distinct. The sso-exchange consumer only reads email/name, so the extra
field is inert.
@xuyushun441-sys xuyushun441-sys merged commit 26e9941 into main Jun 5, 2026
1 of 2 checks passed
@xuyushun441-sys xuyushun441-sys deleted the fix/sso-handoff-value-unique branch June 5, 2026 00:14
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jun 5, 2026 12:14am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants