InvalidateAuthorizeCodeSession marks the code consumed via a CAS `WHERE signature = $1 AND active = TRUE`. The CAS is load-bearing: without it, two concurrent token exchanges at READ COMMITTED can each pass GetAuthorizeCodeSession (both see active=TRUE before either UPDATE lands) and both Invalidate
(ctx context.Context, code string)
| 284 | // ErrInvalidatedAuthorizeCode triggers fosite's deferred rollback in |
| 285 | // flow_authorize_code_token.go. |
| 286 | func (s *Storage) InvalidateAuthorizeCodeSession(ctx context.Context, code string) error { |
| 287 | tag, err := s.db(ctx).Exec(ctx, |
| 288 | `UPDATE oauth_auth_codes SET active = FALSE WHERE signature = $1 AND active = TRUE`, code) |
| 289 | if err != nil { |
| 290 | return err |
| 291 | } |
| 292 | if tag.RowsAffected() == 0 { |
| 293 | return fosite.ErrInvalidatedAuthorizeCode |
| 294 | } |
| 295 | return nil |
| 296 | } |
| 297 | |
| 298 | // ───────────────────────── AccessTokenStorage ───────────────────────── |
| 299 |