refactor: remove the unused consumer-scoping branch from consent grants - #73
Merged
Merged
Conversation
grantAccessToViews took a consumerId that no caller passed. All four call sites use the default, ALL_CONSUMERS, and the two methods the branch reached for -- grantAccessToSystemViewForConsumer and grantAccessToCustomViewForConsumer -- have no other caller anywhere in the codebase. Dead, but not harmless. AccountAccess.consumer_id stores the literal string ALL_CONSUMERS rather than acting as a wildcard, and every lookup matches it by equality. revokeConsentAccountAccess sweeps a revoked consent's rows by asking for exactly ALL_CONSUMERS, so any row written under a real consumer id would have been invisible to it: access outliving the consent that created it, with nothing left to remove it. Whoever first passed a consumerId would have got that silently, and the two functions are far enough apart that the connection is easy to miss. Removing the branch makes the invariant hold by construction rather than by coincidence, and both sides now say so: grantAccessToViews carries the warning, revokeConsentAccountAccess records that its sweep is complete only because of it. The scaladoc also claimed UK grants to the real PSU and passes the consent's own consumerId, which stopped being true when UK moved to the shadow user. The Views trait keeps both ForConsumer methods; only this caller goes. berlin.group 183/183, UKOpenBanking 414/414, v5_1_0 246/246. The local probe matrix gains a check that reads the granted rows back and asserts every one is scoped ALL_CONSUMERS, so the property revoke depends on is pinned rather than assumed: 103/103.
|
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.



grantAccessToViewstook aconsumerIdthat no caller passed. All four call sites use the defaultALL_CONSUMERS, and the two methods the branch reached for —grantAccessToSystemViewForConsumer/grantAccessToCustomViewForConsumer— have no other caller anywhere in the codebase.Why dead code was worth removing rather than leaving
AccountAccess.consumer_idstores the literal stringALL_CONSUMERS; it is not a wildcard, and every lookup matches it by equality:revokeConsentAccountAccesssweeps a revoked consent’s rows by asking for exactlyALL_CONSUMERS. So a row written under a real consumer id would have been invisible to it — access outliving the consent that created it, with nothing left to remove it.Nobody had hit this, because nobody passed a
consumerId. But the first person to use the parameter would have got it silently, and the grant and revoke sites are far enough apart that the connection is easy to miss.Removing the branch makes the invariant hold by construction rather than by coincidence. Both sides now state it:
grantAccessToViewscarries the warning, andrevokeConsentAccountAccessrecords that its sweep is complete only because of it.The scaladoc also still claimed “UK is the exception — it grants to the real PSU — so it passes the consent’s own consumerId”. That stopped being true when UK moved to the per-consent shadow user; corrected.
The
Viewstrait keeps bothForConsumermethods — only this caller goes.Verification
code.api.berlin.groupcode.api.UKOpenBankingcode.api.v5_1_0The local probe matrix gains a check that reads the granted rows back out of the database and asserts every one is scoped
ALL_CONSUMERS, so the property revoke depends on is pinned rather than assumed:103/103 against a running instance.