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 breakingagainstmainis clean: a validation-option change on an existing field.
Known limitations
- A PBKDF2 row that Rails later upgrades to SHA-512 on use arrives again under a new
token_hashwith the samesource_id, and the old row stays live until something revokes bysource_id. A follow-up MR under https://gitlab.com/gitlab-org/gitlab/-/work_items/631544 revokes it inside the upsert (https://gitlab.com/gitlab-org/gitlab/-/work_items/631544#note_4069906522) before Layers 1-3 are enabled.
References
- Work item: https://gitlab.com/gitlab-org/gitlab/-/work_items/631544
- Plan of record, team call 2026-10-22: gitlab-org/gitlab#632068 (comment 4066586084)
- Storage question to reviewers: https://gitlab.com/gitlab-org/gitlab/-/work_items/631544#note_4066645615
- Rails backfill waiting on this: gitlab-org/gitlab!260239 (merged)
Screenshots or screen recordings
None: only a gRPC validation result changes.
How to set up and validate locally
- Start IAM Auth locally per
docs/iam-auth-local-setup.md, with at least one replicated client inoauth_clients. - Call
InternalOAuthDoorkeeperRefreshTokensService.Upsertwithsignatureset to$pbkdf2-sha512$20000$$followed by an 86-character checksum of[A-Za-z0-9./], that client'sclient_id, a numericsubject,owning_cell_id,source_id, andcreated_atnow. SELECT token_hash FROM doorkeeper_refresh_tokens WHERE source_id = <source_id>returns the string unchanged.- 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.