[elbe-devel] [PATCH 2/7] soap authentication: support 6 arguments in @authenticated_admin decorator

Torben Hohn torben.hohn at linutronix.de
Fri Apr 13 14:43:11 CEST 2018


Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/daemons/soap/authentication.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/elbepack/daemons/soap/authentication.py b/elbepack/daemons/soap/authentication.py
index 787cab3c..051bc09c 100644
--- a/elbepack/daemons/soap/authentication.py
+++ b/elbepack/daemons/soap/authentication.py
@@ -155,6 +155,19 @@ def authenticated_admin(func):
                 raise SoapElbeNotAuthorized()
             return func(self, arg1, arg2)
         return wrapped
+    elif func.__code__.co_argcount == 6:
+        @wraps(func)
+        def wrapped(self, arg1, arg2, arg3, arg4, arg5):
+            s = self.transport.req_env['beaker.session']
+            try:
+                uid = s['userid']
+            except KeyError:
+                raise SoapElbeNotLoggedIn()
+
+            if not self.app.pm.db.is_admin(uid):
+                raise SoapElbeNotAuthorized()
+            return func(self, arg1, arg2, arg3, arg4, arg5)
+        return wrapped
     else:
         raise Exception(
             "arg count %d not implemented" %
-- 
2.11.0




More information about the elbe-devel mailing list