fix: OpenID config initialization (#17544)

This is due to a regression in the handling of the enable key in OpenID
configuration.
This commit is contained in:
Aditya Manthramurthy 2023-06-29 23:38:26 -07:00 committed by GitHub
parent 2fcb75d86d
commit bde533a9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View File

@ -206,9 +206,9 @@ func (a adminAPIHandlers) AddIdentityProviderCfg(w http.ResponseWriter, r *http.
// UpdateIdentityProviderCfg: updates an existing IDP config for openid/ldap. // UpdateIdentityProviderCfg: updates an existing IDP config for openid/ldap.
// //
// PATCH <admin-prefix>/idp-cfg/openid/dex1 -> update named config `dex1` // POST <admin-prefix>/idp-cfg/openid/dex1 -> update named config `dex1`
// //
// PATCH <admin-prefix>/idp-cfg/openid/_ -> update (default) named config `_` // POST <admin-prefix>/idp-cfg/openid/_ -> update (default) named config `_`
func (a adminAPIHandlers) UpdateIdentityProviderCfg(w http.ResponseWriter, r *http.Request) { func (a adminAPIHandlers) UpdateIdentityProviderCfg(w http.ResponseWriter, r *http.Request) {
ctx := newContext(r, w, "UpdateIdentityProviderCfg") ctx := newContext(r, w, "UpdateIdentityProviderCfg")
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r)) defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))

View File

@ -243,11 +243,8 @@ func LookupConfig(s config.Config, transport http.RoundTripper, closeRespFn func
// parameters are non-empty. // parameters are non-empty.
var ( var (
cfgEnableVal = getCfgVal(config.Enable) cfgEnableVal = getCfgVal(config.Enable)
isExplicitlyEnabled = false isExplicitlyEnabled = cfgEnableVal != ""
) )
if cfgEnableVal != "" {
isExplicitlyEnabled = true
}
var enabled bool var enabled bool
if isExplicitlyEnabled { if isExplicitlyEnabled {
@ -423,17 +420,21 @@ func (r *Config) GetConfigInfo(s config.Config, cfgName string) ([]madmin.IDPCfg
res := make([]madmin.IDPCfgInfo, 0, len(kvsrcs)+1) res := make([]madmin.IDPCfgInfo, 0, len(kvsrcs)+1)
for _, kvsrc := range kvsrcs { for _, kvsrc := range kvsrcs {
// skip default values. // skip returning default config values.
if kvsrc.Src == config.ValueSourceDef { if kvsrc.Src == config.ValueSourceDef {
if kvsrc.Key != madmin.EnableKey { if kvsrc.Key != madmin.EnableKey {
continue continue
} }
// set an explicit on/off from live configuration. // for EnableKey we set an explicit on/off from live configuration
kvsrc.Value = "off" // if it is present.
if _, ok := r.ProviderCfgs[cfgName]; ok { if _, ok := r.ProviderCfgs[cfgName]; !ok {
if r.Enabled { // No live config is present
kvsrc.Value = "on" continue
} }
if r.Enabled {
kvsrc.Value = "on"
} else {
kvsrc.Value = "off"
} }
} }
res = append(res, madmin.IDPCfgInfo{ res = append(res, madmin.IDPCfgInfo{