Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Downloading packages from LDAP-Authticated feeds in Ruby

    Scheduled Pinned Locked Moved Support
    rubyproget
    3 Posts 1 Posters 13 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      I've got a working PowerShell 'download' script for a NuGet package feed from my company's Proget server:

      $targetUri = "https://path/to/my/nuget/package"
      $credentialUser = "{AD username}"
      $credentialPwd = "{AD password}"
      
      $secureString = ConvertTo-SecureString -String $credentialPwd -AsPlainText -Force
      $credential = New-Object System.Management.Automation.PSCredential ($credentialUser, $secureString)
      $webClient = New-Object System.Net.WebClient
      $webClient.Credentials = $credential
      $webClient.DownloadFile($targetUri, "C:\\Tools\octopus-tentacle.2.6.1.796.nupkg")
      

      Now I need to do this same thing in Ruby. Having no luck getting anything but HTTP 401s. Trying rubyntlm gem now (https://github.com/WinRb/rubyntlm/blob/master/examples/http.rb), but if anyone has a working example, I'd be quite appreciative.

      -/- flagellum

      Product: ProGet
      Version: 3.4.7

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        Hi Jeff, it sounds like you're on the right track.

        If you have ProGet set-up to use Windows Authentication (i.e. NTLM), then you will need to get your ruby script to speak in NTLM. Otherwise, the script cannot pass the authentication barrier.

        NTLM is not trivial to implement, so hopefully the rubyntlm gem will be helpful.

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          Answering my own question using this solution. Hope anyone else who has to do this with Ruby will find this helpful:

          require 'rubygems'
          require 'httpclient'  #latest, with rubyntlm also installed
          
          http_client = HTTPClient.new
          http_client.set_auth(nil, '<domain>\<username>', '<password>')
          local_file = File.new("C:\\temp\\<package>.<version>.nupkg", "wb")
          local_file.write( http_client.get_content("https://<server>/nuget/<feed>/package/<package>/<version>") )
          

          -/- flagellum

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post
          Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation