-
-
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
Separate SSH prompting from ENV logic #23737
Conversation
Code should be logically identical to the previous revision.
The credential code is very careful not to modify the saved credentials until the end of the callback. This was the only exception.
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.
Apart from a minor concern around test coverage this seems pretty good. This might also be a good time to fix some style issues with the rest of base, but I don't think it's huge priority.
end | ||
if !isfile(privatekey) | ||
response = Base.prompt("Private key location for '$prompt_url'", | ||
default=privatekey) |
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.
Might as well fix the spacing to better fit with the existing base julia style (e.g., default=privatekey
lined up with opening parenthesis).
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 ended up leaving the indentation for the default
keyword as is as it matches the winprompt
indentation.
# typically this will just annoy users. | ||
if !isfile(publickey) && isfile(privatekey) | ||
response = Base.prompt("Public key location for '$prompt_url'", | ||
default=publickey) |
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.
Same spacing issue.
@@ -1825,7 +1825,6 @@ mktempdir() do dir | |||
# User provides an empty private key which triggers a re-prompt | |||
challenges = [ | |||
"Private key location for '[email protected]':" => "\n", | |||
"Public key location for '[email protected]' [.pub]:" => "\n", |
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 understand that this test doesn't make sense now that we're only checking for the public key when the private key is provided, but don't we still need to check the public key prompting when a valid private key is provided?
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.
There is one test I can add for public keys at this point. There's one round left of refactoring that will allow me to add a few more tests which currently cause the credential_loop
to infinite loop.
base/libgit2/callbacks.jl
Outdated
if Sys.iswindows() | ||
response = Base.winprompt( | ||
"Your SSH Key requires a password, please enter it now:", | ||
"Passphrase required", privatekey; prompt_username = 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.
Spacing.
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.
Issue here is prompt_username = 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.
Yeah, and a few others. Looking at other places in base I'm guessing it should be.
response = Base.winprompt("Your SSH Key requires a password, ",
"please enter it now: Passphrase required",
privatekey; prompt_username=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.
One of the more extreme cases of this is in authenticate_userpass
:
response = Base.winprompt("Please enter your credentials for '$prompt_url'", "Credentials required",
isempty(username) ? p.username : username; prompt_username = true)
which would become the following in order to fit within the 92-limit:
response = Base.winprompt("Please enter your credentials for '$prompt_url'",
"Credentials required",
isempty(username) ? p.username : username;
prompt_username=true)
I think this is also acceptable in Base (I've been allowed to do this before):
response = Base.winprompt(
"Please enter your credentials for '$prompt_url'", "Credentials required",
isempty(username) ? p.username : username; prompt_username=true)
I'll note that the last example just slightly exceeds the 92-limit but I think is probably the most readable.
I'll try to strike a balance.
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.
Thanks.
Note: currently one the tests cannot be run.
I'll merge once the CI passes. |
Separating some of the SSH callback logic so that
allow_prompt
only enables/disables interactive user prompting. Other changes include:Part of #20725.