Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions base/libgit2/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ function authenticate_userpass(creds::UserPasswordCredentials, libgit2credptr::P
isusedcreds = checkused!(creds)

if creds.prompt_if_incorrect
username = creds.user
userpass = creds.pass
username = Base.get(ENV, "AUTH_USER", creds.user)
userpass = Base.get(ENV, "AUTH_PASS", creds.pass)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these standard / common names? should the option here be documented? seems like there's potential for collision with other applications if these are always favored/tried by default

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've found some examples of these being used in other applications. Mostly I was following the naming conventions set by authenticate_ssh which uses SSL_KEY_PATH, SSH_PUB_KEY_PATH and SSH_KEY_PASS. I'm fine with making these Julia specific: JULIA_AUTH_USER and JULIA_AUTH_PASS.

(username === nothing) && (username = "")
(userpass === nothing) && (userpass = "")
if is_windows()
Expand All @@ -156,7 +156,7 @@ function authenticate_userpass(creds::UserPasswordCredentials, libgit2credptr::P
isnull(res) && return Cint(Error.EAUTH)
username, userpass = Base.get(res)
end
elseif isusedcreds
elseif isempty(username) || isempty(userpass) || isusedcreds
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Make a prompt occur right away if the cached credentials are empty

username = prompt("Username for '$schema$host'", default = isempty(username) ?
urlusername : username)
userpass = prompt("Password for '$schema$username@$host'", password=true)
Expand Down Expand Up @@ -229,7 +229,7 @@ function credentials_callback(libgit2credptr::Ptr{Ptr{Void}}, url_ptr::Cstring,
end

if isset(allowed_types, Cuint(Consts.CREDTYPE_USERPASS_PLAINTEXT))
defaultcreds = reset!(UserPasswordCredentials(true), -1)
defaultcreds = reset!(UserPasswordCredentials(true), 1)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Was set to -1 to trigger a prompt right away. Setting it to 1 allows the ENV variables (also cached creds) be attempted before a prompt occurs

credid = "$schema$host"
upcreds = get_creds!(creds, credid, defaultcreds)
# If there were stored SSH credentials, but we ended up here that must
Expand Down