[Bug 44052] New: Only expose library group settings to users who can manage libraries
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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |42625 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42625 [Bug 42625] Allow records to be locked for editing based on library & group -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211287 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211287&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> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrew@bywatersolutions.com Depends on| |44051 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 [Bug 44051] Add a narrow library groups route for record source editing -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211287|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 --- Comment #2 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- 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 <noreply@anthropic.com> Signed-off-by: Michelle Spinney <mspinney@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA QA Contact|tomascohen@gmail.com |andrew@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211746|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
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.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org