From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: Re: encrypted netrc for Git
Date: Fri, 15 Jul 2011 17:05:41 -0400 [thread overview]
Message-ID: <20110715210541.GD356@sigill.intra.peff.net> (raw)
In-Reply-To: <8762n379pa.fsf@lifelogs.com>
On Fri, Jul 15, 2011 at 12:08:49PM -0500, Ted Zlatanov wrote:
> JK> Check out:
>
> JK> https://github.com/peff/git/commits/jk/http-auth
>
> JK> which provides an interface for getting credentials from external
> JK> helpers.
>
> The API is good, but it's not clear from the docs how to configure
> credential helpers from the user side. From the tests it looks like you
> set GIT_ASKPASS to them, is that right? And you can also set
> credential.helper?
Yes, that is the documentation I need to write before I can send in the
patches. :)
The answer is that you use "credential.helper". For example:
$ git config credential.helper cache
$ git push https://your.server/repo.git
Username: <input your username>
Password: <input your password>
... push happens ...
[five minutes pass]
$ git push https://your.server/repo.git
... push happens, no auth required ...
> Where do those helpers fit with the .netrc file? Are they called before
> or after or instead of the .netrc parse?
They are what git provides to curl, either because we have "user@" in
the URL, or because we tried curl once and got an HTTP 401. Curl uses
netrc automagically behind the scenes.
So for a URL without "user@" I believe the order would be:
1. Curl tries the request with what's in your netrc (or maybe it
transparently requests and uses the netrc after getting a 401; I'm
not sure).
2. Curl gives us a 401, and we ask for credentials via getpass(). Or a
credential helper, if defined. Any username given in netrc will not
be considered a partial credential (i.e., you will be prompted for
username and password as if netrc didn't exist).
3. If those credentials fail (i.e., we get a 401 again), we quit.
> Linking these with external libraries like GPGME and the Secrets API
> will be pretty easy and improve the user experience. So I'll be glad to
> work on it and provide you with feedback.
Yes, exactly. I think somebody at GitHub will probably work on OS X
Keychain integration, too.
I personally use a home-grown password safe that is a searchable
gpg-encrypted file (which then gets unlocked by gpg-agent). My helper is
more or less:
-- >8 --
#!/bin/sh
unique=
for i in "$@"; do
case "$i" in
--unique=*) unique=${i#--unique=} ;;
esac
done
# find lines of the form
# example.com.username=me
# example.com.password=mypass
gpg -qd --no-tty $HOME/.pass.gpg |
sed -n 's/^$unique.//p
-- >8 --
(actually, my file format is quite a bit more complex and robust than
that, and I use a perl script to parse it instead of sed, but this was
meant to be illustrative of how simple it could be).
Obviously something integrated with the secrets API would be way nicer,
if you are running GNOME Keyring (that's part of why I pushed it out to
an external helper; there are nearly as many password wallet solutions
as there are users, and everybody will have their favorite).
> Would you be interested in pushing your patches further after the
> testing? They seem pretty complete.
Absolutely. I'm planning on finishing up the docs and posting the
patches in the next couple days, so hopefully they will get more
feedback and testing there, too.
-Peff
prev parent reply other threads:[~2011-07-15 21:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-01 13:59 [Wishlist] could git tell which password it is asking when asking a password Rémi Vanicat
2011-07-01 17:00 ` Junio C Hamano
2011-07-01 17:16 ` Junio C Hamano
2011-07-01 17:18 ` Shawn Pearce
2011-07-01 17:50 ` Junio C Hamano
2011-07-01 19:25 ` Rémi Vanicat
2011-07-01 20:01 ` Ted Zlatanov
2011-07-01 20:30 ` Junio C Hamano
2011-07-01 20:48 ` Jeff King
2011-07-01 20:46 ` Jeff King
2011-07-01 17:04 ` Ted Zlatanov
2011-07-14 14:05 ` encrypted netrc for Git (was: [Wishlist] could git tell which password it is asking when asking a password.) Ted Zlatanov
2011-07-14 15:00 ` Jeff King
2011-07-15 17:08 ` encrypted netrc for Git Ted Zlatanov
2011-07-15 21:05 ` Jeff King [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110715210541.GD356@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).