[elbe-devel] [PATCH 06/10] elbepack: soap: don't pass userid to soap methods

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Feb 28 14:59:17 CET 2025


The userid is not used anymore.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/daemons/soap/authentication.py |  33 +++++----
 elbepack/daemons/soap/esoap.py          | 116 ++++++++++++++++----------------
 2 files changed, 74 insertions(+), 75 deletions(-)

diff --git a/elbepack/daemons/soap/authentication.py b/elbepack/daemons/soap/authentication.py
index 7fe220a326a3340263fdbd27bec9d2b2225cb7eb..c14f5c96dc74120748579275f32dca7ac37e47bd 100644
--- a/elbepack/daemons/soap/authentication.py
+++ b/elbepack/daemons/soap/authentication.py
@@ -15,16 +15,15 @@ class SoapElbeNotLoggedIn(Fault):
                         'Cant let you perform this command.')
 
 
-def authenticated_uid(func):
-    """ decorator, which Checks, that the current session is logged in,
-        and also passes the current uid to the function
+def authenticated(func):
+    """ decorator, which Checks, that the current session is logged in.
 
         Allows for being wrapped in a soapmethod...
 
         Example:
             @soapmethod (String, _returns=Array(SoapFile))
-            @authenticated_uid
-            def get_files (self, uid, builddir):
+            @authenticated
+            def get_files (self, builddir):
     """
 
     # Do not edit this code.  Although using *args is tempting here,
@@ -38,66 +37,66 @@ def authenticated_uid(func):
         def wrapped(self):
             s = self.transport.req_env['beaker.session']
             try:
-                uid = s['userid']
+                s['userid']
             except KeyError:
                 raise SoapElbeNotLoggedIn()
 
-            return func(self, uid)
+            return func(self)
         return wrapped
     if func.__code__.co_argcount == 3:
         @wraps(func)
         def wrapped(self, arg1):
             s = self.transport.req_env['beaker.session']
             try:
-                uid = s['userid']
+                s['userid']
             except KeyError:
                 raise SoapElbeNotLoggedIn()
 
-            return func(self, uid, arg1)
+            return func(self, arg1)
         return wrapped
     if func.__code__.co_argcount == 4:
         @wraps(func)
         def wrapped(self, arg1, arg2):
             s = self.transport.req_env['beaker.session']
             try:
-                uid = s['userid']
+                s['userid']
             except KeyError:
                 raise SoapElbeNotLoggedIn()
 
-            return func(self, uid, arg1, arg2)
+            return func(self, arg1, arg2)
         return wrapped
     if func.__code__.co_argcount == 5:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3):
             s = self.transport.req_env['beaker.session']
             try:
-                uid = s['userid']
+                s['userid']
             except KeyError:
                 raise SoapElbeNotLoggedIn()
 
-            return func(self, uid, arg1, arg2, arg3)
+            return func(self, arg1, arg2, arg3)
         return wrapped
     if func.__code__.co_argcount == 6:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4):
             s = self.transport.req_env['beaker.session']
             try:
-                uid = s['userid']
+                s['userid']
             except KeyError:
                 raise SoapElbeNotLoggedIn()
 
-            return func(self, uid, arg1, arg2, arg3, arg4)
+            return func(self, arg1, arg2, arg3, arg4)
         return wrapped
     if func.__code__.co_argcount == 7:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4, arg5):
             s = self.transport.req_env['beaker.session']
             try:
-                uid = s['userid']
+                s['userid']
             except KeyError:
                 raise SoapElbeNotLoggedIn()
 
-            return func(self, uid, arg1, arg2, arg3, arg4, arg5)
+            return func(self, arg1, arg2, arg3, arg4, arg5)
         return wrapped
 
     raise Exception(f'arg count {func.__code__.co_argcount} not implemented')
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index 323fb4e9911da249989878591d1b3acd5248c113..7ec4e899a62c8313af9244545c25f5b93984bbf4 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -21,7 +21,7 @@ from elbepack.elbexml import ValidationError, ValidationMode
 from elbepack.projectmanager import InvalidState, ProjectManagerError
 from elbepack.version import elbe_version
 
-from .authentication import authenticated_uid
+from .authentication import authenticated
 from .datatypes import SoapFile, SoapProject
 
 
@@ -93,23 +93,23 @@ class ESoap (ServiceBase):
         return True
 
     @rpc(_returns=Array(SoapProject))
-    @authenticated_uid
-    def list_projects(self, uid):
+    @authenticated
+    def list_projects(self):
         return self.app.pm.db.list_projects()
 
     @rpc(String, _returns=SoapProject)
-    @authenticated_uid
-    def get_project(self, uid, builddir):
+    @authenticated
+    def get_project(self, builddir):
         return self.app.pm.db.get_project_data(builddir)
 
     @rpc(String, _returns=Array(SoapFile))
-    @authenticated_uid
-    def get_files(self, uid, builddir):
+    @authenticated
+    def get_files(self, builddir):
         files = self.app.pm.db.get_project_files(builddir)
         return files
 
     @rpc(String, String, String, Integer, _returns=Integer)
-    @authenticated_uid
+    @authenticated
     def upload_file(self, builddir, fname, blob, part):
 
         fn = os.path.join(builddir, fname)
@@ -138,44 +138,44 @@ class ESoap (ServiceBase):
         return part + 1
 
     @rpc(String)
-    @authenticated_uid
-    def build_chroot_tarball(self, uid, builddir):
+    @authenticated
+    def build_chroot_tarball(self, builddir):
         self.app.pm.build_chroot_tarball(builddir)
 
     @rpc(String)
-    @authenticated_uid
-    def build_sysroot(self, uid, builddir):
+    @authenticated
+    def build_sysroot(self, builddir):
         self.app.pm.build_sysroot(builddir)
 
     @rpc(String)
-    @authenticated_uid
-    def build_sdk(self, uid, builddir):
+    @authenticated
+    def build_sdk(self, builddir):
         self.app.pm.build_sdk(builddir)
 
     @rpc(String, Boolean, Boolean)
-    @authenticated_uid
-    def build_cdroms(self, uid, builddir, build_bin, build_src):
+    @authenticated
+    def build_cdroms(self, builddir, build_bin, build_src):
         self.app.pm.build_cdroms(builddir, build_bin, build_src)
 
     @rpc(String, Boolean, Boolean, Boolean)
-    @authenticated_uid
-    def build(self, uid, builddir, build_bin, build_src, skip_pbuilder):
+    @authenticated
+    def build(self, builddir, build_bin, build_src, skip_pbuilder):
 
         self.app.pm.build_project(builddir, build_bin, build_src, skip_pbuilder)
 
     @rpc(String, Boolean, Boolean, String)
-    @authenticated_uid
-    def build_pbuilder(self, uid, builddir, cross, noccache, ccachesize):
+    @authenticated
+    def build_pbuilder(self, builddir, cross, noccache, ccachesize):
         self.app.pm.build_pbuilder(builddir, cross, noccache, ccachesize)
 
     @rpc(String)
-    @authenticated_uid
-    def update_pbuilder(self, uid, builddir):
+    @authenticated
+    def update_pbuilder(self, builddir):
         self.app.pm.update_pbuilder(builddir)
 
     @rpc(String)
-    @authenticated_uid
-    def start_cdrom(self, uid, builddir):
+    @authenticated
+    def start_cdrom(self, builddir):
         cdrom_fname = os.path.join(builddir, 'uploaded_cdrom.iso')
 
         # Now write empty File
@@ -183,8 +183,8 @@ class ESoap (ServiceBase):
         fp.close()
 
     @rpc(String, String)
-    @authenticated_uid
-    def append_cdrom(self, uid, builddir, data):
+    @authenticated
+    def append_cdrom(self, builddir, data):
         cdrom_fname = os.path.join(builddir, 'uploaded_cdrom.iso')
 
         # Now append data to cdrom_file
@@ -193,13 +193,13 @@ class ESoap (ServiceBase):
         fp.close()
 
     @rpc(String)
-    @authenticated_uid
-    def finish_cdrom(self, uid, builddir):
+    @authenticated
+    def finish_cdrom(self, builddir):
         self.app.pm.set_upload_cdrom(builddir, ValidationMode.NO_CHECK)
 
     @rpc(String)
-    @authenticated_uid
-    def start_pdebuild(self, uid, builddir):
+    @authenticated
+    def start_pdebuild(self, builddir):
         pdebuild_fname = os.path.join(builddir, 'current_pdebuild.tar.gz')
 
         # Now write empty File
@@ -207,8 +207,8 @@ class ESoap (ServiceBase):
         fp.close()
 
     @rpc(String, String)
-    @authenticated_uid
-    def append_pdebuild(self, uid, builddir, data):
+    @authenticated
+    def append_pdebuild(self, builddir, data):
         pdebuild_fname = os.path.join(builddir, 'current_pdebuild.tar.gz')
 
         # Now write empty File
@@ -217,18 +217,18 @@ class ESoap (ServiceBase):
         fp.close()
 
     @rpc(String, String, Boolean)
-    @authenticated_uid
-    def finish_pdebuild(self, uid, builddir, profile, cross):
+    @authenticated
+    def finish_pdebuild(self, builddir, profile, cross):
         self.app.pm.build_pdebuild(builddir, profile, cross)
 
     @rpc(String, String)
-    @authenticated_uid
-    def start_upload_orig(self, uid, builddir, fname):
+    @authenticated
+    def start_upload_orig(self, builddir, fname):
         self.app.pm.set_orig_fname(builddir, fname)
 
     @rpc(String, String)
-    @authenticated_uid
-    def append_upload_orig(self, uid, builddir, data):
+    @authenticated
+    def append_upload_orig(self, builddir, data):
         orig_fname = os.path.join(builddir, self.app.pm.get_orig_fname(builddir))
 
         # Now append to File
@@ -237,26 +237,26 @@ class ESoap (ServiceBase):
         fp.close()
 
     @rpc(String)
-    @authenticated_uid
-    def finish_upload_orig(self, uid, builddir):
+    @authenticated
+    def finish_upload_orig(self, builddir):
         # If we support more than one orig, we need to put the orig_files into
         # some list here.
         # We still need the notion of a "current" orig during file upload.
         pass
 
     @rpc(String)
-    @authenticated_uid
-    def reset_project(self, uid, builddir):
+    @authenticated
+    def reset_project(self, builddir):
         self.app.pm.db.reset_project(builddir, True)
 
     @rpc(String)
-    @authenticated_uid
-    def del_project(self, uid, builddir):
+    @authenticated
+    def del_project(self, builddir):
         self.app.pm.del_project(builddir)
 
     @rpc(String, String, _returns=String)
-    @authenticated_uid
-    def create_project(self, uid, xml, url_validation):
+    @authenticated
+    def create_project(self, xml, url_validation):
         with NamedTemporaryFile() as fp:
             fp.write(binascii.a2b_base64(xml))
             fp.flush()
@@ -266,26 +266,26 @@ class ESoap (ServiceBase):
         return prjid
 
     @rpc(_returns=String)
-    @authenticated_uid
-    def new_project(self, uid):
+    @authenticated
+    def new_project(self):
         return self.app.pm.new_project()
 
     @rpc(String, _returns=String)
-    @authenticated_uid
-    def get_project_busy(self, uid, builddir):
+    @authenticated
+    def get_project_busy(self, builddir):
         ret, msg = self.app.pm.project_is_busy(builddir)
         if not msg and not ret:
             return 'ELBE-FINISH'
         return msg
 
     @rpc(String)
-    @authenticated_uid
-    def rm_log(self, uid, builddir):
+    @authenticated
+    def rm_log(self, builddir):
         self.app.pm.rm_log(builddir)
 
     @rpc(String, _returns=String.customize(max_occurs='unbounded'))
-    @authenticated_uid
-    def list_packages(self, uid, builddir):
+    @authenticated
+    def list_packages(self, builddir):
         r = []
         for _, _, filenames in os.walk(
                 os.path.join(builddir, 'repo/pool/main')):
@@ -294,8 +294,8 @@ class ESoap (ServiceBase):
         return sorted(r)
 
     @rpc(String, String)
-    @authenticated_uid
-    def tar_prjrepo(self, uid, builddir, filename):
+    @authenticated
+    def tar_prjrepo(self, builddir, filename):
         with tarfile.open(os.path.join(builddir, filename), 'w:gz') as tar:
             tar.add(
                 os.path.join(
@@ -304,6 +304,6 @@ class ESoap (ServiceBase):
                         builddir, 'repo')))
 
     @rpc(String, String)
-    @authenticated_uid
-    def include_package(self, uid, builddir, filename):
+    @authenticated
+    def include_package(self, builddir, filename):
         self.app.pm.add_deb_package(builddir, filename)

-- 
2.48.1



More information about the elbe-devel mailing list