gemstash icon indicating copy to clipboard operation
gemstash copied to clipboard

Mirroring for repos requiring authentication

Open viraptor opened this issue 6 years ago • 2 comments

I couldn't find a description of how I could run gemstack mirroring for a specific rubygems repo which requires authentication.

I've got the credentials for the repo configured in ~/.bundle/config, but if I specify BUNDLE_MIRROR__.... for it as well, the download fails. Am I missing something trivial?

viraptor avatar Aug 29 '19 05:08 viraptor

I just figured out how to get this to work.

The credentials from ~/.bundle/config don't get used. Maybe that is due to bundler not passing them along to the mirror when using the simpler approach described here? https://github.com/rubygems/gemstash/blob/master/docs/gemstash-mirror.7.md

The solution that I found was to include the /upstream path when specifying the gemstash mirror and include the credentials in the CGI escaped URI.

So the configuration command will look something like:

bundle config mirror.https://private.gem.host http://localhost:9292/upstream/$(ruby -rcgi -e 'puts CGI.escape("https://user:[email protected]")')

tjwp avatar Dec 14 '19 14:12 tjwp

Recently tried doing the above to mirror our Gemfury repo which uses basic auth as well but just an api token of the form https://<api_token>@gem.fury.io/<repo>. Because the basic auth isn't of the form user:password, Faraday by default wasn't respecting it in the URL. I'm putting together a small PR that adds support for this, which should help anyone that using a private repo service like gemfury.

jebentier avatar Jun 08 '22 20:06 jebentier