aws-samples / iam-identity-center-team

Open-source temporary elevated access solution for AWS IAM Identity Center.
https://aws-samples.github.io/iam-identity-center-team/
MIT No Attribution
295 stars 67 forks source link

teamListGroups returns members of first group only #176

Closed jarrod-mg closed 7 months ago

jarrod-mg commented 7 months ago

I am trying out TEAM, and have found that I cannot raise a request for access if I am an approver for the account I am requesting access to - even though there are other possible approvers.

This means we can't have "peer approvals" - I can't set it up so I can approve a request for one of my colleagues, while they can also approve my access.

It makes sense that I can't approve my own requests, but I should be able to raise a request when I am in the group (or one of the groups) that can approve requests on that account, so someone else can approve it.

jarrod-mg commented 7 months ago

On further investigation, it appears as if this should be supported; but isn't because of a bug.

In teamListGroups, the handler will return the members of the first group with any members.

    members = []
    groupIds = event["arguments"]["groupIds"]
    for groupId in groupIds:
        if members:
            return {"members": members}
        members.extend(list_idc_group_membership(groupId))
    return {"members": members}

In my case, the first group returned one entry - me, and the second group would have returned a bunch more.

This code will, on the first time through the groupIds loop, add the members of the first group to the members list. On the second, it will detect that members is not empty, and return before getting the members of the second group. I think you just need to remove the if members: return { ... } bit?

tawoyinfa commented 7 months ago

@jarrod-mg thanks for pointing this out. Let me know if you still face this issue after this update