Git-Raw
view release on metacpan or search on metacpan
deps/libgit2/include/git2/credential.h view on Meta::CPAN
/**
* @file git2/credential.h
* @brief Git authentication & credential management
* @defgroup git_credential Authentication & credential management
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/**
* Supported credential types
*
* This represents the various types of authentication methods supported by
* the library.
*/
typedef enum {
/**
* A vanilla user/password request
* @see git_credential_userpass_plaintext_new
*/
GIT_CREDENTIAL_USERPASS_PLAINTEXT = (1u << 0),
/**
* An SSH key-based authentication request
* @see git_credential_ssh_key_new
*/
GIT_CREDENTIAL_SSH_KEY = (1u << 1),
/**
* An SSH key-based authentication request, with a custom signature
* @see git_credential_ssh_custom_new
*/
GIT_CREDENTIAL_SSH_CUSTOM = (1u << 2),
/**
* An NTLM/Negotiate-based authentication request.
* @see git_credential_default
*/
GIT_CREDENTIAL_DEFAULT = (1u << 3),
/**
* An SSH interactive authentication request
* @see git_credential_ssh_interactive_new
*/
GIT_CREDENTIAL_SSH_INTERACTIVE = (1u << 4),
/**
* Username-only authentication request
*
* Used as a pre-authentication step if the underlying transport
* (eg. SSH, with no username in its URL) does not know which username
* to use.
*
* @see git_credential_username_new
*/
GIT_CREDENTIAL_USERNAME = (1u << 5),
/**
* An SSH key-based authentication request
*
* Allows credentials to be read from memory instead of files.
* Note that because of differences in crypto backend support, it might
* not be functional.
*
* @see git_credential_ssh_key_memory_new
*/
GIT_CREDENTIAL_SSH_MEMORY = (1u << 6)
} git_credential_t;
/**
* The base structure for all credential types
*/
typedef struct git_credential git_credential;
typedef struct git_credential_userpass_plaintext git_credential_userpass_plaintext;
/** Username-only credential information */
typedef struct git_credential_username git_credential_username;
/** A key for NTLM/Kerberos "default" credentials */
typedef struct git_credential git_credential_default;
/**
* A ssh key from disk
*/
typedef struct git_credential_ssh_key git_credential_ssh_key;
/**
* Keyboard-interactive based ssh authentication
*/
typedef struct git_credential_ssh_interactive git_credential_ssh_interactive;
/**
* A key with a custom signature function
*/
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_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 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 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_credential_acquire_cb)(
git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
void *payload);
/**
* Free a credential.
*
* This is only necessary if you own the object; that is, if you are a
* transport.
*
* @param cred the object to free
*/
GIT_EXTERN(void) git_credential_free(git_credential *cred);
/**
* Check whether a credential object contains username information.
*
* @param cred object to check
* @return 1 if the credential object has non-NULL username, 0 otherwise
*/
GIT_EXTERN(int) git_credential_has_username(git_credential *cred);
/**
* Return the username associated with a credential object.
*
* @param cred object to check
* @return the credential username, or NULL if not applicable
*/
GIT_EXTERN(const char *) git_credential_get_username(git_credential *cred);
/**
* Create a new plain-text username and password credential object.
* The supplied credential parameter will be internally duplicated.
*
* @param out The newly created credential object.
* @param username The username of the credential.
* @param password The password of the credential.
* @return 0 for success or an error code for failure
*/
GIT_EXTERN(int) git_credential_userpass_plaintext_new(
git_credential **out,
const char *username,
const char *password);
/**
* Create a "default" credential usable for Negotiate mechanisms like NTLM
* or Kerberos authentication.
( run in 0.426 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )