You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: keep the code-defined system views current on every installation, not only fresh ones (#80)
The UK Open Banking and Berlin Group views carry can_* sets defined in
Constant.SYSTEM_READ_*_VIEW_PERMISSION, and applyDefaultsForSystemView writes
them. It runs from exactly two places: unsavedSystemView, at creation, and
factoryResetSystemView, an admin endpoint. Boot calls getOrCreateSystemView,
which returns an existing row untouched.
So a view created by an older version keeps that version's permission set for
good. Tightening a set in code reaches new installations and no others -- which
is how "ReadAccountsDetail granted nothing beyond ReadAccountsBasic" and
"ReadBalances alone exposed transaction and counterparty data" could be fixed in
code and remain true of every upgraded database.
Boot now calls ensureSystemViewUpToDate, which creates the view when missing and
otherwise re-applies the code-defined permissions to the existing row. Only the
permission set: name, description, isPublic and the alias flags are left alone,
so operator edits to those survive an upgrade. Unlike a migration this is not
opt-in -- migration_scripts.execute_all defaults to false, so shipping this as a
migration would have reproduced the very shape of the defect, a fix that does not
apply to the installations that have the problem.
system_views.reconcile_permissions_at_boot turns it off for an operator who
hand-tunes these rows. Default true, and every view whose set moves is logged
with the permissions added and removed.
The nine views the code defines sets for are also created unconditionally rather
than through additional_system_views. The code already depends on them: a UK
consent naming ReadTransactionsCredits cannot be granted if that view is absent,
and validateUKConsentPermissions requires a direction permission whenever a
transaction-depth one is granted -- so a conforming consent could not be
exercised at all on an instance whose props predated the view.
ReadTransactionsBerlinGroup and InitiatePaymentsBerlinGroup stay opt-in, since
nothing requires them, but are reconciled where they exist: the prop decides
whether a view exists, not whether the code is authoritative about what it grants.
Written test-first. The new upgrade scenario fails before the change with
ReadAccountsBasic still carrying the 74-permission generic set -- including
can_see_transaction_amount and can_see_other_account_iban on a view meant to
expose four account fields. The scenario that was already there cannot catch
this: afterEach drops every ViewDefinition, so it only ever exercises the create
path.
MappedViewsTest 7/7, full local suite 3378/0 across all four shards.
Known gap, not closed here: the two Berlin Group views' real state on a
long-lived database is not established. One development database has
ReadAccountsBerlinGroup carrying 176 distinct permissions accumulated across
three separate dates, which is neither the generic set nor the target. The tests
cover create-fresh and upgrade-from-the-generic-set; upgrading from that third
shape is untested.
0 commit comments