voxpupuli / puppet-archive

Compressed archive file download and extraction with native types/providers for Windows and Unix
https://forge.puppet.com/puppet/archive
Apache License 2.0
59 stars 176 forks source link

Unable to download from an artifactory host with X-JFrog-Art-Api Header #445

Closed Simoliv closed 1 year ago

Simoliv commented 3 years ago

We have to use a protected artifactory to download a package, the only option is to use X-JFrog-Art-Api Header, user+pass would be 2FA protected, so will not work.

How to reproduce (e.g Puppet code you use)

Try to use download_options with a X-JFrog-Art-Api Header (which I understood should be usable for that ?)

archive { "package.tar.gz":
    ensure           => present,
    path             => $target_file,
    source           => "${artifactory_url}/${repo}/${branch}/package.tar.gz",
    checksum_type    => 'md5',
    checksum_verify  => $package_md5,
    checksum_url     => "$artifactory_url}/${repo}/${branch}/package.tar.gz.md5",
    download_options => "-H \"X-JFrog-Art-Api: ${token}\"",
}

What are you seeing

Error: /Stage[main]/Application::Deployer/Archive[package.tar.gz]/ensure: change from 'absent' to 'present' failed: Execution of '/usr/bin/curl https://artifactory/artifactory/.../...../package.tar.gz -o /srv/tmp_deployment/package.tar.gz_20210617-72402-a7acae -fsSLg --max-redirs 5 -H "X-JFrog-Art-Api: XXXXXXXXXXXXX"' returned 22: curl: (22) The requested URL returned error: 401 Unauthorized

What behaviour did you expect instead

Working

Output log

see above

Any additional information you'd like to impart

When copying the whole command line to bash as-is, downloading works (??)

Simoliv commented 3 years ago

sorry for bad code insertion, seems I am unable to format it correctly ..

cdenneen commented 2 years ago

Considering someone might be using Windows and download_options has "no effect" on underlying ruby client might need a way to make this work on Windows too when coming up with a fix:

https://github.com/voxpupuli/puppet-archive#download-customizations

cdenneen commented 2 years ago

@Simoliv if you modify your download_options you can make this work:

archive { "package.tar.gz":
    ensure           => present,
    path             => $target_file,
    source           => "${artifactory_url}/${repo}/${branch}/package.tar.gz",
    checksum_type    => 'md5',
    checksum_verify  => $package_md5,
    checksum_url     => "$artifactory_url}/${repo}/${branch}/package.tar.gz.md5",
    download_options => "-H \"Authorization: Bearer ${token}\"",
}