Repository navigation
fix(server): confirm a refresh token's grant by its key - #878
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Each refresh token issued with a GrantRegistry set listed all of its end user's grant entries to confirm its own was still recorded, so the cost of issuance grew with the user's grants. In sqlstore that meant fetching and unsealing every row. memstore scanned every subject's entries. storage.GrantListing gains Key. With it set, a store may return only that entry, which the server now asks for. A store that ignores Key and lists the subject's entries as before is still correct, only slower. memstore honours it with one map lookup. The registry contract checks the entry is listed by key and never another subject's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osanderson
force-pushed
the
fix/grant-registry-keyed-confirm
branch
from
November 18, 2026 17:34
4c5a129 to
4194907
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
With
Dependencies.GrantRegistryset, every refresh token issuance runsconfirmGrantRecordedafter storing the token. It listed all of the end user's grant entries to check that its own was still there.A per-subject cap would still need that listing, and would refuse the user's new grant once it was reached. So this asks for the one entry instead.
Change
storage.GrantListinggainsKey. With it set, a store may return only the entry with that key. A store that ignores it and lists the subject's entries as before is still correct, only slower. This isn't breaking for existing implementations.confirmGrantRecordedsetsKeyand still searches whatever comes back.TestGrantRegistryContractgainsListByKey. The keyed entry must be listed while it's the subject's and unexpired, and never for another subject.sqlstore will honour
Keywith a primary-key read in a follow-up once this is released, since sqlstore builds against the released fapigo. Until then it lists as before, which is still correct.Tests
TestRefreshTokenIssuanceConfirmsItsOwnEntrychecks that issuance asks for its own entry by key, against a store that honoursKeyand one that ignores it.TestGrantRegistryListsByKeyAlonechecks memstore returns only the keyed entry.🤖 Generated with Claude Code