Bug 28759: limit accessibility for "Manage API keys"
authorPetro Vashchuk <stalkernoid@gmail.com>
Tue, 10 Aug 2021 15:08:53 +0000 (18:08 +0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 30 Sep 2021 07:19:02 +0000 (09:19 +0200)
commitfcb87024ad97c6a0a8be756aa6977c7bbd17839d
treea06e90ba9744495522a0a2a464cf7ed9d6dc5321
parentc9ad6e004bf85cab3aae496266a4d5fefc8d14be
Bug 28759: limit accessibility for "Manage API keys"

This patch limits the accessibility for "Manage API keys" section only
to superlibrarians and the owner of that said API key account.

The way it does it is by checking if user is superlibrarian or if
logged-in user is the same as a patron id/borrower number is the same
as logged-in user number both in template and apikeys.pl and making sure
the link is inaccessible or redirects to the 403 page if user tries to
go there directly.

To reproduce:
1) create/pick existing patron, set Staff access, allows viewing
of catalogue in staff interface (catalogue)" and "Add, modify and
iew patron information (borrowers)" permissions on;
2) enable "RESTOAuth2ClientCredentials" in sysprefs;
3) login with that user into staff interface;
4) check any other patron, go to the "More"->"Manage API keys" and
check that you can see, add delete their API keys;
5) apply patch;
6) with that same user try to access "Manage API keys" page again.
Ensure that you can't access that page of other patrons but can
access your own page and manage your own API keys.
7) log in with superlibrarian now and ensure that you can access every
"Manage API keys" page of every patron and apply changes there.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
members/apikeys.pl