From 1ef49c9e1b44d8c001aeb8c9e17cc77a455d2408 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 2 Nov 2017 09:14:59 +0100 Subject: [PATCH] Added permission check for integtrations plugins. --- .../app/controllers/_integration/clearbit.coffee | 1 + .../app/controllers/_integration/exchange.coffee | 1 + .../app/controllers/_integration/icinga.coffee | 1 + .../app/controllers/_integration/idoit.coffee | 2 +- .../app/controllers/_integration/ldap.coffee | 1 + .../app/controllers/integrations.coffee | 14 ++++++++++++-- 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_integration/clearbit.coffee b/app/assets/javascripts/app/controllers/_integration/clearbit.coffee index e1c600150..4b05ecff2 100644 --- a/app/assets/javascripts/app/controllers/_integration/clearbit.coffee +++ b/app/assets/javascripts/app/controllers/_integration/clearbit.coffee @@ -157,6 +157,7 @@ App.Config.set( description: 'A powerfull service to get more information about your customers.' controller: Index state: State + permission: ['admin.integration.clearbit'] } 'NavBarIntegrations' ) diff --git a/app/assets/javascripts/app/controllers/_integration/exchange.coffee b/app/assets/javascripts/app/controllers/_integration/exchange.coffee index fd3d881b1..14f6a639a 100644 --- a/app/assets/javascripts/app/controllers/_integration/exchange.coffee +++ b/app/assets/javascripts/app/controllers/_integration/exchange.coffee @@ -535,6 +535,7 @@ App.Config.set( description: 'Exchange integration for contacts management.' controller: Index state: State + permission: ['admin.integration.exchange'] } 'NavBarIntegrations' ) diff --git a/app/assets/javascripts/app/controllers/_integration/icinga.coffee b/app/assets/javascripts/app/controllers/_integration/icinga.coffee index 6d6c4cf44..6788680df 100644 --- a/app/assets/javascripts/app/controllers/_integration/icinga.coffee +++ b/app/assets/javascripts/app/controllers/_integration/icinga.coffee @@ -26,6 +26,7 @@ App.Config.set( description: 'An open source monitoring tool.' controller: Index state: State + permission: ['admin.integration.icinga'] } 'NavBarIntegrations' ) diff --git a/app/assets/javascripts/app/controllers/_integration/idoit.coffee b/app/assets/javascripts/app/controllers/_integration/idoit.coffee index 724207069..d94d96503 100644 --- a/app/assets/javascripts/app/controllers/_integration/idoit.coffee +++ b/app/assets/javascripts/app/controllers/_integration/idoit.coffee @@ -3,7 +3,7 @@ class Index extends App.ControllerIntegrationBase featureName: 'i-doit' featureConfig: 'idoit_config' description: [ - ['This service allows you to connect i-doit objects with Zammad.'] + ['This service allows you to connect %s with %s.', 'i-doit', 'Zammad'] ] events: 'change .js-switch input': 'switch' diff --git a/app/assets/javascripts/app/controllers/_integration/ldap.coffee b/app/assets/javascripts/app/controllers/_integration/ldap.coffee index 83a61dc98..cd6312a68 100644 --- a/app/assets/javascripts/app/controllers/_integration/ldap.coffee +++ b/app/assets/javascripts/app/controllers/_integration/ldap.coffee @@ -587,6 +587,7 @@ App.Config.set( description: 'LDAP integration for user management.' controller: Index state: State + permission: ['admin.integration.ldap'] } 'NavBarIntegrations' ) diff --git a/app/assets/javascripts/app/controllers/integrations.coffee b/app/assets/javascripts/app/controllers/integrations.coffee index 5d419e068..b47bb5bf2 100644 --- a/app/assets/javascripts/app/controllers/integrations.coffee +++ b/app/assets/javascripts/app/controllers/integrations.coffee @@ -33,11 +33,21 @@ class Index extends App.ControllerSubContent render: => return if @initRender && @integration + @user = App.User.find(App.Session.get('id')) + @initRender = true integrations = [] for key, value of @integrationItems - value.key = key - integrations.push value + if !value.permission + value.key = key + integrations.push value + else + match = false + for permissionName in value.permission + if !match && @user.permission(permissionName) + match = true + value.key = key + integrations.push value integrations = _.sortBy(integrations, (item) -> return item.name) @html App.view('integration/index')( head: 'Integrations'