From ec898e164fc45bdbffbcce483cb0b1d608f01506 Mon Sep 17 00:00:00 2001 From: aldbr Date: Wed, 6 Dec 2023 17:54:39 +0100 Subject: [PATCH] fix: useLegacyAdapter should check the VO --- src/DIRAC/ConfigurationSystem/Client/PathFinder.py | 13 ++++++++++++- src/DIRAC/Core/Security/DiracX.py | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/DIRAC/ConfigurationSystem/Client/PathFinder.py b/src/DIRAC/ConfigurationSystem/Client/PathFinder.py index f5470659cca..6cfcb3b2cde 100755 --- a/src/DIRAC/ConfigurationSystem/Client/PathFinder.py +++ b/src/DIRAC/ConfigurationSystem/Client/PathFinder.py @@ -256,9 +256,20 @@ def useLegacyAdapter(system, service=None) -> bool: :return: bool -- True if DiracX should be used """ + from DIRAC.Core.Security.ProxyInfo import getProxyInfo + + # Check if DiracX is enabled for this service system, service = divideFullName(system, service) value = gConfigurationData.extractOptionFromCFG(f"/DiracX/LegacyClientEnabled/{system}/{service}") - return (value or "no").lower() in ("y", "yes", "true", "1") + isServiceEnabled = (value or "no").lower() in ("y", "yes", "true", "1") + # 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 def getServiceURL(system, service=None, setup=False): diff --git a/src/DIRAC/Core/Security/DiracX.py b/src/DIRAC/Core/Security/DiracX.py index 3d0f726d08e..2bc40f835c1 100644 --- a/src/DIRAC/Core/Security/DiracX.py +++ b/src/DIRAC/Core/Security/DiracX.py @@ -75,7 +75,7 @@ def DiracXClient() -> _DiracClient: proxyLocation = getDefaultProxyLocation() diracxToken = diracxTokenFromPEM(proxyLocation) if not diracxToken: - raise ValueError(f"No dirax token in the proxy file {proxyLocation}") + raise ValueError(f"No diracx token in the proxy file {proxyLocation}") with NamedTemporaryFile(mode="wt") as token_file: token_file.write(json.dumps(diracxToken))