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

Integrate Git credential helper support #23824

Merged
merged 1 commit into from
Oct 26, 2017
Merged

Conversation

omus
Copy link
Member

@omus omus commented Sep 22, 2017

Integrate Git credential helper support which allows HTTPS credentials to be cached similarly to SSH agent. The integration is optional and only is enabled if a user has specified helpers to use in their git configuration. Note that with this integration credential information entered in the Julia prompts can be saved and used by any tools which integration git credential helpers (e.g. git).

Additionally there exists a "osxkeychain" helper which would allow Julia to pull credentials from the OS X keychain.

Replaces #20725

@omus omus added the libgit2 The libgit2 library or the LibGit2 stdlib module label Sep 22, 2017
end

return Nullable{String}()
end
Copy link
Member Author

Choose a reason for hiding this comment

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

I need to think of a better name for this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about just helpers and username since you aren't exporting these methods and they make sense within the LibGit2 module?

Copy link
Member Author

Choose a reason for hiding this comment

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

My only issue is that those are good variable names.

Copy link
Contributor

Choose a reason for hiding this comment

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

gethelpers and getusername?

Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed these to credential_helpers and default_username.

value = unsafe_string(ce.value)

return (section, subsection, name, value)
end
Copy link
Member Author

Choose a reason for hiding this comment

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

split is probably not the right name for this function. Suggestions welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think split makes sense. I'm imagining this working similar to urlsplit in python's urllib.

test/libgit2.jl Outdated
success(`git --version`)
catch
false
end
Copy link
Member Author

Choose a reason for hiding this comment

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

I could revise these tests not to use git. That would involve making a custom helper just for these tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, I don't think that's necessary as I'm guessing git is already required for building and testing julia. I'm guessing it should probably be explicitly listed in the README though?

Copy link
Member Author

Choose a reason for hiding this comment

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

git isn't a requirement for building Julia. I think you could just the GitHub "Download Zip" link to build Julia without git.

Copy link
Contributor

@rofinn rofinn left a comment

Choose a reason for hiding this comment

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

This all seems pretty reasonable. I'd feel more comfortable approving this if julia had a SecureString type that handled the securezero! and finalization step for credential strings.

end

return Nullable{String}()
end
Copy link
Contributor

Choose a reason for hiding this comment

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

What about just helpers and username since you aren't exporting these methods and they make sense within the LibGit2 module?

value = unsafe_string(ce.value)

return (section, subsection, name, value)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I think split makes sense. I'm imagining this working similar to urlsplit in python's urllib.

test/libgit2.jl Outdated
success(`git --version`)
catch
false
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, I don't think that's necessary as I'm guessing git is already required for building and testing julia. I'm guessing it should probably be explicitly listed in the README though?

test/libgit2.jl Outdated
@@ -2001,7 +2194,8 @@ mktempdir() do dir
function gen_ex(; username="git")
quote
include($LIBGIT2_HELPER_PATH)
payload = CredentialPayload(allow_ssh_agent=true, allow_prompt=false)
payload = CredentialPayload(allow_prompt=false, allow_ssh_agent=true,
allow_git_helpers=false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation.

test/libgit2.jl Outdated
payload = CredentialPayload($cred, allow_ssh_agent=$allow_ssh_agent,
allow_prompt=$allow_prompt)
payload = CredentialPayload($cred, allow_prompt=$allow_prompt,
allow_ssh_agent=$allow_ssh_agent, allow_git_helpers=false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation.

@omus
Copy link
Member Author

omus commented Sep 29, 2017

I'll be on holidays for the next two weeks. This PR should be ready to merge (besides some minor naming changes) and I'll add the 1.0 milestone to ensure this doesn't get forgotten about.

@omus omus added this to the 1.0 milestone Sep 29, 2017
@JeffBezanson JeffBezanson added the triage This should be discussed on a triage call label Sep 29, 2017
# Provide the helper with the credential information we know
write(input, cred)
write(input, "\n")
close(input)
Copy link
Member

Choose a reason for hiding this comment

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

t = @async close(input), then wait(t) after close(output)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

need to avoid deadlock during process readwrite

@StefanKarpinski
Copy link
Member

Should this be squashed?

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Oct 5, 2017
@omus
Copy link
Member Author

omus commented Oct 5, 2017

Definitely can be squashed. I can take care of the changes after I’m back from holidays.

Allows HTTPS credentials to be cached similarly to SSH agent. The
integration is optional and only is enabled if a user has specified
helpers to use in their git configuration. Note that with this
integration credential information entered in the Julia prompts can be
saved and used by any tools which integration git credential helpers
(e.g. git).

Additionally there exists a "osxkeychain" helper which would allow Julia
to pull credentials from the OS X keychain.

---

Track GitConfig in CredentialPayload

In cases such as `fetch` or `push` this allows users of the payload
to use the repo level configuration instead of just the global
configuration.

Add split for LibGit2.ConfigEntry

Add GitCredential struct

Fill GitCredential instances via helpers

Switch to Nullable

The Git credential protocol treats empty strings as valid. All fields
of the GitCredential are Nullable to be able to distinguish between
missing and empty.

Integrate Git credential helper support

Needed to disable git credential helpers for most tests as this could
cause test credentials to get written to the user's credential store.

More GitCredentialHelper tests

Empty test
@omus omus force-pushed the cv/git-credential-helpers branch from 111bc48 to 9b52df7 Compare October 23, 2017 16:36
@omus omus changed the title RFC: Integrate Git credential helper support Integrate Git credential helper support Oct 23, 2017
Base.warn_once("Resetting the helper list is currently unsupported: " *
"ignoring all git credential helpers.")
return GitCredentialHelper[]
end
Copy link
Member Author

Choose a reason for hiding this comment

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

Due to a bug with libgit2 the configuration iterator may not return results in the order in which they were written in the configuration file. For credential helpers this is only an issue when trying to use the special empty string helper which indicates that all previous helpers should be ignored.

See: libgit2/libgit2#4361

Note that this warning does show up when running the tests.

@omus
Copy link
Member Author

omus commented Oct 23, 2017

Addressed comments, rebased, and squashed. @vtjnash can you verify that the deadlock has been addressed?

@vtjnash
Copy link
Member

vtjnash commented Oct 24, 2017

Yep, looks good.

@omus
Copy link
Member Author

omus commented Oct 26, 2017

Will merge soon.

@omus omus merged commit 1486ba9 into master Oct 26, 2017
@StefanKarpinski StefanKarpinski deleted the cv/git-credential-helpers branch October 26, 2017 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libgit2 The libgit2 library or the LibGit2 stdlib module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants