Private Ruby Gem Server with Authentication

2020-04-07 05:04发布

I want to install a private Ruby gem server with some authentication. I want to be able to host in-house gems using a public Ubuntu server.

I read about http://docs.rubygems.org/read/chapter/18. But there is no authentication with that one - as I can see.

Then I read about https://github.com/cwninja/geminabox. But when I use the basic authentication (they have in their Wiki), it complaints about fetching the sources from my server.

So. How can I make a private Ruby gem server with authentication? Is that just impossible?

Thanks.

Edit:

Geminabox problem. I try to "bundle" to install new gems... but it gives me this error:

AGs-MacBook-Pro:super_app AG$ bundle

Fetching source index for http:// rubygems.org/

Fetching source index for http:// localhost:9292/

Could not reach rubygems repository http:// rubygems.org/, http:// localhost:9292/

Could not find aglipsum-0.0.1 in any of the sources

And "aglipsum" is my custom gem. However when I do not have basic authentication on, it works.

5条回答
疯言疯语
2楼-- · 2020-04-07 05:35

Have you tried prefixing the source url with your basic auth credentials:

gem sources -a http://user:password@localhost:9292

This works for me with an apache + passanger setup.

查看更多
The star\"
3楼-- · 2020-04-07 05:40

Bundler version 1.6 added support for HTTP auth via bundle config.

查看更多
beautiful°
4楼-- · 2020-04-07 05:46

Deploy private rubygems repository

You can easily setup private rubygems repository from geminabox docker image:

docker run -d -v /path_where_to_store_gems:/webapps/geminabox/data --name geminabox -p 9292:9292 -P -h geminabox -e PRIVATE=true -e USERNAME=myuser -e PASSWORD=mypassword spoonest/geminabox:latest

don't forget to change:

  • /path_where_to_store_gems - path on your local machine where you want to store your gems
  • myuser - username
  • mypassword - password

That's all. Your repository is accessible by url http://YOUR_HOST:9292

Installing gems form private repository

Add following line at the top of your Gemfile:

source 'http://myuser:mypassword@YOUR_HOST:9292'

... and use bundle install as usual.

查看更多
叼着烟拽天下
5楼-- · 2020-04-07 05:50

Some professional binary repository managers, such as Artifactory, support private RubyGems repositories.

查看更多
▲ chillily
6楼-- · 2020-04-07 05:56

take a look if my fork of geminabox is what you need. I add the authentication for managing gems.

https://github.com/poshboytl/geminabox

查看更多
登录 后发表回答