From 686d4656dea38634c58416b2ea106beedc726a76 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 10 Jan 2020 16:57:18 -0800 Subject: [PATCH] fix: set appropriate defaults when new keys added (#8795) A new key was added in identity_openid recently required explicitly for client to set the optional value without that it would be empty, handle this appropriately. Fixes #8787 --- cmd/config/cache/lookup.go | 4 +--- cmd/config/config.go | 6 ++++++ cmd/config/identity/openid/jwt.go | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/config/cache/lookup.go b/cmd/config/cache/lookup.go index 4d144edfc..41e678d30 100644 --- a/cmd/config/cache/lookup.go +++ b/cmd/config/cache/lookup.go @@ -121,9 +121,7 @@ func LookupConfig(kvs config.KVS) (Config, error) { return cfg, config.ErrInvalidCacheQuota(err) } cfg.Quota = cfg.MaxUse - } - - if quotaStr := env.Get(EnvCacheQuota, kvs.Get(Quota)); quotaStr != "" { + } else if quotaStr := env.Get(EnvCacheQuota, kvs.Get(Quota)); quotaStr != "" { cfg.Quota, err = strconv.Atoi(quotaStr) if err != nil { return cfg, config.ErrInvalidCacheQuota(err) diff --git a/cmd/config/config.go b/cmd/config/config.go index 3d4eb53b2..6938e3c85 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -621,6 +621,12 @@ func (c Config) SetKVS(s string, defaultKVS map[string]KVS) error { currKVS, ok := c[subSys][tgt] if !ok { currKVS = defaultKVS[subSys] + } else { + for _, kv := range defaultKVS[subSys] { + if _, ok = currKVS.Lookup(kv.Key); !ok { + currKVS.Set(kv.Key, kv.Value) + } + } } for _, kv := range kvs { diff --git a/cmd/config/identity/openid/jwt.go b/cmd/config/identity/openid/jwt.go index d3231e33b..de2ec4603 100644 --- a/cmd/config/identity/openid/jwt.go +++ b/cmd/config/identity/openid/jwt.go @@ -326,6 +326,11 @@ func LookupConfig(kvs config.KVS, transport *http.Transport, closeRespFn func(io return c, err } } + + if c.ClaimName == "" { + c.ClaimName = iampolicy.PolicyName + } + if jwksURL == "" { // Fallback to discovery document jwksURL jwksURL = c.DiscoveryDoc.JwksURI