Files
coder/coderd/database/dbmock
Bobby Ho 96ee8d171a fix: make OAuth2 code redemption single-use under concurrency (#28744)
TL;DR

Third PR in the PLAT-480 stack, on top of #28740. Fixes a race where the same authorization code could be redeemed twice concurrently.

The redeeming delete now returns the deleted row. If another request already redeemed the code, the delete returns sql.ErrNoRows and redemption fails with invalid_grant.

Each redemption runs in its own transaction, so concurrent requests serialize on the code row and only one succeeds.

The test now races two concurrent redemptions to verify single-use behavior.

No scope logic, new endpoints, or schema changes.

Depends on #28740.

Stack: #28237, #28740, this PR.
2026-09-08 16:42:34 -07:00
..