https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Bug ID: 44052 Summary: Only expose library group settings to users who can manage libraries Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: tomascohen@gmail.com CC: tomascohen@gmail.com Target Milestone: --- Bug 42625 lets library groups be embedded in the record sources API (x-koha-embed: library_groups). The embedded group is the full library group, including the settings that control access elsewhere in Koha: hide_patron_info, limit_item_editing, limit_report_access, and the search, hold and float group flags. The administration page that shows these settings (admin/library_groups.pl), and GET /api/v1/library_groups since Bug 38291, require the manage_libraries permission. The embed does not, so a staff user who is only allowed to manage record sources can read the access control configuration of every group linked to a record source. Library groups should only expose their settings to users who can manage libraries. For everybody else only library_group_id, title and description are returned, and the other attributes are left out of the response (they are not returned as null, which could be read as false). This is done on Koha::Library::Group itself, using the is_accessible hook that Koha::Object->to_api already applies to embedded objects, so it covers every place a library group is rendered by the REST API, now and in the future, without any per route code. Test plan: 1. Apply the patches, run yarn api:bundle and restart Plack 2. Administration > Library groups: create a group "Hidden" with "Use for record source editing" and "Limit patron data access by group" checked 3. Administration > Record sources: create a record source, select "Hidden" under "Editable by library groups" and save 4. Create a staff user who is not a superlibrarian, with only the catalogue permission and Parameters > manage_record_sources 5. As that user, request /api/v1/record_sources?_per_page=-1 and note the library_groups of the record source (the request needs the x-koha-embed: library_groups header, which a browser cannot send: use curl or run the unit tests) => Only library_group_id, title and description are returned for the group 6. Give the user Parameters > manage_libraries and repeat => The full group, including hide_patron_info, is returned 7. Run: prove t/db_dependent/Koha/Library/Group.t t/db_dependent/api/v1/record_sources.t => Tests pass -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.