IAM: gRPC endpoint to delete replicated refresh tokens by signature

Summary

Delete replicated refresh tokens in IAM when Rails no longer has them. IAM gets one internal call that deletes replicated tokens by their signatures, several per call. The Layer 4 reconciliation worker calls it.

Why

Rails can hard-delete a token while it is still active. IAM then keeps an active copy and is never told (#629565 (comment 3922831749)). Layers 1-3 do not send deletes (#629565 (comment 3923633562)). The data retention worker deletes old revoked tokens with delete_all, so IAM is never told about them either.

Priority

This is not needed for the first release (no iam-protocell label). Until it ships, the tokens that Rails deleted stay in the IAM database. Revocations already reach IAM through Layers 2 and 3, so most of these rows are inactive. This is acceptable for now, but the growth is not measured. We monitor the size of oauth_refresh_tokens in IAM, and we raise the priority of this work if it grows faster than expected.

Scope

IAM:

  • A gRPC endpoint that deletes replicated tokens by their signatures, several per call.
  • A missing token is not an error for the caller.
  • It deletes only replicated (Rails) tokens. Native IAM tokens are never touched.
  • The call takes only the signatures, not the cell id.

Rails:

  • Bump the gem and add the delete call to the gRPC client.
  • If Layer 4 reconciliation worker finds the replicated tokens that Rails no longer has, with the listing in #632101, update the delivery method to delete them with this call.

Out of scope

  • IAM's own cleanup of expired native rows (#607009).
  • Listing replicated tokens (#632101).
  • Follow-up issue, to create: register the deletes as iam_outbox records when Authn::DataRetention::OauthAccessTokenArchiveWorker, or any other bulk delete path, deletes revoked tokens.

Dependencies

🤖 Drafted by Claude

Edited by 🤖 GitLab Bot 🤖