Thank you for the review, commenting inline. On Fri, Sep 28, 2018 at 3:29 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > Kyle Hubert <khubert@xxxxxxxxx> writes: > > > Subject: Re: [PATCH] Improvement to only call Git Credential Helper once > > Nobody will send in a patch to worsen things, so phrases like > "Improvement to" that convey no useful information has no place on > the title. > > There probably are multiple ways that credential helpers are not > called just once and many of them probably are legit (e.g. "get" is > not the only request one helper can receive). It is unclear why > "only call helper once" is an improvement unless the reader reads > more, which means the title could be a lot more improved. > > Side note: this matters because in "git shortlog --no-merges" > the title is the only thing you can tell your readers what > your contribution was about. Yes, thank you. I just joined the mailing list. I'm getting a sense for the style here. If this patch moves forward, I will rewrite the title. > > When calling the Git Credential Helper that is set in the git config, > > the get command can return a credential. Git immediately turns around > > and calls the store command, even though that credential was just > > retrieved by the Helper. > > Good summary of the current behaviour. A paragraph break here would > make the result easier to read. Check. > > This creates two side effects. First of all, > > if the Helper requires a passphrase, the user has to type it in > > twice. > > Hmph, because...? If I am reading the flow correctly, an > application would > > - call credential_fill(), which returns when both username and > password are obtained by a "get" request to one of the helpers. > > - use the credential to authenticate with a service and find that > it was accepted. > > - call credential_approve(), which does "store" to all the helpers. > > Where does the "twice" come from? > > Ah, that is not between the application and the service, but between > the helper and the user you are required to "unlock" the helper? > > OK, that wish makes sense. > > It does not make much sense to ask helper A for credential and then > tell it to write it back the same thing. > > HOWEVER. Let me play a devil's advocate. > > The "store" does not have to necessarily mean "write it back", no? > > Imagine a helper that is connected to an OTP password device that > gives a different passcode every time button A is pressed, and there > are two other buttons B to tell the device that the password was > accepted and C to tell the device that the password was rejected > (i.e. we are out of sync). "get" would press button A and read the > output, "store" would press button B and "erase" would press button > C, I would imagine. With the current credential.c framework, you > can construct such a helper. The proposed patch that stops calling > "store" unconditionally makes it impossible to build. This example helper would require knowing external state between button pushes. What about aborting the operation? Regardless of the example, I can understand your concern. If a helper depended on receiving confirmation and rejection, this change would break that behavior. The patch is intended to address the common problem of a multi-user system running on a server in headless mode, in other words, without libsecret available via DBus. As such, this patch could eliminate having to double type passwords for every git operation accessing the stored credential. > > Secondly, if the user has a number of helpers, this retrieves > > the credential from one service and writes it to all services. > > It is unclear why you think it is a bad thing. You need to > elaborate. > > On the other hand, I can think of a case to illustrate why it is a > bad idea to unconditionally stop calling "store" to other helpers. > If one helper is a read-only "encrypted on disk" one, you may want > to require passphrase to "decrypt" to implement the "get" request to > the helper. You would then overlay a "stay only in-core for a short > time" helper and give higher priority to it. > > By doing so, on the first "get" request will ask the in-core one, > which says "I dunno", then the encrypted-on-disk one interacts with > the end-user and gives the credential. The current code "store"s to > the in-core one as well as the encrypted-on-disk one, and second and > subseqhent "get" request can be served from that in-core helper. > > Side note: and the "store" to encrypted-on-disk one may not > even need passphrase, even if "get" from it may need one. > > "We got the credential from some helper, so we won't call store" > makes it impossible to build such an arrangement. > > The above is a devil's advocate response in that I do not mean to > say that your proposed workaround does not solve *your* immediate > need, but to point out that you are closing many doors for needs > other people would have, or needs they already satisfy by taking > advantage of the current behaviour the proposed patch is breaking. This seems very valid, I like the configuration your propose. The argument for not storing to all helpers is to prevent leaking credentials across many key stores. In some cases, a developer can short cut looking up the plain text credential, and instead copy the encrypted credential to a new server. This behavior can lead to copying to a local development machine which is not headless, and does have an OS keychain available. If allowed to write the secret credential to all available helpers, this will leak the credential to the developers local machine. > So, I dunno. I certainly do not think it is a bad idea to stop > feeding _other_ helpers. I also do not think it is a good idea to > unconditionally stop calling "store" to the same helper, but I can > see the benefit for having an option to skip "store" to the same > helper. I am not sure if there should be an option to stop feeding > other helpers. I understand your thinking. Is there code you can point me to that would allow referencing an option to specific helpers? Maybe it could be reasoned that configuration could dictate not leaking credentials, and retrieval doesn't need confirmation. Thank you for your review, -Kyle