diff options
| author | Philip Kelley <phkelley@hotmail.com> | 2012-11-08 08:06:23 -0800 |
|---|---|---|
| committer | Philip Kelley <phkelley@hotmail.com> | 2012-11-08 08:06:23 -0800 |
| commit | 9d6412832509ac3fb0217300eefbc75866dd7258 (patch) | |
| tree | a82a0b448b56713b1cf2ee25dd4da98e31ebe65b /include/git2 | |
| parent | 8ff2b0c75983160264ee7c45a01bde27cfbc91ea (diff) | |
| parent | 11fa84728312aecdd8bc038cebd3458ec162e603 (diff) | |
| download | libgit2-9d6412832509ac3fb0217300eefbc75866dd7258.tar.gz | |
Merge pull request #1048 from pwkelley/basic_auth
Basic authentication for http and winhttp
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/remote.h | 17 | ||||
| -rw-r--r-- | include/git2/transport.h | 49 |
2 files changed, 65 insertions, 1 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h index 1827e12b0..33b7dfdec 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -287,6 +287,19 @@ GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const cha GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check); /** + * Set a credentials acquisition callback for this remote. If the remote is + * not available for anonymous access, then you must set this callback in order + * to provide credentials to the transport at the time of authentication + * failure so that retry can be performed. + * + * @param remote the remote to configure + * @param The credentials acquisition callback to use (defaults to NULL) + */ +GIT_EXTERN(void) git_remote_set_cred_acquire_cb( + git_remote *remote, + git_cred_acquire_cb cred_acquire_cb); + +/** * Sets a custom transport for the remote. The caller can use this function * to bypass the automatic discovery of a transport by URL scheme (i.e. * http://, https://, git://) and supply their own transport to be used @@ -297,7 +310,9 @@ GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check); * @param remote the remote to configure * @param transport the transport object for the remote to use */ -GIT_EXTERN(int) git_remote_set_transport(git_remote *remote, git_transport *transport); +GIT_EXTERN(int) git_remote_set_transport( + git_remote *remote, + git_transport *transport); /** * Argument to the completion callback which tells it which operation diff --git a/include/git2/transport.h b/include/git2/transport.h index fd0d56fbe..b2bdaae71 100644 --- a/include/git2/transport.h +++ b/include/git2/transport.h @@ -20,6 +20,54 @@ GIT_BEGIN_DECL /* + *** Begin interface for credentials acquisition *** + */ + +typedef enum { + /* git_cred_userpass_plaintext */ + GIT_CREDTYPE_USERPASS_PLAINTEXT = 1, +} git_credtype_t; + +/* The base structure for all credential types */ +typedef struct git_cred { + git_credtype_t credtype; + void (*free)( + struct git_cred *cred); +} git_cred; + +/* A plaintext username and password */ +typedef struct git_cred_userpass_plaintext { + git_cred parent; + char *username; + char *password; +} git_cred_userpass_plaintext; + +/** + * Creates a new plain-text username and password credential object. + * + * @param cred The newly created credential object. + * @param username The username of the credential. + * @param password The password of the credential. + */ +GIT_EXTERN(int) git_cred_userpass_plaintext_new( + git_cred **cred, + const char *username, + const char *password); + +/** + * Signature of a function which acquires a credential object. + * + * @param cred The newly created credential object. + * @param url The resource for which we are demanding a credential. + * @param allowed_types A bitmask stating which cred types are OK to return. + */ +typedef int (*git_cred_acquire_cb)( + git_cred **cred, + const char *url, + int allowed_types); + +/* + *** End interface for credentials acquisition *** *** Begin base transport interface *** */ @@ -43,6 +91,7 @@ typedef struct git_transport { * direction. */ int (*connect)(struct git_transport *transport, const char *url, + git_cred_acquire_cb cred_acquire_cb, int direction, int flags); |
