From 0b3607ab87a8bb5006a7be5aade56828fe152fc7 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 6 Sep 2018 18:17:44 +0200 Subject: [PATCH] Fix group alias loading when identity memdb is initialized (#5289) --- vault/identity_store_util.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vault/identity_store_util.go b/vault/identity_store_util.go index 0426f53e6ce5..668fabd5a4be 100644 --- a/vault/identity_store_util.go +++ b/vault/identity_store_util.go @@ -923,16 +923,10 @@ func (i *IdentityStore) sanitizeAndUpsertGroup(group *identity.Group, memberGrou // Sanitize the group alias if group.Alias != nil { group.Alias.CanonicalID = group.ID - err = i.sanitizeAlias(group.Alias) if err != nil { return err } - - err = i.MemDBUpsertAliasInTxn(txn, group.Alias, true) - if err != nil { - return err - } } err = i.UpsertGroupInTxn(txn, group, true) @@ -1092,6 +1086,12 @@ func (i *IdentityStore) UpsertGroupInTxn(txn *memdb.Txn, group *identity.Group, // Increment the modify index of the group group.ModifyIndex++ + if group.Alias != nil { + err = i.MemDBUpsertAliasInTxn(txn, group.Alias, true) + if err != nil { + return err + } + } // Insert or update group in MemDB using the transaction created above err = i.MemDBUpsertGroupInTxn(txn, group) if err != nil {