https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052

--- Comment #2 from Andrew Fuerste-Henry <[email protected]> ---
Created attachment 211746
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211746&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 <[email protected]>

Signed-off-by: Michelle Spinney <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to