-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
end | ||
|
||
return Nullable{String}() | ||
end |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gethelpers
and getusername
?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
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. |
base/libgit2/gitcredential.jl
Outdated
# Provide the helper with the credential information we know | ||
write(input, cred) | ||
write(input, "\n") | ||
close(input) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
There was a problem hiding this 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
Should this be squashed? |
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
111bc48
to
9b52df7
Compare
Base.warn_once("Resetting the helper list is currently unsupported: " * | ||
"ignoring all git credential helpers.") | ||
return GitCredentialHelper[] | ||
end |
There was a problem hiding this comment.
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.
Addressed comments, rebased, and squashed. @vtjnash can you verify that the deadlock has been addressed? |
Yep, looks good. |
Will merge soon. |
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