Re: [PATCH] Add a credential-helper for KDE
- From
Jeff King <peff@peff.net>
- Date
- Aug 31, 2011, 01:42 UTC
- Message-ID
- <20110831014237.GA2519@sigill.intra.peff.net>
- In-Reply-To
- <4E594B5A.6070902@gmail.com>
On Sat, Aug 27, 2011 at 09:54:02PM +0200, Lukas Sandström wrote:
> This Python script plugs into the credentials API > of Git to ask the user for passwords with a nice > KDE password dialog.
Thanks for working on this.
> .../git-kde-credentials-helper.py | 122 ++++++++++++++++++++
Can we call it git-credential-kdewallet or similar? Then users can just do:
git config credential.helper kdewallet
(where "kdewallet" can be whatever you think is most appropriate; the key is naming it git-credential-*).
> 1 files changed, 122 insertions(+), 0 deletions(-) > create mode 100755 contrib/kde-credetials-helper/git-kde-credentials-helper.py
Minor typo in directory name.
Show 10 quoted lines
> + def check_wallet(self):
> + (res, data) = self.wallet.readMap(self.token)
> + if res != 0:
> + return None
> + try:
> + self.username = data[QString("username")]
> + self.password = data[QString("password")]
> + except KeyError:
> + return None
> + return self.username and self.passwordIf I am reading this correctly, you look up based purely on the context token. Which means that if I do something like this:
$ git push https://host.com/repo.git [enter username: user1, password: foo] $ git push https://user2@host.com/other-repo.git
We will invoke the helper as:
git credential-kdewallet --unique=https:host.com --username=user2
but the helper will ignore the "user2" bit, and return "user1 / foo".
The "cache" helper I wrote handles this situation better, by indexing both on the token and the username. I wonder if the username should become part of the token. Or if the token should really just become a canonicalized URL, minus the actual path. So the first one would get:
--unique=https://host.com
and the second would get:
--unique=https://user2@host.com
Then helpers wouldn't need to worry about doing anything special.
What do you think? Also, any comments in general on writing a helper? You are the first one besides me to do so. Did you find anything in the interface or the documentation confusing? Suggestions are very welcome, as nothing has been released yet and we're free to tweak as much as we want.
-Peff