Bug 10190: (QA follow-up): fix: permissions

Important note: the following assumes manage_circ_triggers is intended
as a sibling to manage_circ_rules, and that of the two, only
manage_circ_triggers ought to grant access to client-side circulation
trigger configuration actions.

When manage_circ_triggers was introduced, it was not applied client-side,
resulting in the router and menu permission checks incorrectly expecting
manage_circ_rules. Amend that.

Additionally, while the API endpoint blocked a user with only
manage_circ_triggers from editing non-triggers circulation rules,
it did not block a user with only manage_circ_rules from editing
trigger circulation rules. Add a guard clause.

Test plan (based on comment 872):
A) Go to a patron's 'More' > 'Set permissions' tab. Check 'catalogue' (needed for basic staff login), and under circulation-rules sub-permissions, check only 'Manage overdue notice triggers' - leave 'Manage circulation rules' unchecked.
B) Log in as that patron, go to 'Administration' - 'Circulation triggers' link present (admin-home.tt now correctly checks CAN_user_parameters_manage_circ_triggers), 'Circulation and fine rules' is not present.
C) Visit http://localhost:8081/cgi-bin/koha/admin/circulation_triggers directly - you are granted access.
D) Confirm that you can create and edit circulation triggers.
E) Go to a patron's 'More' > 'Set permissions' tab. Check 'catalogue' (needed for basic staff login), and under circulation-rules sub-permissions, check only 'Manage circulation rules' - leave 'Manage overdue notice triggers' unchecked.
F) Log in as that patron, go to 'Administration' - no 'Circulation triggers' link present (as we require manage_circ_triggers), however 'Circulation and fine rules' is present.
G) Visit http://localhost:8081/cgi-bin/koha/admin/circulation_triggers directly - you see "Error: You do not have permission to access this page" and are prompted to log in as a different user (as we require manage_circ_triggers).
H) Go to http://localhost:8081/cgi-bin/koha/admin/smart-rules.pl, and confirm that you can edit circulation rules for your library (no regression).

Assisted-by: Claude Opus 5 (Anthropic)
Sponsored-by: Glasgow Colleges Library Group <https://library.cityofglasgowcollege.ac.uk>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Chloé Zermatten 2026-09-03 09:02:02 +00:00 committed by Pedro Amorim
parent a4be8b914e
commit ec22f77b76
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
3 changed files with 18 additions and 3 deletions

View File

@ -271,6 +271,21 @@ sub set_rules {
}
}
unless ( haspermission( $logged_in_user->userid, { parameters => 'manage_circ_triggers' } )
|| haspermission( $logged_in_user->userid, { circulate => 'circulate_remaining_permissions' } ) )
{
my @trigger_rules = grep { /^overdue_/ } keys %{$body};
if (@trigger_rules) {
return $c->render(
status => 403,
openapi => {
error =>
'the manage_circ_triggers or circulate_remaining_permissions permission is required to manage circulation triggers'
}
);
}
}
if ( $patron_category eq '*' ) {
$patron_category = undef;
} else {

View File

@ -85,7 +85,7 @@
</dl>
[% END %]
[% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities || CAN_user_parameters_manage_curbside_pickups ) %]
[% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_circ_triggers || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities || CAN_user_parameters_manage_curbside_pickups ) %]
<h3>Patrons and circulation</h3>
<dl>
[% IF ( CAN_user_parameters_manage_patron_categories ) %]
@ -96,7 +96,7 @@
<dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fine rules</a></dt>
<dd>Define circulation and fine rules for combinations of libraries, patron categories, and item types</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_circ_rules ) %]
[% IF ( CAN_user_parameters_manage_circ_triggers ) %]
<dt><a href="/cgi-bin/koha/admin/circulation_triggers">Circulation triggers</a></dt>
<dd>Define triggers for circulation notices</dd>
[% END %]

View File

@ -57,7 +57,7 @@ router.beforeEach((to, from, next) => {
.then(() => {
if (
!circRulesStore.isUserPermitted(
"CAN_user_parameters_manage_circ_rules"
"CAN_user_parameters_manage_circ_triggers"
)
) {
navigationStore.$patch({