From 9d575c9f4996525ac6f38da48ce600e82b6b44f8 Mon Sep 17 00:00:00 2001 From: yahavi Date: Wed, 4 Sep 2024 10:33:57 +0300 Subject: [PATCH] Remove cert question in config add --- common/commands/config.go | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/common/commands/config.go b/common/commands/config.go index 0870614a1..d771fc865 100644 --- a/common/commands/config.go +++ b/common/commands/config.go @@ -338,16 +338,11 @@ func (cc *ConfigCommand) getConfigurationFromUser() (err error) { return } - var clientCertChecked bool if cc.details.Password == "" && cc.details.AccessToken == "" { - clientCertChecked, err = cc.promptForCredentials(disallowUsingSavedPassword) - if err != nil { + if err = cc.promptForCredentials(disallowUsingSavedPassword); err != nil { return err } } - if !clientCertChecked { - cc.checkClientCertForReverseProxy() - } return } @@ -410,7 +405,7 @@ func (cc *ConfigCommand) promptUrls(disallowUsingSavedPassword *bool) error { }) } -func (cc *ConfigCommand) promptForCredentials(disallowUsingSavedPassword bool) (clientCertChecked bool, err error) { +func (cc *ConfigCommand) promptForCredentials(disallowUsingSavedPassword bool) (err error) { var authMethod AuthenticationMethod authMethod, err = cc.promptAuthMethods() if err != nil { @@ -418,19 +413,17 @@ func (cc *ConfigCommand) promptForCredentials(disallowUsingSavedPassword bool) ( } switch authMethod { case BasicAuth: - return false, ioutils.ReadCredentialsFromConsole(cc.details, cc.defaultDetails, disallowUsingSavedPassword) + return ioutils.ReadCredentialsFromConsole(cc.details, cc.defaultDetails, disallowUsingSavedPassword) case AccessToken: - return false, cc.promptForAccessToken() + return cc.promptForAccessToken() case MTLS: cc.checkCertificateForMTLS() log.Warn("Please notice that authentication using client certificates (mTLS) is not supported by commands which integrate with package managers.") - return true, nil + return nil case WebLogin: - // Web login sends requests, so certificates must be obtained first if they are required. - cc.checkClientCertForReverseProxy() - return true, cc.handleWebLogin() + return cc.handleWebLogin() default: - return false, errorutils.CheckErrorf("unexpected authentication method") + return errorutils.CheckErrorf("unexpected authentication method") } } @@ -465,15 +458,6 @@ func (cc *ConfigCommand) readClientCertInfoFromConsole() { } } -func (cc *ConfigCommand) checkClientCertForReverseProxy() { - if cc.details.ClientCertPath != "" && cc.details.ClientCertKeyPath != "" || cc.useWebLogin { - return - } - if coreutils.AskYesNo("Is the Artifactory reverse proxy configured to accept a client certificate?", false) { - cc.readClientCertInfoFromConsole() - } -} - func readAccessTokenFromConsole(details *config.ServerDetails) error { token, err := ioutils.ScanPasswordFromConsole("JFrog access token:") if err == nil {