Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Pushing to 'allowed_push_host' without rubygems.org credentails fails #4437

Closed
callahat opened this issue Apr 13, 2016 · 5 comments
Closed

Comments

@callahat
Copy link

Without a rubygems_api_key a gem cannot be published to the host specified by the allowed_push_host. I was able to verify that with a valid key in ~/.gem/credentials I am able to publish instead to the geminabox server (and it doesn't wind up on rubygems.org). Line is here: https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb#L95

@Cohen-Carlisle
Copy link
Contributor

It would be nice to have this addressed.
Its a bit scary when you are prompted for Rubygems credentials when you are trying to push to a private gemserver.
I can also envision a situation in which someone sets their rubygem creds to be able to push to a private gemserver and then later forgets to set allowed_push_host in some gem and ends up pushing potentially proprietary code to a public gemserver.
👍

@Cohen-Carlisle
Copy link
Contributor

It looks like simply moving the linked line down to after the if @gemspec.respond_to?(:metadata)'s end and checking allowed_push_host as well would work. I.e.,

def rubygem_push(path)
  allowed_push_host = nil
  gem_command = "gem push '#{path}'"
  if @gemspec.respond_to?(:metadata)
    allowed_push_host = @gemspec.metadata["allowed_push_host"]
    gem_command += " --host #{allowed_push_host}" if allowed_push_host
  end
  unless allowed_push_host || Pathname.new("~/.gem/credentials").expand_path.file?
    raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
  end
  sh(gem_command)
  Bundler.ui.confirm "Pushed #{name} #{version} to #{allowed_push_host ? allowed_push_host : "rubygems.org."}"
end

@segiddins
Copy link
Member

@Cohen-Carlisle a PR for that would be 🚀

@Cohen-Carlisle
Copy link
Contributor

What branch(es?) should a PR addressing this issue be against?

@segiddins
Copy link
Member

Master

homu added a commit that referenced this issue May 15, 2016
don't error on missing rubygem cred if custom host

only raise error asking user to set rubygem credentials during gem push
if `allowed_push_host` is not set.

Fixes #4437

Apologies if this is a half baked PR.
- I looked around to add tests for this, but there is little test coverage over this area I simply wasn't sure how to add a test around this particular change.
- I also wasn't sure where to put this in the `CHANGELOG` as the latest entry there is already released.
segiddins pushed a commit that referenced this issue May 16, 2016
don't error on missing rubygem cred if custom host

only raise error asking user to set rubygem credentials during gem push
if `allowed_push_host` is not set.

Fixes #4437

Apologies if this is a half baked PR.
- I looked around to add tests for this, but there is little test coverage over this area I simply wasn't sure how to add a test around this particular change.
- I also wasn't sure where to put this in the `CHANGELOG` as the latest entry there is already released.
hsbt pushed a commit to rubygems/bundler-graph that referenced this issue Oct 19, 2021
don't error on missing rubygem cred if custom host

only raise error asking user to set rubygem credentials during gem push
if `allowed_push_host` is not set.

Fixes rubygems/bundler#4437

Apologies if this is a half baked PR.
- I looked around to add tests for this, but there is little test coverage over this area I simply wasn't sure how to add a test around this particular change.
- I also wasn't sure where to put this in the `CHANGELOG` as the latest entry there is already released.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants