Skip to content

Commit 6c2b4f8

Browse files
committed
feat: add PilotScopes
1 parent b9028ac commit 6c2b4f8

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus
3333
from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus
3434
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
35+
from DIRAC.WorkloadManagementSystem.Client.PilotScopes import PILOT_SCOPES
36+
3537
from DIRAC.WorkloadManagementSystem.Client.MatcherClient import MatcherClient
3638
from DIRAC.WorkloadManagementSystem.Client.ServerUtils import getPilotAgentsDB
3739
from DIRAC.WorkloadManagementSystem.private.ConfigHelper import findGenericPilotCredentials
@@ -476,7 +478,7 @@ def __getPilotToken(self, audience: str, scope: list[str] = None):
476478
return S_ERROR("Audience is not defined")
477479

478480
if not scope:
479-
scope = ["compute.cancel", "compute.create", "compute.read", "compute.cancel"]
481+
scope = PILOT_SCOPES
480482

481483
return gTokenManager.getToken(userGroup=self.pilotGroup, requiredTimeLeft=600, scope=scope, audience=audience)
482484

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
This module contains constants and lists for the possible scopes to interact with pilots on CEs.
3+
"""
4+
5+
# Based on: https://github.com/WLCG-AuthZ-WG/common-jwt-profile/blob/master/profile.md#capability-based-authorization-scope
6+
7+
#: To submit pilots:
8+
CREATE = "compute.create"
9+
#: To cancel pilots:
10+
CANCEL = "compute.cancel"
11+
#: To modify attributes of submitted pilots:
12+
MODIFY = "compute.modify"
13+
#: To read information about submitted pilots:
14+
READ = "compute.read"
15+
16+
#: Possible pilot scopes:
17+
PILOT_SCOPES = [CANCEL, CREATE, MODIFY, READ]

src/DIRAC/WorkloadManagementSystem/Service/WMSUtilities.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
1111
from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager
1212
from DIRAC.Resources.Computing.ComputingElementFactory import ComputingElementFactory
13+
from DIRAC.WorkloadManagementSystem.Client.PilotScopes import PILOT_SCOPES
1314

1415

1516
# List of files to be inserted/retrieved into/from pilot Output Sandbox
@@ -77,7 +78,7 @@ def setPilotCredentials(ce, pilotDict):
7778
if "Token" in ce.ceParameters.get("Tag", []):
7879
result = gTokenManager.getToken(
7980
userGroup=pilotDict["OwnerGroup"],
80-
scope=["compute.cancel", "compute.create", "compute.modify", "compute.read"],
81+
scope=PILOT_SCOPES,
8182
audience=ce.audienceName,
8283
requiredTimeLeft=150,
8384
)

0 commit comments

Comments
 (0)