https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 --- Comment #3 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 211753 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211753&action=edit Bug 44052: Only expose library group settings to users who can manage libraries Library groups hold settings that control access elsewhere in Koha: hiding patron information, limiting item editing, limiting report access, and the search, hold and float groups. The library groups administration page, and GET /library_groups, need the manage_libraries permission to show them, but the library_groups embed of the record sources API (added by Bug 42625) returned the whole library group to anybody allowed to manage record sources. Koha::Library::Group now says that its settings are only accessible to those who can manage libraries, using the is_accessible method that Koha::Object->to_api applies to every object it renders, embedded ones included. For anybody else only library_group_id, title and description are returned. The other attributes are left out of the response, and not returned as null, which could be read as false. As it is done by the object, it applies wherever the REST API renders a library group, now or later, without any code in the routes. Without a user, for the code that renders the object by itself, nothing changes. To test: 1. Apply the patches, then run yarn api:bundle and restart_all 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. Log in as that user, open the record source in Administration > Record sources, and in the developer tools of the browser (Network tab) look at the response of the request to /api/v1/record_sources/<id> => SUCCESS: the library group has library_group_id, title and description, and nothing else 6. Log in as a superlibrarian, or give the user Parameters > Manage libraries (manage_libraries), and look at the same response => SUCCESS: the library group also has hide_patron_info (true) and the other settings 7. Run: prove t/db_dependent/Koha/Library/Group.t t/db_dependent/api/v1/record_sources.t t/db_dependent/api/v1/library_groups.t xt/api.t => SUCCESS: Tests pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Michelle Spinney <mspinney@clamsnet.org> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.