Skip to content

Commit

Permalink
Remove cert question in config add
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi committed Sep 4, 2024
1 parent 3293aac commit 9d575c9
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions common/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -410,27 +405,25 @@ 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 {
return
}
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")
}
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9d575c9

Please sign in to comment.