diff options
Diffstat (limited to 'include/git2/transport.h')
-rw-r--r-- | include/git2/transport.h | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/include/git2/transport.h b/include/git2/transport.h index caabd0465..af7812b5d 100644 --- a/include/git2/transport.h +++ b/include/git2/transport.h @@ -41,6 +41,9 @@ typedef enum { /* git_cred_default */ GIT_CREDTYPE_DEFAULT = (1u << 3), + + /* git_cred_ssh_interactive */ + GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4), } git_credtype_t; /* The base structure for all credential types */ @@ -60,8 +63,10 @@ typedef struct { #ifdef GIT_SSH typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback)); +typedef LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*git_cred_ssh_interactive_callback)); #else typedef int (*git_cred_sign_callback)(void *, ...); +typedef int (*git_cred_ssh_interactive_callback)(void *, ...); #endif /** @@ -76,6 +81,16 @@ typedef struct git_cred_ssh_key { } git_cred_ssh_key; /** + * Keyboard-interactive based ssh authentication + */ +typedef struct git_cred_ssh_interactive { + git_cred parent; + char *username; + git_cred_ssh_interactive_callback prompt_callback; + void *payload; +} git_cred_ssh_interactive; + +/** * A key with a custom signature function */ typedef struct git_cred_ssh_custom { @@ -83,8 +98,8 @@ typedef struct git_cred_ssh_custom { char *username; char *publickey; size_t publickey_len; - void *sign_callback; - void *sign_data; + git_cred_sign_callback sign_callback; + void *payload; } git_cred_ssh_custom; /** A key for NTLM/Kerberos "default" credentials */ @@ -131,6 +146,33 @@ GIT_EXTERN(int) git_cred_ssh_key_new( const char *passphrase); /** + * Create a new ssh keyboard-interactive based credential object. + * The supplied credential parameter will be internally duplicated. + * + * @param username Username to use to authenticate. + * @param prompt_callback The callback method used for prompts. + * @param payload Additional data to pass to the callback. + * @return 0 for success or an error code for failure. + */ +GIT_EXTERN(int) git_cred_ssh_interactive_new( + git_cred **out, + const char *username, + git_cred_ssh_interactive_callback prompt_callback, + void *payload); + +/** + * Create a new ssh key credential object used for querying an ssh-agent. + * The supplied credential parameter will be internally duplicated. + * + * @param out The newly created credential object. + * @param username username to use to authenticate + * @return 0 for success or an error code for failure + */ +GIT_EXTERN(int) git_cred_ssh_key_from_agent( + git_cred **out, + const char *username); + +/** * Create an ssh key credential with a custom signing function. * * This lets you use your own function to sign the challenge. @@ -144,8 +186,8 @@ GIT_EXTERN(int) git_cred_ssh_key_new( * @param username username to use to authenticate * @param publickey The bytes of the public key. * @param publickey_len The length of the public key in bytes. - * @param sign_fn The callback method to sign the data during the challenge. - * @param sign_data The data to pass to the sign function. + * @param sign_callback The callback method to sign the data during the challenge. + * @param payload Additional data to pass to the callback. * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_ssh_custom_new( @@ -153,8 +195,8 @@ GIT_EXTERN(int) git_cred_ssh_custom_new( const char *username, const char *publickey, size_t publickey_len, - git_cred_sign_callback sign_fn, - void *sign_data); + git_cred_sign_callback sign_callback, + void *payload); /** * Create a "default" credential usable for Negotiate mechanisms like NTLM @@ -173,7 +215,8 @@ GIT_EXTERN(int) git_cred_default_new(git_cred **out); * remote url, or NULL if not included. * - allowed_types: A bitmask stating which cred types are OK to return. * - payload: The payload provided when specifying this callback. - * - returns 0 for success or non-zero to indicate an error + * - returns 0 for success, < 0 to indicate an error, > 0 to indicate + * no credential was acquired */ typedef int (*git_cred_acquire_cb)( git_cred **cred, @@ -244,7 +287,7 @@ struct git_transport { git_transport *transport, git_repository *repo, git_transfer_progress *stats, - git_transfer_progress_callback progress_cb, + git_transfer_progress_cb progress_cb, void *progress_payload); /* Checks to see if the transport is connected */ @@ -268,6 +311,18 @@ struct git_transport { #define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION} /** + * Initializes a `git_transport` with default values. Equivalent to + * creating an instance with GIT_TRANSPORT_INIT. + * + * @param opts the `git_transport` struct to initialize + * @param version Version of struct; pass `GIT_TRANSPORT_VERSION` + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_transport_init( + git_transport *opts, + unsigned int version); + +/** * Function to use to create a transport from a URL. The transport database * is scanned to find a transport that implements the scheme of the URI (i.e. * git:// or http://) and a transport object is returned to the caller. |