Bug 32502 - Getting patrons/{patron_id} via REST API requires edit_borrowers permission
Summary: Getting patrons/{patron_id} via REST API requires edit_borrowers permission
Status: RESOLVED DUPLICATE of bug 30230
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Matt Blenkinsop
QA Contact: Kyle M Hall (khall)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-20 10:14 UTC by Emmi Takkinen
Modified: 2024-09-13 17:57 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 32502: Api call to patrons/{patron_id} permission change (1.30 KB, patch)
2022-12-21 17:00 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 32502: Api call to patrons/{patron_id} permission change (1.43 KB, patch)
2022-12-27 10:37 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 32502: Api call to patrons/{patron_id} permission change (1.48 KB, patch)
2023-02-10 19:13 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emmi Takkinen 2022-12-20 10:14:34 UTC
Staff without edit_borrowers permission can see patrons info in detail.pl or returns.pl, but not via REST API call GET patrons/{patron_id}. We should use permission view_borrower_infos_from_any_libraries here instead of edit_borrowers.
Comment 1 Matt Blenkinsop 2022-12-21 17:00:13 UTC
Created attachment 144783 [details] [review]
Bug 32502: Api call to patrons/{patron_id} permission change

The API permissions for GET patrons/{patron_id} required staff to have edit_borrowers permission rather than view_borrower_infos_from_any_libraries. This has now been changed to allow staff to access patrons through the API.

Test plan:
1) From a staff account that does not have edit_borrowers permission, make a request to patrons/{patron_id}
2) The request should be rejected
3) Apply patch
4) Repeat the request
5) The request should return the data for the patron requested
Comment 2 Frédéric Demians 2022-12-27 10:37:09 UTC
Created attachment 144845 [details] [review]
Bug 32502: Api call to patrons/{patron_id} permission change

The API permissions for GET patrons/{patron_id} required staff to have
edit_borrowers permission rather than
view_borrower_infos_from_any_libraries. This has now been changed to
allow staff to access patrons through the API.

Test plan:
1) From a staff account that does not have edit_borrowers permission,
   make a request to patrons/{patron_id}
2) The request should be rejected
3) Apply patch
4) Repeat the request
5) The request should return the data for the patron requested

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Comment 3 Kyle M Hall (khall) 2023-02-10 19:13:45 UTC
Created attachment 146512 [details] [review]
Bug 32502: Api call to patrons/{patron_id} permission change

The API permissions for GET patrons/{patron_id} required staff to have
edit_borrowers permission rather than
view_borrower_infos_from_any_libraries. This has now been changed to
allow staff to access patrons through the API.

Test plan:
1) From a staff account that does not have edit_borrowers permission,
   make a request to patrons/{patron_id}
2) The request should be rejected
3) Apply patch
4) Repeat the request
5) The request should return the data for the patron requested

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Tomás Cohen Arazi (tcohen) 2023-02-16 14:56:03 UTC
I'm not sure I agree with this patch.

Our permissions schema is obfuscated, but view_borrower_infos_from_any_libraries goes too far as well. We really need something like 'view_borrowers', and let Koha::Patrons->search_limited take care of which patrons can actually be seen.

Something like:

my $patron = Koha::Patrons->search_limited;

unless ($patron) {
    # return 404
}

return $patron->to_api;
Comment 5 David Cook 2023-08-31 23:19:23 UTC
(In reply to Tomás Cohen Arazi from comment #4)
> I'm not sure I agree with this patch.
> 
> Our permissions schema is obfuscated, but
> view_borrower_infos_from_any_libraries goes too far as well. We really need
> something like 'view_borrowers', and let Koha::Patrons->search_limited take
> care of which patrons can actually be seen.

+1
Comment 6 Martin Renvoize (ashimema) 2024-09-13 16:35:24 UTC
We have 'list_borrowers' now, that's the appropriate permission here
Comment 7 Martin Renvoize (ashimema) 2024-09-13 17:57:42 UTC
Resolved by bug 30230

*** This bug has been marked as a duplicate of bug 30230 ***