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 module libgit2_d.sys.credential;
8 
9 
10 private static import libgit2_d.credential;
11 
12 /**
13  * @file git2/sys/cred.h
14  * @brief Git credentials low-level implementation
15  * @defgroup git_credential Git credentials low-level implementation
16  * @ingroup Git
17  * @{
18  */
19 extern (C):
20 nothrow @nogc:
21 package(libgit2_d):
22 
23 /**
24  * The base structure for all credential types
25  */
26 struct git_credential
27 {
28 	/**
29 	 * A type of credential
30 	 */
31 	libgit2_d.credential.git_credential_t credtype;
32 
33 	/**
34 	 * The deallocator for this type of credentials
35 	 */
36 	void function(.git_credential* cred) free;
37 }
38 
39 /**
40  * A plaintext username and password
41  */
42 struct git_credential_userpass_plaintext
43 {
44 	/**
45 	 * The parent credential
46 	 */
47 	.git_credential parent;
48 
49 	/**
50 	 * The username to authenticate as
51 	 */
52 	char* username;
53 
54 	/**
55 	 * The password to use
56 	 */
57 	char* password;
58 }
59 
60 /**
61  * Username-only credential information
62  */
63 struct git_credential_username
64 {
65 	/**
66 	 * The parent credential
67 	 */
68 	.git_credential parent;
69 
70 	/**
71 	 * The username to authenticate as.
72 	 *
73 	 * This member is treated as an array.
74 	 */
75 	char username;
76 }
77 
78 /**
79  * A ssh key from disk
80  */
81 struct git_credential_ssh_key
82 {
83 	/**
84 	 * The parent credential
85 	 */
86 	.git_credential parent;
87 
88 	/**
89 	 * The username to authenticate as
90 	 */
91 	char* username;
92 
93 	/**
94 	 * The path to a public key
95 	 */
96 	char* publickey;
97 
98 	/**
99 	 * The path to a private key
100 	 */
101 	char* privatekey;
102 
103 	/**
104 	 * Passphrase to decrypt the private key
105 	 */
106 	char* passphrase;
107 }
108 
109 /**
110  * Keyboard-interactive based ssh authentication
111  */
112 struct git_credential_ssh_interactive
113 {
114 	/**
115 	 * The parent credential
116 	 */
117 	.git_credential parent;
118 
119 	/**
120 	 * The username to authenticate as
121 	 */
122 	char* username;
123 
124 	/**
125 	 * Callback used for authentication.
126 	 */
127 	libgit2_d.credential.git_credential_ssh_interactive_cb prompt_callback;
128 
129 	/**
130 	 * Payload passed to prompt_callback
131 	 */
132 	void* payload;
133 }
134 
135 /**
136  * A key with a custom signature function
137  */
138 struct git_credential_ssh_custom
139 {
140 	/**
141 	 * The parent credential
142 	 */
143 	.git_credential parent;
144 
145 	/**
146 	 * The username to authenticate as
147 	 */
148 	char* username;
149 
150 	/**
151 	 * The public key data
152 	 */
153 	char* publickey;
154 
155 	/**
156 	 * Length of the public key
157 	 */
158 	size_t publickey_len;
159 
160 	/**
161 	 * Callback used to sign the data.
162 	 */
163 	libgit2_d.credential.git_credential_sign_cb sign_callback;
164 
165 	/**
166 	 * Payload passed to prompt_callback
167 	 */
168 	void* payload;
169 }