Module: check_mk
Branch: master
Commit: 0c346794205b3f5fbec313e55935aa325763bf6e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0c346794205b3f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Sep 2 12:58:38 2014 +0200
#1392 WATO Folder filter: show only the paths a user is allowed to see
---
.werks/1392 | 9 +++++++++
ChangeLog | 1 +
web/plugins/views/wato.py | 19 ++++++++++++++++++-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.werks/1392 b/.werks/1392
new file mode 100644
index 0000000..54eca8f
--- /dev/null
+++ b/.werks/1392
@@ -0,0 +1,9 @@
+Title: WATO Folder filter: show only the paths a user is allowed to see
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.5i6
+Date: 1409655497
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index cf3a8c9..5220e10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,7 @@
Multisite:
* 1066 Implemented Dashboard Designer...
+ * 1392 WATO Folder filter: show only the paths a user is allowed to see
* 1067 FIX: Fixed login problem in LDAP connector when no user filter specified...
* 1094 FIX: sidebar snaping 'Tree of folders': fixed exception
* 1154 FIX: Availability: Fixed unwanted redirect to edit annotation page after
editing availability options...
diff --git a/web/plugins/views/wato.py b/web/plugins/views/wato.py
index 023f51f..bcc414d 100644
--- a/web/plugins/views/wato.py
+++ b/web/plugins/views/wato.py
@@ -47,7 +47,24 @@ class FilterWatoFile(Filter):
def display(self):
self.check_wato_data_update()
- html.select(self.name, [("", "")] + self.selection)
+ # Note: WATO Folders that the user has not permissions to must not be visible.
+ # Permissions in this case means, that the user has view permissions for at
+ # least one host in that folder.
+ result = html.live.query("GET hosts\nCache: reload\nColumns:
filename\nStats: state >= 0\n")
+ allowed_folders = set([""])
+ for path, host_count in result:
+ # convert '/wato/server/hosts.mk' to 'server'
+ folder = path[6:-9]
+ # allow the folder an all of its parents
+ parts = folder.split("/")
+ subfolder = ""
+ for part in parts:
+ if subfolder:
+ subfolder += "/"
+ subfolder += part
+ allowed_folders.add(subfolder)
+
+ html.select(self.name, [("", "")] + [ entry for entry in
self.selection if (entry[0] in allowed_folders) ])
def filter(self, infoname):
self.check_wato_data_update()