You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to overwrite the default authentication based on remote url. For instance, I have a url like git@... which means git2-rs will expect to authenticate through ssh with user git. I want to be able to login using plain username and password instead like the example below.
I tried the following:
cb.credentials(|_url, _username_from_url, _allowed_types| {
log::debug!("url is: {}", _url);
log::debug!("username from url is: {}", _username_from_url.unwrap_or("Not defined"));
log::debug!("allowed types are: {:#?}", _allowed_types);
let mut cred = git2::Cred::userpass_plaintext("username", "password"); an https address 'url = https://git.cscs.ch/msopena/manta.git' makes library to switch to CredentialType::USER_PASS_PLAINTEXT
let cred_aux: git2::Cred = cred.unwrap();
log::debug!("credentials type: {}", &cred_aux.credtype());
log::debug!("credentials username: {}", &cred_aux.has_username());
Ok(cred_aux)
});
and this is what I get
[2022-10-05T16:22:29Z DEBUG manta::git2_rs_utils::local] url is: git@...
[2022-10-05T16:22:29Z DEBUG manta::git2_rs_utils::local] username from url is: git
[2022-10-05T16:22:29Z DEBUG manta::git2_rs_utils::local] allowed types are: USER_PASS_PLAINTEXT | SSH_KEY | SSH_MEMORY | SSH_CUSTOM
[2022-10-05T16:22:29Z DEBUG manta::git2_rs_utils::local] credentials type: 1
[2022-10-05T16:22:29Z DEBUG manta::git2_rs_utils::local] credentials username: true
Error: Error { code: -1, klass: 23, message: "username does not match previous request" }
Any idea how can I force the git2-rs to use a different authentication type ignoring the username in the url?
The text was updated successfully, but these errors were encountered:
Masber
changed the title
how can I overwrite the url username and change authentication
how can I fallback authentication from ssh to plain username and password if no ssh key valid found
Oct 5, 2022
I would like to overwrite the default authentication based on remote url. For instance, I have a url like git@... which means git2-rs will expect to authenticate through ssh with user git. I want to be able to login using plain username and password instead like the example below.
I tried the following:
and this is what I get
Any idea how can I force the git2-rs to use a different authentication type ignoring the username in the url?
The text was updated successfully, but these errors were encountered: