1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 #ifndef INCLUDE_sys_git_credential_h__ 8 #define INCLUDE_sys_git_credential_h__ 9 10 #include "git2/common.h" 11 #include "git2/credential.h" 12 13 /** 14 * @file git2/sys/cred.h 15 * @brief Git credentials low-level implementation 16 * @defgroup git_credential Git credentials low-level implementation 17 * @ingroup Git 18 * @{ 19 */ 20 GIT_BEGIN_DECL 21 22 /** 23 * The base structure for all credential types 24 */ 25 struct git_credential { 26 git_credential_t credtype; /**< A type of credential */ 27 28 /** The deallocator for this type of credentials */ 29 void GIT_CALLBACK(free)(git_credential *cred); 30 }; 31 32 /** A plaintext username and password */ 33 struct git_credential_userpass_plaintext { 34 git_credential parent; /**< The parent credential */ 35 char *username; /**< The username to authenticate as */ 36 char *password; /**< The password to use */ 37 }; 38 39 /** Username-only credential information */ 40 struct git_credential_username { 41 git_credential parent; /**< The parent credential */ 42 char username[1]; /**< The username to authenticate as */ 43 }; 44 45 /** 46 * A ssh key from disk 47 */ 48 struct git_credential_ssh_key { 49 git_credential parent; /**< The parent credential */ 50 char *username; /**< The username to authenticate as */ 51 char *publickey; /**< The path to a public key */ 52 char *privatekey; /**< The path to a private key */ 53 char *passphrase; /**< Passphrase to decrypt the private key */ 54 }; 55 56 /** 57 * Keyboard-interactive based ssh authentication 58 */ 59 struct git_credential_ssh_interactive { 60 git_credential parent; /**< The parent credential */ 61 char *username; /**< The username to authenticate as */ 62 63 /** 64 * Callback used for authentication. 65 */ 66 git_credential_ssh_interactive_cb prompt_callback; 67 68 void *payload; /**< Payload passed to prompt_callback */ 69 }; 70 71 /** 72 * A key with a custom signature function 73 */ 74 struct git_credential_ssh_custom { 75 git_credential parent; /**< The parent credential */ 76 char *username; /**< The username to authenticate as */ 77 char *publickey; /**< The public key data */ 78 size_t publickey_len; /**< Length of the public key */ 79 80 /** 81 * Callback used to sign the data. 82 */ 83 git_credential_sign_cb sign_callback; 84 85 void *payload; /**< Payload passed to prompt_callback */ 86 }; 87 88 GIT_END_DECL 89 90 #endif 91