git2_auth

Crates.iogit2_auth
lib.rsgit2_auth
version0.1.0
sourcesrc
created_at2023-03-07 18:35:49.09009
updated_at2023-03-07 18:35:49.09009
descriptionA small library to provide easy to use callback handler to authenticate with git2-rs
homepage
repository
max_upload_size
id803816
size16,026
(kayagokalp-crates-io)

documentation

README

git2_auth

An authentication handler to be used with git2_rs. An example usage can be seen below. I used the following repos:

TODO

  • User defined ssh handlers
  • User provided username trials

Example Usage

// Setup remote callbacks
let mut callback = git2::RemoteCallbacks::new();
let config = git2::Config::open_default().unwrap();
// Setup authentication handler
let mut auth_handler = AuthHandler::default_with_config(config);
callback.credentials(move |url, username, allowed| {
    auth_handler.handle_callback(url, username, allowed)
});
// Create fetch options
let mut fetch_options = git2::FetchOptions::new();
fetch_options
    .remote_callbacks(callback)
    .download_tags(git2::AutotagOption::All)
    .update_fetchhead(true);
// Clone the repo
git2::build::RepoBuilder::new()
    .branch("master")
    .fetch_options(fetch_options)
    .clone("git@github.com:kayagokalp/git2_auth.git", dir.as_ref())
    .unwrap();

License

MIT

Commit count: 0

cargo fmt