summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2012-11-06 08:52:03 -0500
committerPhilip Kelley <phkelley@hotmail.com>2012-11-06 08:52:03 -0500
commit091361f569dd86e8550c04afb193bfb516a21a74 (patch)
treea6afafde40743ddde98fcb8e4d36031b6d7f47a0 /include/git2
parenta5e85d86b7e13352c553b0a43bc36fee5880b5c7 (diff)
downloadlibgit2-091361f569dd86e8550c04afb193bfb516a21a74.tar.gz
Basic authentication for http and winhttp
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/remote.h17
-rw-r--r--include/git2/transport.h49
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);