1- """ ProxyDB class is a front-end to the ProxyDB MySQL database.
1+ """ProxyDB class is a front-end to the ProxyDB MySQL database.
22
3- Database contains the following tables:
3+ Database contains the following tables:
44
5- * ProxyDB_Requests -- a delegation requests storage table for a given proxy Chain
6- * ProxyDB_CleanProxies -- table for storing proxies in "clean" form, ie without
7- the presence of DIRAC and VOMS extensions.
8- * ProxyDB_VOMSProxies -- proxy storage table with VOMS extension already added.
9- * ProxyDB_Log -- table with logs.
5+ * ProxyDB_Requests -- a delegation requests storage table for a given proxy Chain
6+ * ProxyDB_CleanProxies -- table for storing proxies in "clean" form, ie without
7+ the presence of DIRAC and VOMS extensions.
8+ * ProxyDB_VOMSProxies -- proxy storage table with VOMS extension already added.
9+ * ProxyDB_Log -- table with logs.
1010"""
11+
1112import textwrap
1213from threading import Lock
1314
@@ -167,8 +168,7 @@ def generateDelegationRequest(self, proxyChain, userDN):
167168 data = retVal ["Value" ]
168169 if not data :
169170 return S_ERROR ("Insertion of the request in the db didn't work as expected" )
170- userGroup = proxyChain .getDIRACGroup ().get ("Value" ) or "unset"
171- self .logAction ("request upload" , userDN , userGroup , userDN , "any" )
171+ self .logAction ("request upload" , userDN , userDN )
172172 # Here we go!
173173 return S_OK ({"id" : data [0 ][0 ], "request" : reqStr })
174174
@@ -249,8 +249,7 @@ def completeDelegation(self, requestId, userDN, delegatedPem):
249249 return self .deleteRequest (requestId ) if retVal ["OK" ] else retVal
250250
251251 def __storeProxy (self , userDN , chain , proxyProvider = None ):
252- """Store user proxy into the Proxy repository for a user specified by his
253- DN and group or proxy provider.
252+ """Store user proxy into the Proxy repository for a user specified by their DN
254253
255254 :param str userDN: user DN from proxy
256255 :param X509Chain() chain: proxy chain
@@ -353,7 +352,7 @@ def __storeProxy(self, userDN, chain, proxyProvider=None):
353352 sqlSet .append (f"{ k } = { dValues [k ]} " )
354353 cmd = f"UPDATE `{ sTable } ` SET { ', ' .join (sqlSet )} WHERE { ' AND ' .join (sqlWhere )} "
355354
356- self .logAction ("store proxy" , userDN , proxyProvider , userDN , proxyProvider )
355+ self .logAction ("store proxy" , userDN , userDN )
357356 return self ._update (cmd )
358357
359358 def purgeExpiredProxies (self , sendNotifications = True ):
@@ -376,23 +375,17 @@ def purgeExpiredProxies(self, sendNotifications=True):
376375 return result
377376 return S_OK (purged )
378377
379- def deleteProxy (self , userDN , userGroup = None , proxyProvider = None ):
378+ def deleteProxy (self , userDN ):
380379 """Remove proxy of the given user from the repository
381380
382381 :param str userDN: user DN
383- :param str userGroup: DIRAC group
384- :param str proxyProvider: proxy provider name
385382
386383 :return: S_OK()/S_ERROR()
387384 """
388385 try :
389386 userDN = self ._escapeString (userDN )["Value" ]
390- if userGroup :
391- userGroup = self ._escapeString (userGroup )["Value" ]
392- if proxyProvider :
393- proxyProvider = self ._escapeString (proxyProvider )["Value" ]
394387 except KeyError :
395- return S_ERROR ("Invalid DN or group or proxy provider " )
388+ return S_ERROR ("Invalid DN" )
396389 errMsgs = []
397390 req = f"DELETE FROM `ProxyDB_CleanProxies` WHERE UserDN={ userDN } "
398391 result = self ._update (req )
@@ -552,7 +545,7 @@ def __getProxyFromProxyProviders(self, userDN, userGroup, requiredLifeTime):
552545 result = chain .generateProxyToString (remainingSecs , diracGroup = userGroup )
553546 if result ["OK" ]:
554547 return S_OK ((result ["Value" ], remainingSecs ))
555- errMsgs .append (f" \" { proxyProvider } \ " : { result [' Message' ] } " )
548+ errMsgs .append (f'" { proxyProvider } ": { result [" Message" ] } ' )
556549
557550 return S_ERROR ("Cannot generate proxy%s" % (errMsgs and ": " + ", " .join (errMsgs ) or "" ))
558551
@@ -592,8 +585,8 @@ def getProxy(self, userDN, userGroup, requiredLifeTime=None):
592585
593586 # Proxy is invalid for some reason, let's delete it
594587 if not chain .isValidProxy ()["OK" ]:
595- self .deleteProxy (userDN , userGroup )
596- return S_ERROR (DErrno .EPROXYFIND , f"{ userDN } @ { userGroup } has no proxy registered" )
588+ self .deleteProxy (userDN )
589+ return S_ERROR (DErrno .EPROXYFIND , f"{ userDN } has no proxy registered" )
597590 return S_OK ((chain , timeLeft ))
598591
599592 def __getVOMSAttribute (self , userGroup , requiredVOMSAttribute = False ):
@@ -824,27 +817,23 @@ def getProxiesContent(self, selDict, sortList, start=0, limit=0):
824817 totalRecords = len (data )
825818 return S_OK ({"ParameterNames" : fields , "Records" : data , "TotalRecords" : totalRecords })
826819
827- def logAction (self , action , issuerDN , issuerGroup , targetDN , targetGroup ):
820+ def logAction (self , action , issuerDN , targetDN ):
828821 """Add an action to the log
829822
830823 :param str action: proxy action
831824 :param str issuerDN: user DN of issuer
832- :param str issuerGroup: DIRAC group of issuer
833825 :param str targetDN: user DN of target
834- :param str targetGroup: DIRAC group of target
835826
836827 :return: S_ERROR()
837828 """
838829 try :
839830 sAction = self ._escapeString (action )["Value" ]
840831 sIssuerDN = self ._escapeString (issuerDN )["Value" ]
841- sIssuerGroup = self ._escapeString (issuerGroup )["Value" ]
842832 sTargetDN = self ._escapeString (targetDN )["Value" ]
843- sTargetGroup = self ._escapeString (targetGroup )["Value" ]
844833 except KeyError :
845834 return S_ERROR ("Can't escape from death" )
846835 cmd = "INSERT INTO `ProxyDB_Log` ( Action, IssuerDN, IssuerGroup, TargetDN, TargetGroup, Timestamp ) VALUES "
847- cmd += f"( { sAction } , { sIssuerDN } , { sIssuerGroup } , { sTargetDN } , { sTargetGroup } , UTC_TIMESTAMP() )"
836+ cmd += f"( { sAction } , { sIssuerDN } , 'IssuerGroup' { sTargetDN } , 'TargetGroup' , UTC_TIMESTAMP() )"
848837 retVal = self ._update (cmd )
849838 if not retVal ["OK" ]:
850839 self .log .error ("Can't add a proxy action log: " , retVal ["Message" ])
0 commit comments