简体   繁体   中英

Jfrog CLI does not respect configured API key

I'm using Powershell DSC to set up a Windows Server 2012 R2 box. As part of the configuration process, I'm provisioning jfrog.exe and executing a configuration command as a service account:

jfrog rt config --url=$localArtifactoryInstance --user=$username --apikey=$apikey

This command creates .jfrog.jfrog-cli.conf in the service account's home directory (C:\\Users\\$serviceAccount.jfrog.jfrog-cli.conf) as expected, containing URL/username/apiKey.

Post-provisioning, this service account is charged with 'promoting' artifacts from one repository to another:

jfrog rt move '$devRepo/(Org)/(Org.Common.Configuration)/Org.Common.Configuration.1.0.0.nupkg' '$prodRepo/{1}/{2}/'

This command is rejected with a 401:

[Error] Artifactory response: 401 Unauthorized
{
  "errors": [
    {
      "status": 401,
      "message": "Bad authentication. Provided username or password are incorrect."
    }
  ]
}

However, when I add the same API key as is already configured in jfrog-cli.conf to the command:

jfrog rt move '$devRepo/(Org)/(Org.Common.Configuration)/Org.Common.Configuration.1.0.0.nupkg' '$prodRepo/{1}/{2}/' --ApiKey $apiKey

It is successful, and I can verify success via the Artifactory UI.

  • The service account executing the command is the same as the service account that executed jfrog rt config, and matches the username in jfrog-cli.conf.
  • The API key was generated in Artifactory for that service account
  • I have tried altering the username in jfrog-cli.conf to include and not include the domain
  • I have ensured that the environment variable 'HOME' exists and is pointed to the service account's home directory ( https://github.com/JFrogDev/jfrog-cli-go/blob/master/utils/ioutils/ioutils.go seems to imply that this variable is necessary)
  • 'jfrog rt config show' shows the correct data

Thanks for any help or guidance you can supply!

The '401 Unauthorized' response is a consequence of configuring both a username and an API key.

When running jfrog rt config , you may supply either a username/password pair or an API key. After configuring a username and api key, my commands failed since jfrog.exe was contacting the server with a username and no password.

The solution was to remove username from my Powershell DSC config entirely, and provide only url and apikey when running jfrog rt config .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM