Skip to content

Commit

Permalink
Merge pull request #756 from fstagni/proxyDB
Browse files Browse the repository at this point in the history
fix: removed group from ProxyManager
  • Loading branch information
fstagni authored Apr 17, 2024
2 parents 1debc0c + afa6b04 commit c446f8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 43 deletions.
9 changes: 2 additions & 7 deletions src/WebAppDIRAC/WebApp/handler/JobLaunchpadHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down
24 changes: 4 additions & 20 deletions src/WebAppDIRAC/WebApp/handler/ProxyManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]}
Expand All @@ -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]),
}
)
Expand All @@ -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("@")
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ Ext.define("DIRAC.ProxyManager.classes.ProxyManager", {
{
name: "UserDN",
},
{
name: "UserGroup",
type: "auto",
},
{
name: "ExpirationTime",
type: "date",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit c446f8e

Please sign in to comment.