Bug 28759: limit accessibility for "Manage API keys"
authorPetro Vashchuk <stalkernoid@gmail.com>
Tue, 10 Aug 2021 15:08:53 +0000 (18:08 +0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Wed, 15 Sep 2021 14:46:24 +0000 (10:46 -0400)
commit921e3ac50fb4e3411bb4122c830cf0e874dc24bb
treea28dc0020ea669920493f4f9929c664208abb8e4
parentb1a25e45c0ffbf2897639e5f02f8b3233dd0b9f1
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: Kyle M Hall <kyle@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
members/apikeys.pl