-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
LibGit2 user/password authentication with ENV variables #20769
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
| (username === nothing) && (username = "") | ||
| (userpass === nothing) && (userpass = "") | ||
| if is_windows() | ||
|
|
@@ -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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
@@ -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) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
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.
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
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've found some examples of these being used in other applications. Mostly I was following the naming conventions set by
authenticate_sshwhich usesSSL_KEY_PATH,SSH_PUB_KEY_PATHandSSH_KEY_PASS. I'm fine with making these Julia specific:JULIA_AUTH_USERandJULIA_AUTH_PASS.