({
binding,
ignoreGroup,
getGroupByIdentifier,
}: {
binding: Binding;
ignoreGroup: boolean;
// Resolves a group from its binding member string. Defaults to the Pinia
// group store; React callers pass a resolver backed by the app store so
// group expansion reads from the same cache they populate.
getGroupByIdentifier?: (identifier: string) => Group | undefined;
})
| 101 | // - serviceAccounts/{email} |
| 102 | // - workloadIdentities/{email} |
| 103 | export const getUserListInBinding = ({ |
| 104 | binding, |
| 105 | ignoreGroup, |
| 106 | getGroupByIdentifier, |
| 107 | }: { |
| 108 | binding: Binding; |
| 109 | ignoreGroup: boolean; |
| 110 | // Resolves a group from its binding member string. Defaults to the Pinia |
| 111 | // group store; React callers pass a resolver backed by the app store so |
| 112 | // group expansion reads from the same cache they populate. |
| 113 | getGroupByIdentifier?: (identifier: string) => Group | undefined; |
| 114 | }): string[] => { |
| 115 | if (isBindingPolicyExpired(binding)) { |
| 116 | return []; |
| 117 | } |
| 118 | |
| 119 | const resolveGroup = |
| 120 | getGroupByIdentifier ?? |
| 121 | ((identifier: string) => |
| 122 | appStoreUtilBridge()?.getGroupByIdentifier(identifier)); |
| 123 | const fullnameList = []; |
| 124 | |
| 125 | for (const member of binding.members) { |
| 126 | const fullname = convertMemberToFullname(member); |
| 127 | if (fullname.startsWith(groupNamePrefix)) { |
| 128 | if (ignoreGroup) { |
| 129 | continue; |
| 130 | } |
| 131 | const group = resolveGroup(member); |
| 132 | if (!group) { |
| 133 | continue; |
| 134 | } |
| 135 | for (const groupMember of group.members) { |
| 136 | // the group member MUST be human. |
| 137 | fullnameList.push(ensureUserFullName(groupMember.member)); |
| 138 | } |
| 139 | } else { |
| 140 | fullnameList.push(fullname); |
| 141 | } |
| 142 | } |
| 143 | return uniq(fullnameList); |
| 144 | }; |
| 145 | |
| 146 | // memberMapToRolesInProjectIAM return the Map<users/{email}, Set<roles/{role}>> |
| 147 | // the user could includes users/ALL_USERS_USER_EMAIL |
no test coverage detected