Skip to content

Commit d42fe77

Browse files
committed
fix (RMS): fix compatibility with old requests
1 parent f3db17d commit d42fe77

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/DIRAC/RequestManagementSystem/private/RequestValidator.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def hasBar( request ):
5353
from DIRAC.Core.Security.Properties import FULL_DELEGATION, LIMITED_DELEGATION
5454
from DIRAC.Core.Utilities.DIRACSingleton import DIRACSingleton
5555
from DIRAC.ConfigurationSystem.Client import PathFinder
56+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getUsernameForDN
5657

5758

5859
class RequestValidator(metaclass=DIRACSingleton):
@@ -268,28 +269,21 @@ def setAndCheckRequestOwner(request, remoteCredentials):
268269
269270
:returns: True if everything is fine, False otherwise
270271
"""
271-
272272
credUserName = remoteCredentials["username"]
273273
credGroup = remoteCredentials["group"]
274274
credProperties = remoteCredentials["properties"]
275-
ownershipCheck = None
276-
277-
# FIXME: code for backward compatibility with requests created by 8.0 clients
278-
# The below can be clearly simplified, leaving the extended checks for clarity
279-
if hasattr(request, "OwnerDN") and not hasattr(
280-
request, "Owner"
281-
): # Requests created by v8.0 client for v8.0 servers
282-
ownershipCheck = request.OwnerDN
283-
if not hasattr(request, "OwnerDN") and hasattr(
284-
request, "Owner"
285-
): # Requests created by v9 client for v9 servers
286-
ownershipCheck = request.Owner
287-
if hasattr(request, "OwnerDN") and hasattr(request, "Owner"): # Requests created by v8.0 client for v9 servers
288-
ownershipCheck = request.Owner
289-
# ##
275+
276+
# In case we have an old style request with only a DN and no Owner,
277+
# get the Owner from the DN.
278+
if getattr(request, "OwnerDN", None) and not getattr(request, "Owner", None):
279+
res = getUsernameForDN(request.OwnerDN)
280+
if not res["OK"]:
281+
gLogger.error("Cannot Validate request", res)
282+
return False
283+
request.Owner = res["Value"]
290284

291285
# If the owner or the group was not set, we use the one of the credentials
292-
if not ownershipCheck or not request.OwnerGroup:
286+
if not request.Owner or not request.OwnerGroup:
293287
request.Owner = credUserName
294288
request.OwnerGroup = credGroup
295289
return True

0 commit comments

Comments
 (0)