From afa6b043a1ab3f083fa72ed864d01effab30e32e Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Tue, 16 Apr 2024 14:16:40 +0200 Subject: [PATCH] fix: removed group from ProxyManager --- .../WebApp/handler/JobLaunchpadHandler.py | 9 ++----- .../WebApp/handler/ProxyManagerHandler.py | 24 ++++--------------- .../ProxyManager/classes/ProxyManager.js | 17 +------------ 3 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/WebAppDIRAC/WebApp/handler/JobLaunchpadHandler.py b/src/WebAppDIRAC/WebApp/handler/JobLaunchpadHandler.py index 863547f7..1b8d281c 100644 --- a/src/WebAppDIRAC/WebApp/handler/JobLaunchpadHandler.py +++ b/src/WebAppDIRAC/WebApp/handler/JobLaunchpadHandler.py @@ -51,19 +51,14 @@ def web_getProxyStatus(self): def __getProxyStatus(self): proxyManager = ProxyManagerClient() - group = self.getUserGroup() - - if group == "visitor": - return {"success": "false", "error": "User is anonymous or is not registered in the system"} - userDN = self.getUserDN() defaultSeconds = 24 * 3600 + 60 # 24H + 1min validSeconds = gConfig.getValue("/Registry/DefaultProxyLifeTime", defaultSeconds) - gLogger.info(f"\033[0;31m userHasProxy({userDN}, {group}, {validSeconds}) \033[0m") + gLogger.info(f"\033[0;31m userHasProxy({userDN}, {validSeconds}) \033[0m") - if (result := proxyManager.userHasProxy(userDN, group, validSeconds))["OK"]: + if (result := proxyManager.userHasProxy(userDN, validSeconds))["OK"]: return {"success": "true", "result": "true" if result["Value"] else "false"} return {"success": "false", "error": "false"} diff --git a/src/WebAppDIRAC/WebApp/handler/ProxyManagerHandler.py b/src/WebAppDIRAC/WebApp/handler/ProxyManagerHandler.py index 069ecd64..b43d1222 100644 --- a/src/WebAppDIRAC/WebApp/handler/ProxyManagerHandler.py +++ b/src/WebAppDIRAC/WebApp/handler/ProxyManagerHandler.py @@ -23,23 +23,14 @@ def web_getSelectionData(self, **kwargs): return {"success": "false", "error": result["Message"]} data = result["Value"] users = [] - groups = [] for record in data["Records"]: users.append(str(record[0])) - groups.append(str(record[2])) - # AL: - # for record in data["Dictionaries"]: - # users.append(record['user']) - # groups += record['groups'] + users = uniqueElements(users) - groups = uniqueElements(groups) users.sort() - groups.sort() users = [[x] for x in users] - groups = [[x] for x in groups] callback["username"] = users - callback["usergroup"] = groups result = gConfig.getOption("/WebApp/ProxyManagementMonitoring/TimeSpan", "86400,432000,604800,2592000") if result["OK"]: tmp = result["Value"] @@ -64,17 +55,14 @@ def web_getProxyManagerData( sortDirection="ASC", sortField="UserName", username="[]", - usergroup="[]", expiredBefore=0, expiredAfter=0, ): if self.getUserName().lower() == "anonymous": return {"success": "false", "error": "You are not authorize to access these data"} - req = self.__prepareParameters(username, usergroup, expiredBefore, expiredAfter) + req = self.__prepareParameters(username, expiredBefore, expiredAfter) gLogger.info("!!! S O R T : ", sort := [[sortField, sortDirection]]) - # pylint: disable=no-member result = gProxyManager.getDBContents(req, sort, start, limit) - # result = gProxyManager.getDBContents(None, None, req, start, limit) gLogger.info(f"*!*!*! RESULT: \n{result}") if not result["OK"]: return {"success": "false", "error": result["Message"]} @@ -86,7 +74,6 @@ def web_getProxyManagerData( "proxyid": f"{record[1]}@{record[2]}", "UserName": str(record[0]), "UserDN": record[1], - "UserGroup": record[2], "ExpirationTime": str(record[3]), } ) @@ -101,8 +88,7 @@ def web_deleteProxies(self, idList=None): for id in webIds: spl = id.split("@") dn = "@".join(spl[:-1]) - group = spl[-1] - idList.append((dn, group)) + idList.append((dn,)) retVal = gProxyManager.deleteProxyBundle(idList) # for uid in webIds: # spl = uid.split("@") @@ -145,12 +131,10 @@ def __humanize_time(self, sec=False): elif day > 0: return f"{day} days" - def __prepareParameters(self, username, usergroup, expiredBefore, expiredAfter): + def __prepareParameters(self, username, expiredBefore, expiredAfter): req = {} if users := list(json.loads(username)): req["UserName"] = users - if usersgroup := list(json.loads(usergroup)): - req["UserGroup"] = usersgroup if expiredBefore > expiredAfter: expiredBefore, expiredAfter = expiredAfter, expiredBefore diff --git a/src/WebAppDIRAC/WebApp/static/DIRAC/ProxyManager/classes/ProxyManager.js b/src/WebAppDIRAC/WebApp/static/DIRAC/ProxyManager/classes/ProxyManager.js index 3c89f490..b23692da 100644 --- a/src/WebAppDIRAC/WebApp/static/DIRAC/ProxyManager/classes/ProxyManager.js +++ b/src/WebAppDIRAC/WebApp/static/DIRAC/ProxyManager/classes/ProxyManager.js @@ -52,10 +52,6 @@ Ext.define("DIRAC.ProxyManager.classes.ProxyManager", { { name: "UserDN", }, - { - name: "UserGroup", - type: "auto", - }, { name: "ExpirationTime", type: "date", @@ -89,13 +85,9 @@ Ext.define("DIRAC.ProxyManager.classes.ProxyManager", { var selectors = { username: "User", - usergroup: "Group", }; - var map = [ - ["username", "username"], - ["usergroup", "usergroup"], - ]; + var map = [["username", "username"]]; me.leftPanel = new Ext.create("Ext.dirac.utils.DiracBaseSelector", { scope: me, @@ -162,13 +154,6 @@ Ext.define("DIRAC.ProxyManager.classes.ProxyManager", { sortable: true, }, }, - Group: { - dataIndex: "UserGroup", - properties: { - width: 100, - sortable: true, - }, - }, "Expiration date (UTC)": { dataIndex: "ExpirationTime", properties: {