Only add distinct policies to identity group (#15638)

* Only add distinct policies to identity group
This commit is contained in:
Peter Wilson 2022-05-26 13:52:19 +01:00 committed by GitHub
parent aa6bf94621
commit b7fc4645f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

3
changelog/15638.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
vault: Fix a bug where duplicate policies could be added to an identity group.
```

View File

@ -181,7 +181,7 @@ func (i *IdentityStore) handleGroupUpdateCommon(ctx context.Context, req *logica
// Update the policies if supplied
policiesRaw, ok := d.GetOk("policies")
if ok {
group.Policies = policiesRaw.([]string)
group.Policies = strutil.RemoveDuplicatesStable(policiesRaw.([]string), true)
}
if strutil.StrListContains(group.Policies, "root") {

View File

@ -677,7 +677,7 @@ func TestIdentityStore_GroupsCreateUpdate(t *testing.T) {
// Create a group with the above created 2 entities as its members
groupData := map[string]interface{}{
"policies": "testpolicy1,testpolicy2",
"policies": "testpolicy1,testPolicy1 , testpolicy2",
"metadata": []string{"testkey1=testvalue1", "testkey2=testvalue2"},
"member_entity_ids": []string{entityID1, entityID2},
}