From 85f3b8354783d539d24cbed6201c59f419bb7800 Mon Sep 17 00:00:00 2001 From: akshya96 Date: Wed, 21 Jun 2023 19:14:58 +0530 Subject: [PATCH] removing loadCaseSensitivityKeyStore --- vault/core.go | 4 ---- vault/identity_store.go | 17 +++++++++++++++++ vault/identity_store_util.go | 22 ++++++++-------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/vault/core.go b/vault/core.go index 72742b992dbd..0e81675b5099 100644 --- a/vault/core.go +++ b/vault/core.go @@ -593,10 +593,6 @@ type Core struct { // active, or give up active as soon as it gets it neverBecomeActive *uint32 - // loadCaseSensitiveIdentityStore enforces the loading of identity store - // artifacts in a case sensitive manner. To be used only in testing. - loadCaseSensitiveIdentityStore bool - // clusterListener starts up and manages connections on the cluster ports clusterListener *atomic.Value diff --git a/vault/identity_store.go b/vault/identity_store.go index da086c964c66..cd6f6970d2ef 100644 --- a/vault/identity_store.go +++ b/vault/identity_store.go @@ -31,6 +31,7 @@ const ( ) var ( + caseSensitivityKey = "casesensitivity" parseExtraEntityFromBucket = func(context.Context, *IdentityStore, *identity.Entity) (bool, error) { return false, nil } addExtraEntityDataToResponse = func(*identity.Entity, map[string]interface{}) {} ) @@ -644,6 +645,22 @@ func (i *IdentityStore) initialize(ctx context.Context, req *logical.Initializat if err := i.storeOIDCDefaultResources(ctx, req.Storage); err != nil { return err } + + // if the storage entry for caseSensitivityKey exists, remove it + storageEntry, err := i.view.Get(ctx, caseSensitivityKey) + if err != nil { + i.logger.Error("could not get storage entry", "error", err) + return nil + } + + if storageEntry != nil { + err = i.view.Delete(ctx, caseSensitivityKey) + if err != nil { + i.logger.Error("could not delete storage entry", "error", err) + return nil + } + } + return nil } diff --git a/vault/identity_store_util.go b/vault/identity_store_util.go index 4310fdf6a0f4..b84db8dd5ff2 100644 --- a/vault/identity_store_util.go +++ b/vault/identity_store_util.go @@ -31,10 +31,6 @@ var ( tmpSuffix = ".tmp" ) -func (c *Core) SetLoadCaseSensitiveIdentityStore(caseSensitive bool) { - c.loadCaseSensitiveIdentityStore = caseSensitive -} - func (c *Core) loadIdentityStoreArtifacts(ctx context.Context) error { if c.identityStore == nil { c.logger.Warn("identity store is not setup, skipping loading") @@ -58,16 +54,14 @@ func (c *Core) loadIdentityStoreArtifacts(ctx context.Context) error { return nil } - if !c.loadCaseSensitiveIdentityStore { - // Load everything when memdb is set to operate on lower cased names - err := loadFunc(ctx) - switch { - case err == nil: - // If it succeeds, all is well - return nil - case !errwrap.Contains(err, errDuplicateIdentityName.Error()): - return err - } + // Load everything when memdb is set to operate on lower cased names + err := loadFunc(ctx) + switch { + case err == nil: + // If it succeeds, all is well + return nil + case !errwrap.Contains(err, errDuplicateIdentityName.Error()): + return err } c.identityStore.logger.Warn("enabling case sensitive identity names")