Bug 29523: Add redaction for inaccessible objects
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 31 Aug 2023 12:13:54 +0000 (14:13 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 27 Oct 2023 19:40:46 +0000 (16:40 -0300)
commited6791d64e536d2884611d17e57bfa2d20e65ee1
tree858c6bfbb958a016cf4969b5753399753d75ae46
parentaa3b7fb50d5fe48d7313adba974dd8dfc3d6462a
Bug 29523: Add redaction for inaccessible objects

This patch switches from removing inaccessible items from the responses
to instead redacting fields in innaccessible responses.

This allows for embed traversal and keeps counts etc correct but also
hides the data we want to hide.

We add support for an 'unredact_list' method at the Koha::* class level
allowing for individual classes to specify which fields they wish to
expose to restricted users regardless of their restriction.

It is to be used in combination with the is_accessible method introduced
earlier in this patchset which is used to denote whether the current
user should be allowed to see the full record or only a subset of it as
defined in the unredacted_list.

We undefine any fields not listed in the unredact_list for the API
response. This has the effect of still returning the full object of
keys, but setting most fields to a JSON null.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Object.pm
Koha/Patron.pm
t/db_dependent/Koha/Object.t