Skip to content

getCreds fails when CredentialManagers don't return optional fields #614

Closed

Description

@WillHipschman

The git credential doc (https://www.kernel.org/pub/software/scm/git/docs/git-credential.html
) doesn't list path, username, password, or url as required. Git successfully authenticates if a CredentialHelper does not write them to output.

git-lfs fails with the cryptic error "'git credential fill' error: exit status 128" when not all fields are written out. Should we match git's behavior?

Activity

  1. technoweenie commented on Aug 27, 2015

    @technoweenie
    Contributor

    So LFS should try git-credential as a last resort. If the credential helper isn't returning enough info, I'm not sure how else we can handle it. Do you think it'd be better to just ignore the error and let the command fail with an auth error?

  2. WillHipschman commented on Aug 27, 2015

    @WillHipschman
    Author

    I have a few thoughts:

    1. git successfully authenticates without extra fields (it only requires protocol and host I think). We should do the same thing git does.
    2. I think an auth error is better. Ideally we have an error that is "Your Credential Helper Gave Us Something We Didn't Expect". The credential helper is completing successfully and returning all the info it thinks should be needed--so the issue is in the auth chain. The 128 error is a generic "git didn't exit cleanly" which could mean any number of things.
    3. Given that CredHelpers can basically do whatever they want, we should expect them to fail and handle it gracefully when they don't match with what we expect.
  3. whoisj commented on Aug 27, 2015

    @whoisj

    Do you think it'd be better to just ignore the error and let the command fail with an auth error?

    This is what Git does, this is what users will expect. So, yes.

    I helped @WillHipschman debug the issue, it seems that if git-credential fill fails to write username=\npassword=\n git-lfs chokes. However, empty values are legal value and assuming empty == null is dangerous. Instead, the absence of the values printed should be treated as null while empty values should treated as empty values.

  4. technoweenie commented on Aug 28, 2015

    @technoweenie
    Contributor

    git successfully authenticates without extra fields (it only requires protocol and host I think). We should mirror them.

    How do you authenticate without a username or password?

  5. ethomson commented on Aug 28, 2015

    @ethomson

    How do you authenticate without a username or password?

    Avoiding the "why would you do this" aspect to this answer, certainly you can have a blank password in general.

    The more compelling use, here, is that git indicates that you should use the default credentials for Kerberos or NTLM authentication by specifying an empty username and password when prompted. This empty username and password can be round tripped by a credential helper, in which case you will never be prompted for this again and you'll just always do Kerberos.

  6. ethomson commented on Aug 28, 2015

    @ethomson

    I apologize for coming late to this conversation and with very little background, so if I'm misunderstanding your quote, I apologize.

    If the credential helper isn't returning enough info, I'm not sure how else we can handle it.

    This should be allowed per the spec, and you should just chain to the next one until you have enough data to perform the authentication:

    A helper is free to produce a subset, or even no values at all if it has nothing useful to provide.

  7. technoweenie commented on Aug 28, 2015

    @technoweenie
    Contributor

    The more compelling use, here, is that git indicates that you should use the default credentials for Kerberos or NTLM authentication by specifying an empty username and password when prompted.

    Ah, that makes sense. 👍 So if I'm understanding correctly, the flow should look like this:

    # FIRST TIME
    $ git push origin master
    # 'git-credential fill' is called
    # prompts for your username/password
    # you enter blank to trigger ntlm auth
    # 'git-credential accept' is called
    
    # SECOND TIME
    $ git push origin master
    # 'git-credential fill' returns blank username/password
    

    The 128 error is a generic "git didn't exit cleanly" which could mean any number of things.

    This 128 error is coming from git-credential. Discarding any error, or even just 128 exit codes is easy. It would suck to swallow up a legit error though.

  8. whoisj commented on Aug 28, 2015

    @whoisj

    Looking around a bit at the Git code it seems that git-credential emits an error message (aka a call to die) if the username or password values are not returned.

    https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/credential.c#L286

    Because it is a built-in, it always returns 128 on any non-ideal exit (even allowed and/or expected ones).

    https://github.com/git-for-windows/git/blob/master/usage.c#L34-L38

    I recommend that you wholly ignore the return code, and rely on parsing the data coming back from the helper.

  9. technoweenie commented on Aug 28, 2015

    @technoweenie
    Contributor

    This should be fixed in #611 (comment)

  10. technoweenie commented on Sep 3, 2015

    @technoweenie
    Contributor

    #611 has been merged. Let me know if you still have issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions