[Bug 44051] New: Add a narrow library groups route for record source editing
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 Bug ID: 44051 Summary: Add a narrow library groups route for record source editing Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement 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 adds a selector to the record source form that lists the library groups flagged for record source editing. It gets them from GET /api/v1/library_groups, which Bug 38291 restricts to the manage_libraries permission because it returns the full library group configuration, including the policy flags (hide patron info, limit item editing, limit report access). A user who is allowed to manage record sources but not libraries therefore gets a 403 and an empty selector. Add GET /api/v1/record_source_editing_groups, authorized by manage_record_sources: - it only lists the groups flagged for record source editing - it only returns library_group_id, title and description - q, _order_by, _match and paging work on those fields. Filtering or sorting on anything else is rejected with invalid_query, however the field is spelled, so the policy flags cannot be read or probed through it The controller keeps the flag column and the allowed fields of each feature in one table, so other features that let users pick a library group can add a route with their own permission. Test plan: 1. Apply the patches, run yarn api:bundle and yarn js:build, then restart Plack 2. Administration > Library groups: create a group with "Use for record source editing" checked, and another without it 3. Create a staff user who is not a superlibrarian, with the catalogue permission and Parameters > manage_record_sources 4. As that user, Administration > Record sources > New record source => The "Editable by library groups" selector lists only the first group 5. As the same user, request /api/v1/record_source_editing_groups?_order_by=hide_patron_info, then /api/v1/library_groups => 400 invalid_query, then 403 -- 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=44051 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211263 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211263&action=edit Bug 44051: Add a narrow library groups route for record source editing The record source form added by Bug 42625 lists the library groups flagged for record source editing. It gets them from GET /library_groups, which Bug 38291 restricts to manage_libraries as it returns the full group configuration, including the policy flags (hide patron info, limit item editing, limit report access). A user allowed to manage record sources but not libraries gets a 403 and an empty selector. Add GET /record_source_editing_groups, authorized by manage_record_sources, which: - only lists the groups flagged for record source editing - only returns library_group_id, title and description - accepts q, _order_by, _match and paging for the fields it returns (library_group_id, title, description) and rejects anything else with invalid_query, however the field is spelled (API or DB name, me. prefix, relationship, nested in -or, request body), so the policy flags cannot be read by filtering or sorting on them The controller keeps the per feature column and allowed fields in one table, so other features that need to pick a library group can add a route with their own permission. The JS LibraryGroupsAPIClient gets a matching table of feature routes, used by the record source selector. To test: 1. Apply the patches, run yarn api:bundle and yarn js:build, restart_all 2. prove t/db_dependent/api/v1/record_source_editing_groups.t t/db_dependent/api/v1/library_groups.t t/db_dependent/api/v1/record_sources.t xt/api.t => SUCCESS: Tests pass 3. Create a staff user without the superlibrarian flag, with only the catalogue permission and Parameters > manage_record_sources 4. Administration > Library groups: create a group with "Use for record source editing" checked and another without 5. As the user from step 3, Administration > Record sources > New record source => SUCCESS: "Editable by library groups" lists only the first group 6. As the same user, in the browser console or with curl, request /api/v1/record_source_editing_groups?_order_by=hide_patron_info and /api/v1/library_groups => SUCCESS: 400 invalid_query, and 403 7. Run the Cypress spec t/cypress/integration/Admin/RecordSources_spec.ts => SUCCESS: Tests pass Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.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=44051 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |42625 Status|NEW |Needs Signoff 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 the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 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=44051 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=44054 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 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=44051 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211263|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=44051 --- Comment #2 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 211286 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211286&action=edit Bug 44051: Add a narrow library groups route for record source editing The record source form added by Bug 42625 lists the library groups flagged for record source editing. It gets them from GET /library_groups, which Bug 38291 restricts to manage_libraries as it returns the full group configuration, including the policy flags (hide patron info, limit item editing, limit report access). A user allowed to manage record sources but not libraries gets a 403 and an empty selector. Add GET /record_source_editing_groups, authorized by manage_record_sources, which: - only lists the groups flagged for record source editing - only returns library_group_id, title and description - accepts q, _order_by, _match and paging for the fields it returns (library_group_id, title, description) and rejects anything else with invalid_query, however the field is spelled (API or DB name, me. prefix, relationship, nested in -or, request body), so the policy flags cannot be read by filtering or sorting on them The controller keeps the per feature column and allowed fields in one table, so other features that need to pick a library group can add a route with their own permission. The JS LibraryGroupsAPIClient gets a matching table of feature routes, used by the record source selector. To test: 1. Apply the patches, run yarn api:bundle and yarn js:build, restart_all 2. prove t/db_dependent/api/v1/record_source_editing_groups.t t/db_dependent/api/v1/library_groups.t t/db_dependent/api/v1/record_sources.t xt/api.t => SUCCESS: Tests pass 3. Create a staff user without the superlibrarian flag, with only the catalogue permission and Parameters > manage_record_sources 4. Administration > Library groups: create a group with "Use for record source editing" checked and another without 5. As the user from step 3, Administration > Record sources > New record source => SUCCESS: "Editable by library groups" lists only the first group 6. As the same user, in the browser console or with curl, request /api/v1/record_source_editing_groups?_order_by=hide_patron_info and /api/v1/library_groups => SUCCESS: 400 invalid_query, and 403 7. Run the Cypress spec t/cypress/integration/Admin/RecordSources_spec.ts => SUCCESS: Tests pass Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> 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=44051 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44052 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44052 [Bug 44052] Only expose library group settings to users who can manage libraries -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA CC| |andrew@bywatersolutions.com --- Comment #3 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Confirmed this issue pointed out by Claude: LibraryGroupFeatures.pm:21: any search containing a non-ASCII character is rejected. - Problem: the code parses the search with Mojo::JSON::decode_json. That function expects raw bytes, but $c->req->params has already decoded them. So a search like ?q={"title":{"like":"%Bibliothèque%"}} fails with 400 “The q parameter is not valid JSON”. The review agent reproduced this in KTD. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211745 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211745&action=edit Bug 44051: (QA follow-up) Accept non-ASCII characters in the q parameter The q validation parsed the search with Mojo::JSON::decode_json, which expects UTF-8 bytes. Mojolicious has already decoded the query parameter into characters, so any search containing a non-ASCII character, such as {"title":{"like":"%Bibliothèque%"}}, was rejected with 400 "The q parameter is not valid JSON". Use from_json, which takes characters, and add a test with a non-ASCII title. To test: 1. Apply the patches, restart_all 2. prove t/db_dependent/api/v1/record_source_editing_groups.t => Success 3. Create a library group flagged for record source editing with the title "Bibliothèque municipale" 4. As a user with manage_record_sources, request /api/v1/record_source_editing_groups?q={"title":{"like":"%Biblioth%C3%A8que%"}} => 200 with the matching group, not 400 invalid JSON Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 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=44051 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|tomascohen@gmail.com |andrew@bywatersolutions.com Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211286|0 |1 is obsolete| | Attachment #211745|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=44051 --- Comment #5 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 211747 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211747&action=edit Bug 44051: Add a narrow library groups route for record source editing The record source form added by Bug 42625 lists the library groups flagged for record source editing. It gets them from GET /library_groups, which Bug 38291 restricts to manage_libraries as it returns the full group configuration, including the policy flags (hide patron info, limit item editing, limit report access). A user allowed to manage record sources but not libraries gets a 403 and an empty selector. Add GET /record_source_editing_groups, authorized by manage_record_sources, which: - only lists the groups flagged for record source editing - only returns library_group_id, title and description - accepts q, _order_by, _match and paging for the fields it returns (library_group_id, title, description) and rejects anything else with invalid_query, however the field is spelled (API or DB name, me. prefix, relationship, nested in -or, request body), so the policy flags cannot be read by filtering or sorting on them The controller keeps the per feature column and allowed fields in one table, so other features that need to pick a library group can add a route with their own permission. The JS LibraryGroupsAPIClient gets a matching table of feature routes, used by the record source selector. To test: 1. Apply the patches, run yarn api:bundle and yarn js:build, restart_all 2. prove t/db_dependent/api/v1/record_source_editing_groups.t t/db_dependent/api/v1/library_groups.t t/db_dependent/api/v1/record_sources.t xt/api.t => SUCCESS: Tests pass 3. Create a staff user without the superlibrarian flag, with only the catalogue permission and Parameters > manage_record_sources 4. Administration > Library groups: create a group with "Use for record source editing" checked and another without 5. As the user from step 3, Administration > Record sources > New record source => SUCCESS: "Editable by library groups" lists only the first group 6. As the same user, in the browser console or with curl, request /api/v1/record_source_editing_groups?_order_by=hide_patron_info and /api/v1/library_groups => SUCCESS: 400 invalid_query, and 403 7. Run the Cypress spec t/cypress/integration/Admin/RecordSources_spec.ts => SUCCESS: Tests pass Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 --- Comment #6 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 211748 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211748&action=edit Bug 44051: (QA follow-up) Accept non-ASCII characters in the q parameter The q validation parsed the search with Mojo::JSON::decode_json, which expects UTF-8 bytes. Mojolicious has already decoded the query parameter into characters, so any search containing a non-ASCII character, such as {"title":{"like":"%Bibliothèque%"}}, was rejected with 400 "The q parameter is not valid JSON". Use from_json, which takes characters, and add a test with a non-ASCII title. To test: 1. Apply the patches, restart_all 2. prove t/db_dependent/api/v1/record_source_editing_groups.t => Success 3. Create a library group flagged for record source editing with the title "Bibliothèque municipale" 4. As a user with manage_record_sources, request /api/v1/record_source_editing_groups?q={"title":{"like":"%Biblioth%C3%A8que%"}} => 200 with the matching group, not 400 invalid JSON Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> 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