Files
coder/coderd/database
Garrett Delfosse bd06fc5d84 fix(externalauth): prevent race condition in token refresh with optimistic locking (#22904) (backport to 2.31) (#24902)
Backport of https://github.com/coder/coder/pull/22904 to `release/2.31`.

Adds an optimistic lock to `UpdateExternalAuthLinkRefreshToken` so that
a concurrent caller that lost a token-refresh race cannot overwrite a
valid token stored by the winner. The SQL `WHERE` clause now includes
`AND oauth_refresh_token = @old_oauth_refresh_token`.

Original PR: #22904
Merge commit: 53e52aef78

Cherry-pick applied cleanly with no conflicts.

> Generated by Coder Agents

Co-authored-by: Kyle Carberry <kyle@coder.com>
2026-05-01 14:45:56 -04:00
..