Skip to content

Commit

Permalink
removing loadCaseSensitivityKeyStore
Browse files Browse the repository at this point in the history
  • Loading branch information
akshya96 committed Jun 21, 2023
1 parent 30b72ce commit 85f3b83
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 0 additions & 4 deletions vault/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions vault/identity_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {}
)
Expand Down Expand Up @@ -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)

This comment has been minimized.

Copy link
@ncabatoff

ncabatoff Jun 21, 2023

Collaborator

Why bother with the Get? You could just do the delete, it won't return an error if there's nothing to delete.

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
}

Expand Down
22 changes: 8 additions & 14 deletions vault/identity_store_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 85f3b83

Please sign in to comment.