fix(runtime): SSO handoff value must be unique (embed token) — opening same env twice 500s#1585
Merged
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
The cloud-minted SSO handoff (
sso_as_owner/ the "Open" / "打开" button) writes asys_verificationrow viaAuthProxyPlugin'sPOST /api/v1/auth/sso-handoff-issue. The unique handoff token lives inidentifier(sso-handoff:<token>), whilevalueheld a static JSON payload{email,name,by,envId}.But
sys_verification.valuecarries a UNIQUE index (it's the OTP/token column for email-verification flows — seeplatform-objects/.../sys-verification.object.ts). So issuing a handoff for the same owner+env twice produces identicalvalueJSON and the second one fails:→ 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. Thesso-exchangeconsumer only readsemail/namefrom the parsed value, so the extra field is inert.Verified (local 2-process stack)
sso_as_ownerminted 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.