Bugzilla – Attachment 147466 Details for
Bug 32968
Create granular permissions for ERM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32968: (WIP) Create granular permissions for ERM
Bug-32968-WIP-Create-granular-permissions-for-ERM.patch (text/plain), 14.17 KB, created by
Pedro Amorim
on 2023-02-27 19:09:52 UTC
(
hide
)
Description:
Bug 32968: (WIP) Create granular permissions for ERM
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-02-27 19:09:52 UTC
Size:
14.17 KB
patch
obsolete
>From 3cbfbaf62b77bdc70fba178250d017c85d3590ef Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Mon, 27 Feb 2023 19:09:13 +0000 >Subject: [PATCH] Bug 32968: \(WIP\) Create granular permissions for ERM > >--- > Koha/REST/V1/ERM.pm | 2 +- > api/v1/swagger/paths/erm_agreements.yaml | 24 +++++++++++--- > api/v1/swagger/paths/erm_licenses.yaml | 24 +++++++++++--- > erm/erm.pl | 2 +- > .../data/mysql/atomicupdate/bug_32968.pl | 30 ++++++++++++++++++ > .../data/mysql/mandatory/userpermissions.sql | 8 ++++- > .../prog/en/includes/permissions.inc | 31 +++++++++++++++++++ > .../intranet-tmpl/prog/en/modules/erm/erm.tt | 8 +++++ > .../js/vue/components/ERM/AgreementsList.vue | 15 ++++++--- > .../prog/js/vue/components/ERM/Main.vue | 9 +++++- > .../intranet-tmpl/prog/js/vue/modules/erm.ts | 3 ++ > 11 files changed, 137 insertions(+), 19 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_32968.pl > >diff --git a/Koha/REST/V1/ERM.pm b/Koha/REST/V1/ERM.pm >index 3f98a8e12d..3d398f6618 100644 >--- a/Koha/REST/V1/ERM.pm >+++ b/Koha/REST/V1/ERM.pm >@@ -42,7 +42,7 @@ sub list_users { > > return try { > >- my $patrons_rs = Koha::Patrons->search->filter_by_have_permission('erm'); >+ my $patrons_rs = Koha::Patrons->search->filter_by_have_permission('erm'); #TODO: Double-check that related users are working > my $patrons = $c->objects->search( $patrons_rs ); > > return $c->render( >diff --git a/api/v1/swagger/paths/erm_agreements.yaml b/api/v1/swagger/paths/erm_agreements.yaml >index 37233bdf37..9bd85871cf 100644 >--- a/api/v1/swagger/paths/erm_agreements.yaml >+++ b/api/v1/swagger/paths/erm_agreements.yaml >@@ -93,7 +93,11 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_show >+ - erm_agreement >+ - erm_eholdings > post: > x-mojo-to: ERM::Agreements#add > operationId: addErmAgreements >@@ -153,7 +157,9 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_agreement > "/erm/agreements/{agreement_id}": > get: > x-mojo-to: ERM::Agreements#get >@@ -216,7 +222,11 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_show >+ - erm_agreement >+ - erm_eholdings > put: > x-mojo-to: ERM::Agreements#update > operationId: updateErmAgreements >@@ -287,7 +297,9 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_agreement > delete: > x-mojo-to: ERM::Agreements#delete > operationId: deleteErmAgreements >@@ -333,4 +345,6 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_agreement >diff --git a/api/v1/swagger/paths/erm_licenses.yaml b/api/v1/swagger/paths/erm_licenses.yaml >index 0abc7cf424..988f0deebf 100644 >--- a/api/v1/swagger/paths/erm_licenses.yaml >+++ b/api/v1/swagger/paths/erm_licenses.yaml >@@ -78,7 +78,11 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_show >+ - erm_licensing >+ - erm_agreement > post: > x-mojo-to: ERM::Licenses#add > operationId: addERMLicenses >@@ -138,7 +142,9 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_licensing > "/erm/licenses/{license_id}": > get: > x-mojo-to: ERM::Licenses#get >@@ -193,7 +199,11 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_show >+ - erm_licensing >+ - erm_agreement > put: > x-mojo-to: ERM::Licenses#update > operationId: updateERMlicenses >@@ -261,7 +271,9 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_licensing > delete: > x-mojo-to: ERM::Licenses#delete > operationId: deleteERMlicenses >@@ -307,4 +319,6 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- erm: 1 >+ erm: >+ - erm_admin >+ - erm_licensing >diff --git a/erm/erm.pl b/erm/erm.pl >index df841c98bd..896d73e6c5 100755 >--- a/erm/erm.pl >+++ b/erm/erm.pl >@@ -32,7 +32,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > template_name => "erm/erm.tt", > query => $input, > type => "intranet", >- flagsrequired => { 'erm' => '1' }, >+ flagsrequired => { 'erm' => '*' }, > } > ); > >diff --git a/installer/data/mysql/atomicupdate/bug_32968.pl b/installer/data/mysql/atomicupdate/bug_32968.pl >new file mode 100644 >index 0000000000..1d06cf827d >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_32968.pl >@@ -0,0 +1,30 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "32968", >+ description => "Create granular permissions for ERM", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ >+ $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (28, 'erm_admin', 'Create, edit and delete all ERM related content') }); >+ say $out "Added new permission 'erm_admin'"; >+ >+ $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (28, 'erm_show', 'Read-only permission for all ERM related content') }); >+ say $out "Added new permission 'erm_show'"; >+ >+ $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (28, 'erm_licensing', 'Create, edit and delete licenses') }); >+ say $out "Added new permission 'erm_licensing'"; >+ >+ $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (28, 'erm_agreement', 'Create, edit and delete agreements') }); >+ say $out "Added new permission 'erm_agreement'"; >+ >+ $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (28, 'erm_eholdings', 'Create, edit and delete EHoldings local titles and local packages') }); >+ say $out "Added new permission 'erm_eholdings'"; >+ >+ $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (28, 'erm_ebsco', 'Create, edit and delete EHoldings provided by EBSCO') }); >+ say $out "Added new permission 'erm_ebsco'"; >+ >+ }, >+}; >\ No newline at end of file >diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql >index 7b6955de44..3158009822 100644 >--- a/installer/data/mysql/mandatory/userpermissions.sql >+++ b/installer/data/mysql/mandatory/userpermissions.sql >@@ -148,5 +148,11 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (25, 'cashup', 'Perform cash register cashup action'), > (25, 'takepayment', 'Access the point of sale page and take payments'), > (26, 'manage_problem_reports', 'Manage OPAC problem reports'), >- (27, 'manage_recalls', 'Manage recalls for patrons') >+ (27, 'manage_recalls', 'Manage recalls for patrons'), >+ (28, 'erm_admin', 'Create, edit and delete all ERM related content'), >+ (28, 'erm_show', 'Read-only permission for all ERM related content'), >+ (28, 'erm_licensing', 'Create, edit and delete licenses'), >+ (28, 'erm_agreement', 'Create, edit and delete agreements'), >+ (28, 'erm_eholdings', 'Create, edit and delete EHoldings local titles and local packages'), >+ (28, 'erm_ebsco', 'Create, edit and delete EHoldings provided by EBSCO') > ; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >index a8bfd89e02..5807f0ca1d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >@@ -846,5 +846,36 @@ > Manage authentication providers > </span> > <span class="permissioncode">([% name | html %])</span> >+ [%# erm %] >+ [%- CASE 'erm_admin' -%] >+ <span class="sub_permission manage_agreements_subpermission"> >+ Create, edit and delete all ERM related content >+ </span> >+ <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'erm_show' -%] >+ <span class="sub_permission manage_licenses_subpermission"> >+ Read-only permission for all ERM related content >+ </span> >+ <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'erm_licensing' -%] >+ <span class="sub_permission manage_packages_subpermission"> >+ Create, edit and delete licenses >+ </span> >+ <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'erm_agreement' -%] >+ <span class="sub_permission manage_titles_subpermission"> >+ Create, edit and delete agreements >+ </span> >+ <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'erm_eholdings' -%] >+ <span class="sub_permission manage_providers_resources_subpermission"> >+ Create, edit and delete EHoldings local titles and local packages >+ </span> >+ <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'erm_ebsco' -%] >+ <span class="sub_permission manage_providers_resources_subpermission"> >+ Create, edit and delete EHoldings provided by EBSCO >+ </span> >+ <span class="permissioncode">([% name | html %])</span> > [%- END -%] > [%- END -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt >index 783d3a0329..b77e6e092c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt >@@ -60,6 +60,14 @@ > > const logged_in_user_lists = [% To.json(logged_in_user.virtualshelves.unblessed) | $raw %]; > >+ const permissions = { >+ admin: [% CAN_user_erm_erm_admin ? 1 : 0 %], >+ show: [% CAN_user_erm_erm_show ? 1 : 0 %], >+ licensing: [% CAN_user_erm_erm_licensing ? 1 : 0 %], >+ agreement: [% CAN_user_erm_erm_agreement ? 1 : 0 %], >+ eholdings: [% CAN_user_erm_erm_eholdings ? 1 : 0 %], >+ ebsco: [% CAN_user_erm_erm_ebsco ? 1 : 0 %] >+ } > </script> > > [% Asset.js("js/vue/dist/erm.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >index 9394f1c08d..b9c89dbb68 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >@@ -57,6 +57,7 @@ export default { > get_lib_from_av, > map_av_dt_filter, > table_id, >+ permissions, > } > }, > data: function () { >@@ -333,11 +334,15 @@ export default { > ] > ) > >- let n = createVNode("span", {}, [ >- editButton, >- " ", >- deleteButton, >- ]) >+ let n = >+ permissions.admin || >+ permissions.agreement >+ ? createVNode("span", {}, [ >+ editButton, >+ " ", >+ deleteButton, >+ ]) >+ : "" > render(n, e) > } > ) >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >index 57d43c9d54..608210d299 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >@@ -16,7 +16,13 @@ > <div id="navmenulist"> > <h5>{{ $__("E-resource management") }}</h5> > <ul> >- <li> >+ <li >+ v-if=" >+ permissions.admin || >+ permissions.agreement || >+ permissions.show >+ " >+ > > <router-link > to="/cgi-bin/koha/erm/agreements" > > >@@ -146,6 +152,7 @@ export default { > vendorStore, > erm_providers, > ERMModule, >+ permissions, > } > }, > data() { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts >index f136b3f4d3..c298ff3d1c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts >@@ -58,6 +58,9 @@ app.mount("#erm"); > > const { removeMessages } = mainStore; > router.beforeEach((to, from) => { >+ if(to.path == '/cgi-bin/koha/erm/agreements' && !permissions.admin && !permissions.agreement && !permissions.show){ >+ return { path: '/cgi-bin/koha/erm/erm.pl' } >+ } > removeMessages(); // This will actually flag the messages as displayed already > }); > router.afterEach((to, from) => { >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32968
:
146698
|
147466
|
147510
|
147511
|
147513
|
147514
|
147515
|
147516
|
147517
|
147518
|
147559
|
148797
|
148798
|
148799
|
148800
|
148801
|
148802
|
148803
|
148804
|
148959
|
148960
|
148961
|
148962
|
148963
|
148964
|
148965
|
148966
|
149423
|
149424
|
149425
|
149426
|
149427
|
149428
|
149429
|
149430
|
150060
|
150061
|
150062
|
150063
|
150064
|
150065
|
150066
|
150067