Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove self-signed certificate question in Config #1258

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading