From bb7a428f28125000b7161b7bfec0b977993233b5 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Fri, 11 Mar 2022 13:46:59 +0100 Subject: [PATCH] Bug 30279: Log viewing of personal data in staff client Add possiblilty to log when personal data is viewed by staff in the web interface. To test: 1) Enable the system preference "PatronViewLog" 2) Visit any page where the patron-info sidebar is displayed 3) Verify that an log entry has been created for module "MEMBERS" and action "VIEW" in the action_logs table 4) Disable the system preference and perform step 2) again 5) Verify that no new log entries for the above module and action has been created Sponsored-by: Gothenburg University Library --- Koha/Template/Plugin/ViewLog.pm | 43 +++++++++++++++++++ .../atomicupdate/bug-30279-log-patron-view.pl | 12 ++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/includes/circ-menu.inc | 2 + .../en/modules/admin/preferences/logs.pref | 7 ++- 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Koha/Template/Plugin/ViewLog.pm create mode 100755 installer/data/mysql/atomicupdate/bug-30279-log-patron-view.pl diff --git a/Koha/Template/Plugin/ViewLog.pm b/Koha/Template/Plugin/ViewLog.pm new file mode 100644 index 0000000000..c29c2c077d --- /dev/null +++ b/Koha/Template/Plugin/ViewLog.pm @@ -0,0 +1,43 @@ +package Koha::Template::Plugin::ViewLog; + +=head1 NAME + +Koha::Template::Plugin::ViewLog - A module for logging when a particular template is rendered and viewed by staff. + +=head1 DESCRIPTION + +This plugin contains methods to log when sensitive information is viewed by staff in order to mitigate or aid in +investigating GDPR personal data breach incidents. + +=head2 Methods + +=head3 log_patron_view + +[% Desks.log_patron_view(borrowernumber) %] + +Writes to action log that a patron with C has been viewd by the current user. + +=cut + +use Modern::Perl; +use C4::Context; +use C4::Log qw( logaction ); + +use Template::Plugin; +use base qw( Template::Plugin ); + +sub log_patron_view { + my ($self, $patron_borrowernumber ) = @_; + if (C4::Context->preference('PatronViewLog')) { + my $ip = $ENV{REMOTE_ADDR}; + my $uri = $ENV{REQUEST_URI}; + logaction( + 'MEMBERS', + 'VIEW', + $patron_borrowernumber, + "borrowernumber: $patron_borrowernumber, ip: $ip, uri: $uri" + ); + } +}; + +1; diff --git a/installer/data/mysql/atomicupdate/bug-30279-log-patron-view.pl b/installer/data/mysql/atomicupdate/bug-30279-log-patron-view.pl new file mode 100755 index 0000000000..1c1061c8b7 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-30279-log-patron-view.pl @@ -0,0 +1,12 @@ +use Modern::Perl; + +return { + bug_number => "30279", + description => "Add' PatronViewLog' system preference", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('PatronViewLog', '0', NULL, 'If enabled, log when patron personal data is viewed in staff interface', 'YesNo') }); + say $out "System preference added"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 94e2463434..a4404e7258 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -527,6 +527,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'), ('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate their account.','YesNo'), ('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'), +('PatronViewLog','0',NULL,'If enabled, log when patron personal data is viewed in staff interface','YesNo'), ('PatronQuickAddFields', '', NULL , 'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry', 'Free' ), ('PhoneNotification','0',NULL,'If ON, enables generation of phone notifications to be sent by plugins','YesNo'), ('PrefillGuaranteeField', 'phone,email,streetnumber,address,city,state,zipcode,country', NULL, 'Prefill these fields in guarantee member entry form from guarantor patron record', 'Multiple'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index 926008ed94..4b71e8a698 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -1,7 +1,9 @@ [% USE Koha %] [% USE KohaDates %] +[% USE ViewLog %] [% PROCESS 'member-display-address-style.inc' %] [% IF ( patron.borrowernumber ) %] +[% ViewLog.log_patron_view(patron.borrowernumber) %] [% SET patron_is_staff = patron.has_permission({ 'catalogue' => 1 }) %] [% SET patron_is_superlibrarian = patron.is_superlibrarian %] [% SET patron_type_class = 'is-not-staff' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref index ba4dcbed7e..d0812a6934 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref @@ -114,7 +114,12 @@ Logging: 1: Log 0: "Don't log" - any actions on recalls (create, cancel, expire, fulfill). - + - + - pref: PatronViewLog + choices: + 1: Log + 0: "Don't log" + - " when patron personal information is viewed in the staff interface." Debugging: - - pref: DumpTemplateVarsIntranet -- 2.20.1