summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-01-18 13:51:40 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2020-01-26 18:39:41 +0000
commit3f54ba8b61869f42b2bbd1a60091a0be640bc8fc (patch)
treed2ea442f1ab5ecb7a0f8c10d3a26664bc4c44cdc /include
parent4460bf40c9e935acb853b5d61279a50014ede0b3 (diff)
downloadlibgit2-3f54ba8b61869f42b2bbd1a60091a0be640bc8fc.tar.gz
credential: change git_cred to git_credentialethomson/credtype
We avoid abbreviations where possible; rename git_cred to git_credential. In addition, we have standardized on a trailing `_t` for enum types, instead of using "type" in the name. So `git_credtype_t` has become `git_credential_t` and its members have become `GIT_CREDENTIAL` instead of `GIT_CREDTYPE`. Finally, the source and header files have been renamed to `credential` instead of `cred`. Keep previous name and values as deprecated, and include the new header files from the previous ones.
Diffstat (limited to 'include')
-rw-r--r--include/git2.h2
-rw-r--r--include/git2/cred_helpers.h46
-rw-r--r--include/git2/credential.h (renamed from include/git2/cred.h)112
-rw-r--r--include/git2/credential_helpers.h52
-rw-r--r--include/git2/deprecated.h77
-rw-r--r--include/git2/proxy.h4
-rw-r--r--include/git2/remote.h2
-rw-r--r--include/git2/sys/cred.h83
-rw-r--r--include/git2/sys/credential.h90
-rw-r--r--include/git2/sys/transport.h4
-rw-r--r--include/git2/transport.h2
11 files changed, 290 insertions, 184 deletions
diff --git a/include/git2.h b/include/git2.h
index 7f49f8faf..f39d7fbe2 100644
--- a/include/git2.h
+++ b/include/git2.h
@@ -22,7 +22,7 @@
#include "git2/commit.h"
#include "git2/common.h"
#include "git2/config.h"
-#include "git2/cred.h"
+#include "git2/credential.h"
#include "git2/deprecated.h"
#include "git2/describe.h"
#include "git2/diff.h"
diff --git a/include/git2/cred_helpers.h b/include/git2/cred_helpers.h
index 1416d5642..3721b6d8a 100644
--- a/include/git2/cred_helpers.h
+++ b/include/git2/cred_helpers.h
@@ -7,47 +7,9 @@
#ifndef INCLUDE_git_cred_helpers_h__
#define INCLUDE_git_cred_helpers_h__
-#include "transport.h"
-
-/**
- * @file git2/cred_helpers.h
- * @brief Utility functions for credential management
- * @defgroup git_cred_helpers credential management helpers
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-/**
- * Payload for git_cred_stock_userpass_plaintext.
- */
-typedef struct git_cred_userpass_payload {
- const char *username;
- const char *password;
-} git_cred_userpass_payload;
-
-
-/**
- * Stock callback usable as a git_cred_acquire_cb. This calls
- * git_cred_userpass_plaintext_new unless the protocol has not specified
- * `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type.
- *
- * @param cred The newly created credential object.
- * @param url The resource for which we are demanding a credential.
- * @param user_from_url The username that was embedded in a "user\@host"
- * remote url, or NULL if not included.
- * @param allowed_types A bitmask stating which cred types are OK to return.
- * @param payload The payload provided when specifying this callback. (This is
- * interpreted as a `git_cred_userpass_payload*`.)
- */
-GIT_EXTERN(int) git_cred_userpass(
- git_cred **cred,
- const char *url,
- const char *user_from_url,
- unsigned int allowed_types,
- void *payload);
-
+/* These declarations have moved. */
+#ifndef GIT_DEPRECATE_HARD
+# include "git2/credential_helpers.h"
+#endif
-/** @} */
-GIT_END_DECL
#endif
diff --git a/include/git2/cred.h b/include/git2/credential.h
index e89ab2361..9426a6ea2 100644
--- a/include/git2/cred.h
+++ b/include/git2/credential.h
@@ -4,15 +4,15 @@
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
-#ifndef INCLUDE_git_cred_h__
-#define INCLUDE_git_cred_h__
+#ifndef INCLUDE_git_credential_h__
+#define INCLUDE_git_credential_h__
#include "common.h"
/**
- * @file git2/cred.h
+ * @file git2/credential.h
* @brief Git authentication & credential management
- * @defgroup git_cred Authentication & credential management
+ * @defgroup git_credential Authentication & credential management
* @ingroup Git
* @{
*/
@@ -27,33 +27,33 @@ GIT_BEGIN_DECL
typedef enum {
/**
* A vanilla user/password request
- * @see git_cred_userpass_plaintext_new
+ * @see git_credential_userpass_plaintext_new
*/
- GIT_CREDTYPE_USERPASS_PLAINTEXT = (1u << 0),
+ GIT_CREDENTIAL_USERPASS_PLAINTEXT = (1u << 0),
/**
* An SSH key-based authentication request
- * @see git_cred_ssh_key_new
+ * @see git_credential_ssh_key_new
*/
- GIT_CREDTYPE_SSH_KEY = (1u << 1),
+ GIT_CREDENTIAL_SSH_KEY = (1u << 1),
/**
* An SSH key-based authentication request, with a custom signature
- * @see git_cred_ssh_custom_new
+ * @see git_credential_ssh_custom_new
*/
- GIT_CREDTYPE_SSH_CUSTOM = (1u << 2),
+ GIT_CREDENTIAL_SSH_CUSTOM = (1u << 2),
/**
* An NTLM/Negotiate-based authentication request.
- * @see git_cred_default
+ * @see git_credential_default
*/
- GIT_CREDTYPE_DEFAULT = (1u << 3),
+ GIT_CREDENTIAL_DEFAULT = (1u << 3),
/**
* An SSH interactive authentication request
- * @see git_cred_ssh_interactive_new
+ * @see git_credential_ssh_interactive_new
*/
- GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4),
+ GIT_CREDENTIAL_SSH_INTERACTIVE = (1u << 4),
/**
* Username-only authentication request
@@ -62,9 +62,9 @@ typedef enum {
* (eg. SSH, with no username in its URL) does not know which username
* to use.
*
- * @see git_cred_username_new
+ * @see git_credential_username_new
*/
- GIT_CREDTYPE_USERNAME = (1u << 5),
+ GIT_CREDENTIAL_USERNAME = (1u << 5),
/**
* An SSH key-based authentication request
@@ -73,62 +73,63 @@ typedef enum {
* Note that because of differences in crypto backend support, it might
* not be functional.
*
- * @see git_cred_ssh_key_memory_new
+ * @see git_credential_ssh_key_memory_new
*/
- GIT_CREDTYPE_SSH_MEMORY = (1u << 6),
-} git_credtype_t;
+ GIT_CREDENTIAL_SSH_MEMORY = (1u << 6),
+} git_credential_t;
/**
* The base structure for all credential types
*/
-typedef struct git_cred git_cred;
+typedef struct git_credential git_credential;
-typedef struct git_cred_userpass_plaintext git_cred_userpass_plaintext;
+typedef struct git_credential_userpass_plaintext git_credential_userpass_plaintext;
/** Username-only credential information */
-typedef struct git_cred_username git_cred_username;
+typedef struct git_credential_username git_credential_username;
/** A key for NTLM/Kerberos "default" credentials */
-typedef struct git_cred git_cred_default;
+typedef struct git_credential git_credential_default;
/**
* A ssh key from disk
*/
-typedef struct git_cred_ssh_key git_cred_ssh_key;
+typedef struct git_credential_ssh_key git_credential_ssh_key;
/**
* Keyboard-interactive based ssh authentication
*/
-typedef struct git_cred_ssh_interactive git_cred_ssh_interactive;
+typedef struct git_credential_ssh_interactive git_credential_ssh_interactive;
/**
* A key with a custom signature function
*/
-typedef struct git_cred_ssh_custom git_cred_ssh_custom;
+typedef struct git_credential_ssh_custom git_credential_ssh_custom;
/**
* Credential acquisition callback.
*
* This callback is usually involved any time another system might need
- * authentication. As such, you are expected to provide a valid git_cred
- * object back, depending on allowed_types (a git_credtype_t bitmask).
+ * authentication. As such, you are expected to provide a valid
+ * git_credential object back, depending on allowed_types (a
+ * git_credential_t bitmask).
*
* Note that most authentication details are your responsibility - this
* callback will be called until the authentication succeeds, or you report
* an error. As such, it's easy to get in a loop if you fail to stop providing
* the same incorrect credentials.
*
- * @param cred The newly created credential object.
+ * @param out The newly created credential object.
* @param url The resource for which we are demanding a credential.
* @param username_from_url The username that was embedded in a "user\@host"
* remote url, or NULL if not included.
- * @param allowed_types A bitmask stating which cred types are OK to return.
+ * @param allowed_types A bitmask stating which credential types are OK to return.
* @param payload The payload provided when specifying this callback.
* @return 0 for success, < 0 to indicate an error, > 0 to indicate
* no credential was acquired
*/
-typedef int GIT_CALLBACK(git_cred_acquire_cb)(
- git_cred **cred,
+typedef int GIT_CALLBACK(git_credential_acquire_cb)(
+ git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
@@ -142,7 +143,7 @@ typedef int GIT_CALLBACK(git_cred_acquire_cb)(
*
* @param cred the object to free
*/
-GIT_EXTERN(void) git_cred_free(git_cred *cred);
+GIT_EXTERN(void) git_credential_free(git_credential *cred);
/**
* Check whether a credential object contains username information.
@@ -150,7 +151,7 @@ GIT_EXTERN(void) git_cred_free(git_cred *cred);
* @param cred object to check
* @return 1 if the credential object has non-NULL username, 0 otherwise
*/
-GIT_EXTERN(int) git_cred_has_username(git_cred *cred);
+GIT_EXTERN(int) git_credential_has_username(git_credential *cred);
/**
* Return the username associated with a credential object.
@@ -158,7 +159,7 @@ GIT_EXTERN(int) git_cred_has_username(git_cred *cred);
* @param cred object to check
* @return the credential username, or NULL if not applicable
*/
-GIT_EXTERN(const char *) git_cred_get_username(git_cred *cred);
+GIT_EXTERN(const char *) git_credential_get_username(git_credential *cred);
/**
* Create a new plain-text username and password credential object.
@@ -169,8 +170,8 @@ GIT_EXTERN(const char *) git_cred_get_username(git_cred *cred);
* @param password The password of the credential.
* @return 0 for success or an error code for failure
*/
-GIT_EXTERN(int) git_cred_userpass_plaintext_new(
- git_cred **out,
+GIT_EXTERN(int) git_credential_userpass_plaintext_new(
+ git_credential **out,
const char *username,
const char *password);
@@ -178,17 +179,22 @@ GIT_EXTERN(int) git_cred_userpass_plaintext_new(
* Create a "default" credential usable for Negotiate mechanisms like NTLM
* or Kerberos authentication.
*
+ * @param out The newly created credential object.
* @return 0 for success or an error code for failure
*/
-GIT_EXTERN(int) git_cred_default_new(git_cred **out);
+GIT_EXTERN(int) git_credential_default_new(git_credential **out);
/**
* Create a credential to specify a username.
*
* This is used with ssh authentication to query for the username if
* none is specified in the url.
+ *
+ * @param out The newly created credential object.
+ * @param username The username to authenticate with
+ * @return 0 for success or an error code for failure
*/
-GIT_EXTERN(int) git_cred_username_new(git_cred **cred, const char *username);
+GIT_EXTERN(int) git_credential_username_new(git_credential **out, const char *username);
/**
* Create a new passphrase-protected ssh key credential object.
@@ -201,8 +207,8 @@ GIT_EXTERN(int) git_cred_username_new(git_cred **cred, const char *username);
* @param passphrase The passphrase of the credential.
* @return 0 for success or an error code for failure
*/
-GIT_EXTERN(int) git_cred_ssh_key_new(
- git_cred **out,
+GIT_EXTERN(int) git_credential_ssh_key_new(
+ git_credential **out,
const char *username,
const char *publickey,
const char *privatekey,
@@ -218,8 +224,8 @@ GIT_EXTERN(int) git_cred_ssh_key_new(
* @param passphrase The passphrase of the credential.
* @return 0 for success or an error code for failure
*/
-GIT_EXTERN(int) git_cred_ssh_key_memory_new(
- git_cred **out,
+GIT_EXTERN(int) git_credential_ssh_key_memory_new(
+ git_credential **out,
const char *username,
const char *publickey,
const char *privatekey,
@@ -235,7 +241,7 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT;
typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE;
#endif
-typedef void GIT_CALLBACK(git_cred_ssh_interactive_cb)(
+typedef void GIT_CALLBACK(git_credential_ssh_interactive_cb)(
const char *name,
int name_len,
const char *instruction, int instruction_len,
@@ -253,10 +259,10 @@ typedef void GIT_CALLBACK(git_cred_ssh_interactive_cb)(
* @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,
+GIT_EXTERN(int) git_credential_ssh_interactive_new(
+ git_credential **out,
const char *username,
- git_cred_ssh_interactive_cb prompt_callback,
+ git_credential_ssh_interactive_cb prompt_callback,
void *payload);
/**
@@ -267,11 +273,11 @@ GIT_EXTERN(int) git_cred_ssh_interactive_new(
* @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,
+GIT_EXTERN(int) git_credential_ssh_key_from_agent(
+ git_credential **out,
const char *username);
-typedef int GIT_CALLBACK(git_cred_sign_cb)(
+typedef int GIT_CALLBACK(git_credential_sign_cb)(
LIBSSH2_SESSION *session,
unsigned char **sig, size_t *sig_len,
const unsigned char *data, size_t data_len,
@@ -295,12 +301,12 @@ typedef int GIT_CALLBACK(git_cred_sign_cb)(
* @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(
- git_cred **out,
+GIT_EXTERN(int) git_credential_ssh_custom_new(
+ git_credential **out,
const char *username,
const char *publickey,
size_t publickey_len,
- git_cred_sign_cb sign_callback,
+ git_credential_sign_cb sign_callback,
void *payload);
/** @} */
diff --git a/include/git2/credential_helpers.h b/include/git2/credential_helpers.h
new file mode 100644
index 000000000..9a70ecb38
--- /dev/null
+++ b/include/git2/credential_helpers.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_credential_helpers_h__
+#define INCLUDE_git_credential_helpers_h__
+
+#include "transport.h"
+
+/**
+ * @file git2/credential_helpers.h
+ * @brief Utility functions for credential management
+ * @defgroup git_credential_helpers credential management helpers
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Payload for git_credential_userpass_plaintext.
+ */
+typedef struct git_credential_userpass_payload {
+ const char *username;
+ const char *password;
+} git_credential_userpass_payload;
+
+
+/**
+ * Stock callback usable as a git_credential_acquire_cb. This calls
+ * git_cred_userpass_plaintext_new unless the protocol has not specified
+ * `GIT_CREDENTIAL_USERPASS_PLAINTEXT` as an allowed type.
+ *
+ * @param out The newly created credential object.
+ * @param url The resource for which we are demanding a credential.
+ * @param user_from_url The username that was embedded in a "user\@host"
+ * remote url, or NULL if not included.
+ * @param allowed_types A bitmask stating which credential types are OK to return.
+ * @param payload The payload provided when specifying this callback. (This is
+ * interpreted as a `git_credential_userpass_payload*`.)
+ */
+GIT_EXTERN(int) git_credential_userpass(
+ git_credential **out,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index 7eb21dc9c..61d0115fd 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -33,6 +33,8 @@
#include "status.h"
#include "submodule.h"
#include "worktree.h"
+#include "credential.h"
+#include "credential_helpers.h"
/*
* Users can avoid deprecated functions by defining `GIT_DEPRECATE_HARD`.
@@ -359,7 +361,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
/**@}*/
-/** @name Deprecated Credential Callback Types
+/** @name Deprecated Credential Types
*
* These types are retained for backward compatibility. The newer
* versions of these values should be preferred in all new code.
@@ -368,8 +370,77 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
* this time.
*/
-typedef git_cred_sign_cb git_cred_sign_callback;
-typedef git_cred_ssh_interactive_cb git_cred_ssh_interactive_callback;
+typedef git_credential git_cred;
+typedef git_credential_userpass_plaintext git_cred_userpass_plaintext;
+typedef git_credential_username git_cred_username;
+typedef git_credential_default git_cred_default;
+typedef git_credential_ssh_key git_cred_ssh_key;
+typedef git_credential_ssh_interactive git_cred_ssh_interactive;
+typedef git_credential_ssh_custom git_cred_ssh_custom;
+
+typedef git_credential_acquire_cb git_cred_acquire_cb;
+typedef git_credential_sign_cb git_cred_sign_callback;
+typedef git_credential_sign_cb git_cred_sign_cb;
+typedef git_credential_ssh_interactive_cb git_cred_ssh_interactive_callback;
+typedef git_credential_ssh_interactive_cb git_cred_ssh_interactive_cb;
+
+#define git_credtype_t git_credential_t
+
+#define GIT_CREDTYPE_USERPASS_PLAINTEXT GIT_CREDENTIAL_USERPASS_PLAINTEXT
+#define GIT_CREDTYPE_SSH_KEY GIT_CREDENTIAL_SSH_KEY
+#define GIT_CREDTYPE_SSH_CUSTOM GIT_CREDENTIAL_SSH_CUSTOM
+#define GIT_CREDTYPE_DEFAULT GIT_CREDENTIAL_DEFAULT
+#define GIT_CREDTYPE_SSH_INTERACTIVE GIT_CREDENTIAL_SSH_INTERACTIVE
+#define GIT_CREDTYPE_USERNAME GIT_CREDENTIAL_USERNAME
+#define GIT_CREDTYPE_SSH_MEMORY GIT_CREDENTIAL_SSH_MEMORY
+
+GIT_EXTERN(void) git_cred_free(git_credential *cred);
+GIT_EXTERN(int) git_cred_has_username(git_credential *cred);
+GIT_EXTERN(const char *) git_cred_get_username(git_credential *cred);
+GIT_EXTERN(int) git_cred_userpass_plaintext_new(
+ git_credential **out,
+ const char *username,
+ const char *password);
+GIT_EXTERN(int) git_cred_default_new(git_credential **out);
+GIT_EXTERN(int) git_cred_username_new(git_credential **out, const char *username);
+GIT_EXTERN(int) git_cred_ssh_key_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase);
+GIT_EXTERN(int) git_cred_ssh_key_memory_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase);
+GIT_EXTERN(int) git_cred_ssh_interactive_new(
+ git_credential **out,
+ const char *username,
+ git_credential_ssh_interactive_cb prompt_callback,
+ void *payload);
+GIT_EXTERN(int) git_cred_ssh_key_from_agent(
+ git_credential **out,
+ const char *username);
+GIT_EXTERN(int) git_cred_ssh_custom_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ size_t publickey_len,
+ git_credential_sign_cb sign_callback,
+ void *payload);
+
+/* Deprecated Credential Helper Types */
+
+typedef git_credential_userpass_payload git_cred_userpass_payload;
+
+GIT_EXTERN(int) git_cred_userpass(
+ git_credential **out,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload);
/**@}*/
diff --git a/include/git2/proxy.h b/include/git2/proxy.h
index f959ae2e2..653425dee 100644
--- a/include/git2/proxy.h
+++ b/include/git2/proxy.h
@@ -10,7 +10,7 @@
#include "common.h"
#include "cert.h"
-#include "cred.h"
+#include "credential.h"
GIT_BEGIN_DECL
@@ -61,7 +61,7 @@ typedef struct {
* Returning GIT_PASSTHROUGH will make libgit2 behave as
* though this field isn't set.
*/
- git_cred_acquire_cb credentials;
+ git_credential_acquire_cb credentials;
/**
* If cert verification fails, this will be called to let the
diff --git a/include/git2/remote.h b/include/git2/remote.h
index f9454d6d5..54b6672b9 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -517,7 +517,7 @@ struct git_remote_callbacks {
* Returning GIT_PASSTHROUGH will make libgit2 behave as
* though this field isn't set.
*/
- git_cred_acquire_cb credentials;
+ git_credential_acquire_cb credentials;
/**
* If cert verification fails, this will be called to let the
diff --git a/include/git2/sys/cred.h b/include/git2/sys/cred.h
index 7636e79e4..4d2a59af7 100644
--- a/include/git2/sys/cred.h
+++ b/include/git2/sys/cred.h
@@ -7,84 +7,9 @@
#ifndef INCLUDE_sys_git_cred_h__
#define INCLUDE_sys_git_cred_h__
-#include "git2/common.h"
-#include "git2/cred.h"
-
-/**
- * @file git2/sys/cred.h
- * @brief Git credentials low-level implementation
- * @defgroup git_cred Git credentials low-level implementation
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-/**
- * The base structure for all credential types
- */
-struct git_cred {
- git_credtype_t credtype; /**< A type of credential */
-
- /** The deallocator for this type of credentials */
- void GIT_CALLBACK(free)(git_cred *cred);
-};
-
-/** A plaintext username and password */
-struct git_cred_userpass_plaintext {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
- char *password; /**< The password to use */
-};
-
-/** Username-only credential information */
-struct git_cred_username {
- git_cred parent; /**< The parent cred */
- char username[1]; /**< The username to authenticate as */
-};
-
-/**
- * A ssh key from disk
- */
-struct git_cred_ssh_key {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
- char *publickey; /**< The path to a public key */
- char *privatekey; /**< The path to a private key */
- char *passphrase; /**< Passphrase used to decrypt the private key */
-};
-
-/**
- * Keyboard-interactive based ssh authentication
- */
-struct git_cred_ssh_interactive {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
-
- /**
- * Callback used for authentication.
- */
- git_cred_ssh_interactive_cb prompt_callback;
-
- void *payload; /**< Payload passed to prompt_callback */
-};
-
-/**
- * A key with a custom signature function
- */
-struct git_cred_ssh_custom {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
- char *publickey; /**< The public key data */
- size_t publickey_len; /**< Length of the public key */
-
- /**
- * Callback used to sign the data.
- */
- git_cred_sign_cb sign_callback;
-
- void *payload; /**< Payload passed to prompt_callback */
-};
-
-GIT_END_DECL
+/* These declarations have moved. */
+#ifndef GIT_DEPRECATE_HARD
+# include "git2/sys/credential.h"
+#endif
#endif
diff --git a/include/git2/sys/credential.h b/include/git2/sys/credential.h
new file mode 100644
index 000000000..bb4c9f942
--- /dev/null
+++ b/include/git2/sys/credential.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_credential_h__
+#define INCLUDE_sys_git_credential_h__
+
+#include "git2/common.h"
+#include "git2/credential.h"
+
+/**
+ * @file git2/sys/cred.h
+ * @brief Git credentials low-level implementation
+ * @defgroup git_credential Git credentials low-level implementation
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * The base structure for all credential types
+ */
+struct git_credential {
+ git_credential_t credtype; /**< A type of credential */
+
+ /** The deallocator for this type of credentials */
+ void GIT_CALLBACK(free)(git_credential *cred);
+};
+
+/** A plaintext username and password */
+struct git_credential_userpass_plaintext {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+ char *password; /**< The password to use */
+};
+
+/** Username-only credential information */
+struct git_credential_username {
+ git_credential parent; /**< The parent credential */
+ char username[1]; /**< The username to authenticate as */
+};
+
+/**
+ * A ssh key from disk
+ */
+struct git_credential_ssh_key {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+ char *publickey; /**< The path to a public key */
+ char *privatekey; /**< The path to a private key */
+ char *passphrase; /**< Passphrase to decrypt the private key */
+};
+
+/**
+ * Keyboard-interactive based ssh authentication
+ */
+struct git_credential_ssh_interactive {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+
+ /**
+ * Callback used for authentication.
+ */
+ git_credential_ssh_interactive_cb prompt_callback;
+
+ void *payload; /**< Payload passed to prompt_callback */
+};
+
+/**
+ * A key with a custom signature function
+ */
+struct git_credential_ssh_custom {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+ char *publickey; /**< The public key data */
+ size_t publickey_len; /**< Length of the public key */
+
+ /**
+ * Callback used to sign the data.
+ */
+ git_credential_sign_cb sign_callback;
+
+ void *payload; /**< Payload passed to prompt_callback */
+};
+
+GIT_END_DECL
+
+#endif
diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h
index d7c7313af..6cee42f54 100644
--- a/include/git2/sys/transport.h
+++ b/include/git2/sys/transport.h
@@ -55,7 +55,7 @@ struct git_transport {
int GIT_CALLBACK(connect)(
git_transport *transport,
const char *url,
- git_cred_acquire_cb cred_acquire_cb,
+ git_credential_acquire_cb cred_acquire_cb,
void *cred_acquire_payload,
const git_proxy_options *proxy_opts,
int direction,
@@ -266,7 +266,7 @@ GIT_EXTERN(int) git_transport_smart_certificate_check(git_transport *transport,
* refused to provide credentials and callers should behave as if no
* callback was set), or < 0 for an error
*/
-GIT_EXTERN(int) git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods);
+GIT_EXTERN(int) git_transport_smart_credentials(git_credential **out, git_transport *transport, const char *user, int methods);
/**
* Get a copy of the proxy options
diff --git a/include/git2/transport.h b/include/git2/transport.h
index b99bb30e1..fc99ce8f3 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -11,7 +11,7 @@
#include "net.h"
#include "types.h"
#include "cert.h"
-#include "cred.h"
+#include "credential.h"
/**
* @file git2/transport.h