Module: check_mk
Branch: master
Commit: fed6243ed96d5689fe826ae65f7fea268cee257d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fed6243ed96d56…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Jan 14 15:09:23 2019 +0100
Unbreak web API... :-}
Change-Id: Ifd5b1c8adde09bfe1ca9fefd4e5a1a5927802724
---
cmk/gui/webapi.py | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/cmk/gui/webapi.py b/cmk/gui/webapi.py
index ab100cf..37c688b 100644
--- a/cmk/gui/webapi.py
+++ b/cmk/gui/webapi.py
@@ -116,16 +116,7 @@ def page_api():
if not config.wato_enabled:
raise MKUserError(None, _("WATO is disabled on this site."))
- config.user.need_permission("wato.use")
- config.user.need_permission("wato.api_allowed")
-
- action = html.request.var('action')
- api_call = api_call_collection_registry.get(action)
- if not api_call:
- raise MKUserError(None, "Unknown API action %s" %
html.attrencode(action))
-
- for permission in api_call.get("required_permissions", []):
- config.user.need_permission(permission)
+ api_call = _get_api_call()
# Initialize host and site attributes
watolib.init_wato_datastructures()
@@ -193,3 +184,15 @@ def page_api():
}
html.write(_FORMATTERS[html.output_format][1 if pretty_print else 0](response))
+
+
+def _get_api_call():
+ action = html.request.var('action')
+ for cls in api_call_collection_registry.values():
+ api_call = cls().get_api_calls().get(action)
+ if api_call:
+ for permission in ["wato.use", "wato.api_allowed"] + \
+ api_call.get("required_permissions", []):
+ config.user.need_permission(permission)
+ return api_call
+ raise MKUserError(None, "Unknown API action %s" % html.attrencode(action))