[elbe-devel] [PATCH v2 02/10] soap authentication: support 6 arguments in @authenticated_admin decorator
Torben Hohn
torben.hohn at linutronix.de
Tue Apr 17 12:39:33 CEST 2018
The docorators have an implemetation for for each number of arguments.
When we want to decorate a function with 6 arguments, we need an
implementation there.
This is a preparation for the add_user command.
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