feat(proto): accept Doorkeeper PBKDF2 refresh token signatures

What does this MR do and why?

IAM now accepts a Doorkeeper refresh token whose stored hash is a PBKDF2 string, not only a SHA-512 digest. gitlab-rails still holds refresh tokens issued between 2022-09 and 2025-09 in that shape and rewrites one only when its client uses it, so the token backfill in gitlab-org/gitlab!260239 (merged) has to send them as they are. Today IAM answers INVALID_ARGUMENT and the row never lands.

The signature field on the refresh-token upsert keeps its name and number. Its rule widens to a SHA-512 hex digest or Rails' one PBKDF2 shape, $pbkdf2-sha512$20000$$ followed by the 86-character checksum, and the handler check mirrors it through the new hashers.PBKDF2Pattern. Rails never wrote another shape: 41.3% of live refresh tokens on the production clone are PBKDF2, all of them this one (gitlab-org/gitlab#632068 (comment 4068971162)). The string is stored verbatim as token_hash, so a later lookup is by equality. A plaintext is still refused. Nothing reads these rows at the token endpoint yet; redeeming a replicated token is the second phase of the work item.

Case What the caller sees
SHA-512 hex digest or PBKDF2 string stored as sent
PBKDF2 string truncated, uppercase scheme, other rounds or a salt, or any plaintext INVALID_ARGUMENT

Flag: none. Migration: none, token_hash is already TEXT. Changelog: none, repo convention. Paired: gitlab-org/gitlab!260239 (merged) sends the shape once this is deployed. The application-secret side (hashed_client_secret and the client-secret hasher) follows in a separate MR.

Commits, logging, database
  • fec94467 feat(proto): accept Doorkeeper PBKDF2 refresh token signatures; 65d9a987, 8085a1ef comment dates; 03e1b8e5 drops the duplicate integration case; 867ce556 gofmt; the last commit pins the PBKDF2 shape
  • No new log lines. The error text names the accepted shapes, never the value.
  • No query change. buf breaking against main is clean: a validation-option change on an existing field.
Known limitations

References

Screenshots or screen recordings

None: only a gRPC validation result changes.

How to set up and validate locally

  1. Start IAM Auth locally per docs/iam-auth-local-setup.md, with at least one replicated client in oauth_clients.
  2. Call InternalOAuthDoorkeeperRefreshTokensService.Upsert with signature set to $pbkdf2-sha512$20000$$ followed by an 86-character checksum of [A-Za-z0-9./], that client's client_id, a numeric subject, owning_cell_id, source_id, and created_at now.
  3. SELECT token_hash FROM doorkeeper_refresh_tokens WHERE source_id = <source_id> returns the string unchanged.
  4. Repeat step 2 with the checksum one character shorter: the call fails with INVALID_ARGUMENT.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Edited by Smriti Garg

Merge request reports

Loading
Loading