Skip to content

Commit 0f8b608

Browse files
marianne013web-flow
authored andcommitted
sweep: #8256 feat: multiVO by IAM group
1 parent e741794 commit 0f8b608

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/DIRAC/ConfigurationSystem/Client/VOMS2CSSynchronizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def syncCSWithVOMS(self):
594594

595595
# Try to fill in the DiracX section
596596
if self.useIAM:
597-
iam_subs = self.iamSrv.getUsersSub()
597+
iam_subs = self.iamSrv.getUsersSub(self.vo)
598598
diracx_vo_config = {"DiracX": {"CsSync": {"VOs": {self.vo: {"UserSubjects": iam_subs}}}}}
599599
iam_sub_cfg = CFG()
600600
iam_sub_cfg.loadFromDict(diracx_vo_config)

src/DIRAC/Core/Security/IAMService.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,15 @@ def getUsers(self):
144144
result = S_OK({"Users": users, "Errors": errors})
145145
return result
146146

147-
def getUsersSub(self) -> dict[str, str]:
147+
def getUsersSub(self, vo=None) -> dict[str, str]:
148148
"""
149149
Return the mapping based on IAM sub:
150150
{nickname : sub}
151151
"""
152152
iam_users_raw = self._getIamUserDump()
153153
diracx_user_section = {}
154154
for user_info in iam_users_raw:
155+
userGroups = [grp["display"] for grp in user_info.get("groups", [])]
155156
# The nickname is available in the list of attributes
156157
# (if configured so)
157158
# in the form {'name': 'nickname', 'value': 'chaen'}
@@ -165,8 +166,8 @@ def getUsersSub(self) -> dict[str, str]:
165166
except (KeyError, IndexError):
166167
nickname = user_info["userName"]
167168
sub = user_info["id"]
168-
169-
diracx_user_section[nickname] = sub
169+
if not vo or vo in userGroups:
170+
diracx_user_section[nickname] = sub
170171
# reorder it
171172
diracx_user_section = dict(sorted(diracx_user_section.items()))
172173

0 commit comments

Comments
 (0)