Skip to content

Commit

Permalink
fix: handle case where requets is coming from a host
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Dec 7, 2023
1 parent ec898e1 commit 72c9af7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/DIRAC/ConfigurationSystem/Client/PathFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def getServiceURLs(system, service=None, setup=False, failover=False):
return resList


def useLegacyAdapter(system, service=None) -> bool:
def useLegacyAdapter(system, service=None, useCertificates=None) -> bool:
"""Should DiracX be used for this service via the legacy adapter mechanism
:param str system: system name or full name e.g.: Framework/ProxyManager
Expand All @@ -261,15 +261,22 @@ def useLegacyAdapter(system, service=None) -> bool:
# Check if DiracX is enabled for this service
system, service = divideFullName(system, service)
value = gConfigurationData.extractOptionFromCFG(f"/DiracX/LegacyClientEnabled/{system}/{service}")
isServiceEnabled = (value or "no").lower() in ("y", "yes", "true", "1")
# Check if DiracX is enabled for this VO
if (value or "no").lower() not in ("y", "yes", "true", "1"):
return False

# Check if we are using a server certificate: in this case we cannot use DiracX
if not useCertificates:
useCertificates = gConfigurationData.useServerCertificate()
if useCertificates:
return False

# We are using a proxy: check if DiracX is enabled for this VO
result = getProxyInfo()
if not result["OK"]:
return False
value = gConfigurationData.extractOptionFromCFG(f"/Registry/Groups/{result['Value']['group']}/VO")
isVOEnabled = value not in getDisabledDiracxVOs()

return isServiceEnabled and isVOEnabled
return value not in getDisabledDiracxVOs()


def getServiceURL(system, service=None, setup=False):
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Core/Tornado/Client/ClientSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def ClientSelector(disetClient, *args, **kwargs): # We use same interface as RP
# If we are not already given a URL, resolve it
if serviceName.startswith(("http", "dip")):
completeUrl = serviceName
elif useLegacyAdapter(serviceName):
elif useLegacyAdapter(serviceName, kwargs.get("useCertificates")):
sLog.debug(f"Using legacy adapter for service {serviceName}")
if diracxClient is None:
raise NotImplementedError(
Expand Down

0 comments on commit 72c9af7

Please sign in to comment.