Merge pull request #4447 from hashicorp/identity-upgrade-nil-check

Add identity store nil checks
This commit is contained in:
Jeff Mitchell 2018-04-24 23:38:53 -04:00 committed by GitHub
commit 54eebfa200
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View file

@ -697,7 +697,7 @@ func (c *Core) LookupToken(token string) (*TokenEntry, error) {
// This list includes the policies from the entity itself and from all the // This list includes the policies from the entity itself and from all the
// groups in which the given entity ID is a member of. // groups in which the given entity ID is a member of.
func (c *Core) fetchEntityAndDerivedPolicies(entityID string) (*identity.Entity, []string, error) { func (c *Core) fetchEntityAndDerivedPolicies(entityID string) (*identity.Entity, []string, error) {
if entityID == "" { if entityID == "" || c.identityStore == nil {
return nil, nil, nil return nil, nil, nil
} }

View file

@ -21,7 +21,8 @@ import (
func (c *Core) loadIdentityStoreArtifacts(ctx context.Context) error { func (c *Core) loadIdentityStoreArtifacts(ctx context.Context) error {
var err error var err error
if c.identityStore == nil { if c.identityStore == nil {
return fmt.Errorf("identity store is not setup") c.logger.Warn("identity store is not setup, skipping loading")
return nil
} }
err = c.identityStore.loadEntities(ctx) err = c.identityStore.loadEntities(ctx)

View file

@ -364,7 +364,8 @@ func (c *Core) handleRequest(ctx context.Context, req *logical.Request) (retResp
resp != nil && resp != nil &&
resp.Auth != nil && resp.Auth != nil &&
resp.Auth.EntityID != "" && resp.Auth.EntityID != "" &&
resp.Auth.GroupAliases != nil { resp.Auth.GroupAliases != nil &&
c.identityStore != nil {
err := c.identityStore.refreshExternalGroupMembershipsByEntityID(resp.Auth.EntityID, resp.Auth.GroupAliases) err := c.identityStore.refreshExternalGroupMembershipsByEntityID(resp.Auth.EntityID, resp.Auth.GroupAliases)
if err != nil { if err != nil {
c.logger.Error("failed to refresh external group memberships", "error", err) c.logger.Error("failed to refresh external group memberships", "error", err)
@ -498,7 +499,10 @@ func (c *Core) handleLoginRequest(ctx context.Context, req *logical.Request) (re
mEntry := c.router.MatchingMountEntry(req.Path) mEntry := c.router.MatchingMountEntry(req.Path)
if auth.Alias != nil && mEntry != nil && !mEntry.Local { if auth.Alias != nil &&
mEntry != nil &&
!mEntry.Local &&
c.identityStore != nil {
// Overwrite the mount type and mount path in the alias // Overwrite the mount type and mount path in the alias
// information // information
auth.Alias.MountType = req.MountType auth.Alias.MountType = req.MountType