From f1016e7f0f28a37cbd273b6b1ba48ecf236aaca4 Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:15:17 -0500 Subject: [PATCH] backport of commit 5ee68b2e8d50239ffa4d3de33e692d68b3924603 (#24326) Co-authored-by: Mike Palmiotto --- vault/identity_store_entities.go | 64 ++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/vault/identity_store_entities.go b/vault/identity_store_entities.go index f284dcedd482..402d3161f683 100644 --- a/vault/identity_store_entities.go +++ b/vault/identity_store_entities.go @@ -58,9 +58,12 @@ func entityPaths(i *IdentityStore) []*framework.Path { return []*framework.Path{ { Pattern: "entity$", - Fields: entityPathFields(), - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.handleEntityUpdateCommon(), + + Fields: entityPathFields(), + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.handleEntityUpdateCommon(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["entity"][0]), @@ -69,10 +72,16 @@ func entityPaths(i *IdentityStore) []*framework.Path { { Pattern: "entity/name/(?P.+)", Fields: entityPathFields(), - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.handleEntityUpdateCommon(), - logical.ReadOperation: i.pathEntityNameRead(), - logical.DeleteOperation: i.pathEntityNameDelete(), + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.handleEntityUpdateCommon(), + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathEntityNameRead(), + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathEntityNameDelete(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["entity-name"][0]), @@ -81,10 +90,16 @@ func entityPaths(i *IdentityStore) []*framework.Path { { Pattern: "entity/id/" + framework.GenericNameRegex("id"), Fields: entityPathFields(), - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.handleEntityUpdateCommon(), - logical.ReadOperation: i.pathEntityIDRead(), - logical.DeleteOperation: i.pathEntityIDDelete(), + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.handleEntityUpdateCommon(), + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathEntityIDRead(), + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathEntityIDDelete(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["entity-id"][0]), @@ -98,8 +113,11 @@ func entityPaths(i *IdentityStore) []*framework.Path { Description: "Entity IDs to delete", }, }, - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.handleEntityBatchDelete(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.handleEntityBatchDelete(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["batch-delete"][0]), @@ -107,8 +125,11 @@ func entityPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "entity/name/?$", - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.ListOperation: i.pathEntityNameList(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.ListOperation: &framework.PathOperation{ + Callback: i.pathEntityNameList(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["entity-name-list"][0]), @@ -116,8 +137,11 @@ func entityPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "entity/id/?$", - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.ListOperation: i.pathEntityIDList(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.ListOperation: &framework.PathOperation{ + Callback: i.pathEntityIDList(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["entity-id-list"][0]), @@ -143,8 +167,10 @@ func entityPaths(i *IdentityStore) []*framework.Path { Description: "Setting this will follow the 'mine' strategy for merging MFA secrets. If there are secrets of the same type both in entities that are merged from and in entity into which all others are getting merged, secrets in the destination will be unaltered. If not set, this API will throw an error containing all the conflicts.", }, }, - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.pathEntityMergeID(), + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.pathEntityMergeID(), + }, }, HelpSynopsis: strings.TrimSpace(entityHelp["entity-merge-id"][0]),