Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github(login): Add a way to read ~/.netrc.gpg encrypted files #624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paulrbr-fl
Copy link

@paulrbr-fl paulrbr-fl commented Sep 14, 2018

Context

I usually don't store authentication information in plain text in my home directory. Instead most of my secrets are stored in *.gpg files which can be read by relevant applications if my GPG key has been unlocked in my X session.

The current implementation of travis.rb only reads ~/.netrc for --auto logins. It would be nice for the cli to also be able to read ~/.netrc.gpg file.

PR Content

This PR adds the gpgme gem as a dependency to be able to read *.gpg files if needs be.

Doubts

I am not sure requiring the gpgme gem in the gemspec is a good idea as it really depends on wether you have *.gpg files to read or not. Do you have a better idea on how we could do that?

Thanks!

@BanzaiMan
Copy link
Contributor

Hello, there. Sorry for the long delay.

gpgme doesn't appear to be supported by JRuby. Do you have any other option to read PGP/GPG-encrypted files? Calling out to shell is probably a viable option; presumably users who want such an option would have the necessary utility to do so.

@@ -278,11 +278,22 @@ def security(type, key, arg, name)
end

def file(path, default = nil)
path &&= File.expand_path(path)
gpg_path = File.expand_path("#{path}.gpg")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation checks for gpg-encrypted files on all #file calls, which is far more than just the credentials. I don't know if that is a good idea.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thanks for reviewing (and sorry for the delay!). I've changed the code to avoid this.

I usually don't store authentication information in plain text in my
home directory. Instead most of my secrets are stored in *.gpg files
which can be read by relevant applications if my GPG key has been
unlocked in my X session.

The current implementation of travis.rb only reads ~/.netrc for
`--auto` logins. It would be nice for the cli to also be able to read
`~/.netrc.gpg` file.

This PR adds a system (`Open3.capture3`) call to the `gpg` binary
because users using `*.gpg` files would probably always have the
binary available in their path.

Thanks!
@paulrbr-fl
Copy link
Author

gpgme doesn't appear to be supported by JRuby. Do you have any other option to read PGP/GPG-encrypted files? Calling out to shell is probably a viable option; presumably users who want such an option would have the necessary utility to do so.

Good point, I've implement a system call to gpg instead of adding the gpgme gem. What do you think now @BanzaiMan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants