From cae581979bbdaa81eaea342359812edeebcd5dbc Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Thu, 28 Dec 2017 01:44:55 +0800 Subject: [PATCH] Return UAA settings in configuration API All the UAA settings will be read only as we expect user to modify it via opsman instead of Harbor UI. --- src/ui/api/config.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ui/api/config.go b/src/ui/api/config.go index 79beb1d52..d2e19bd08 100644 --- a/src/ui/api/config.go +++ b/src/ui/api/config.go @@ -52,6 +52,10 @@ var ( common.ProjectCreationRestriction, common.TokenExpiration, common.ScanAllPolicy, + common.UAAClientID, + common.UAAClientSecret, + common.UAAEndpoint, + common.UAAVerifyCert, } stringKeys = []string{ @@ -68,6 +72,8 @@ var ( common.EmailFrom, common.EmailIdentity, common.ProjectCreationRestriction, + common.UAAClientID, + common.UAAEndpoint, } numKeys = []string{ @@ -82,11 +88,13 @@ var ( common.EmailInsecure, common.SelfRegistration, common.LDAPVerifyCert, + common.UAAVerifyCert, } passwordKeys = []string{ common.EmailPassword, common.LDAPSearchPwd, + common.UAAClientSecret, } ) @@ -223,8 +231,8 @@ func validateCfg(c map[string]interface{}) (bool, error) { } if value, ok := strMap[common.AUTHMode]; ok { - if value != common.DBAuth && value != common.LDAPAuth { - return false, fmt.Errorf("invalid %s, shoud be %s or %s", common.AUTHMode, common.DBAuth, common.LDAPAuth) + if value != common.DBAuth && value != common.LDAPAuth && value != common.UAAAuth { + return false, fmt.Errorf("invalid %s, shoud be one of %s, %s, %s", common.AUTHMode, common.DBAuth, common.LDAPAuth, common.UAAAuth) } flag, err := authModeCanBeModified() if err != nil { @@ -329,8 +337,12 @@ func convertForGet(cfg map[string]interface{}) (map[string]*value, error) { if err != nil { return nil, err } - result[common.AUTHMode].Editable = flag - + //All configuration of UAA will be un-editable for PKS 1.0 (1.4) + result[common.AUTHMode].Editable = flag && result[common.AUTHMode].Value.(string) != common.UAAAuth + result[common.UAAEndpoint].Editable = false + // result[common.UAAClientSecret].Editable = false + result[common.UAAVerifyCert].Editable = false + result[common.UAAClientID].Editable = false return result, nil }