auth-git2

Easy authentication for [git2].

Authentication with [git2] can be quite difficult to implement correctly. This crate aims to make it easy.

In the simplest case, you can create a [GitAuthenticator] struct and directly use it for authentication. By default, it will enable all supported authentication mechanisms. You can run any git operation that requires authentication using the [GitAuthenticator::run_operation()] function.

Features

Example: Clone a repository with authentication

```rust use auth_git2::GitAuthenticator; use std::path::Path;

let gitconfig = git2::Config::opendefault()?; let repo = GitAuthenticator::default() .runoperation(&gitconfig, |credentials| { let mut remotecallbacks = git2::RemoteCallbacks::new(); remotecallbacks.credentials(credentials); let mut fetchoptions = git2::FetchOptions::new(); fetchoptions.remotecallbacks(remotecallbacks); let mut repobuilder = git2::build::RepoBuilder::new(); repobuilder.fetchoptions(fetchoptions);

    let url = "https://github.com/de-vri-es/auth-git2-rs";
    let path = Path::new("/tmp/auth-git2-rs");
    repo_builder.clone(url, path)
})?;

```