Artifactspublic-v0

curl

master
ply4 git calls36 ms290 KiB3 cachedprotocol v2
326 lines11 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
9 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10 *
11 * This software is licensed as described in the file COPYING, which
12 * you should have received as part of this distribution. The terms
13 * are also available at https://curl.se/docs/copyright.html.
14 *
15 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 * copies of the Software, and permit persons to whom the Software is
17 * furnished to do so, under the terms of the COPYING file.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 * SPDX-License-Identifier: curl
23 *
24 * RFC4752 The Kerberos V5 ("GSSAPI") SASL Mechanism
25 *
26 ***************************************************************************/
27#include "curl_setup.h"
29#if defined(HAVE_GSSAPI) && defined(USE_KERBEROS5)
31#include "vauth/vauth.h"
32#include "curl_sasl.h"
33#include "curl_gssapi.h"
34#include "curl_trc.h"
36#if defined(CURL_HAVE_DIAG) && defined(__APPLE__) && !defined(HAVE_GSSAPPLE)
37#pragma GCC diagnostic push
38#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
39#endif
41/*
42 * Curl_auth_is_gssapi_supported()
43 *
44 * This is used to evaluate if GSSAPI (Kerberos V5) is supported.
45 *
46 * Parameters: None
47 *
48 * Returns TRUE if Kerberos V5 is supported by the GSS-API library.
49 */
50bool Curl_auth_is_gssapi_supported(void)
52 return TRUE;
55/*
56 * Curl_auth_create_gssapi_user_message()
57 *
58 * This is used to generate an already encoded GSSAPI (Kerberos V5) user token
59 * message ready for sending to the recipient.
60 *
61 * Parameters:
62 *
63 * data [in] - The session handle.
64 * userp [in] - The username.
65 * passwdp [in] - The user's password.
66 * service [in] - The service type such as http, smtp, pop or imap.
67 * host [in[ - The hostname.
68 * mutual_auth [in] - Flag specifying whether or not mutual authentication
69 * is enabled.
70 * chlg [in] - Optional challenge message.
71 * krb5 [in/out] - The Kerberos 5 data struct being used and modified.
72 * out [out] - The result storage.
73 *
74 * Returns CURLE_OK on success.
75 */
76CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
77 struct Curl_creds *creds,
78 const char *default_service,
79 const char *host,
80 const bool mutual_auth,
81 const struct bufref *chlg,
82 struct kerberos5data *krb5,
83 struct bufref *out)
85 CURLcode result = CURLE_OK;
86 OM_uint32 major_status;
87 OM_uint32 minor_status;
88 OM_uint32 unused_status;
89 gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
90 gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
91 const char *service = Curl_creds_has_sasl_service(creds) ?
92 Curl_creds_sasl_service(creds) : default_service;
94 if(!krb5->spn) {
95 gss_buffer_desc spn_token = GSS_C_EMPTY_BUFFER;
97 /* Generate our SPN */
98 char *spn = Curl_auth_build_spn(service, NULL, host);
99 if(!spn)
100 return CURLE_OUT_OF_MEMORY;
102 /* Populate the SPN structure */
103 spn_token.value = spn;
104 spn_token.length = strlen(spn);
106 /* Import the SPN */
107 major_status = gss_import_name(&minor_status, &spn_token,
108 GSS_C_NT_HOSTBASED_SERVICE, &krb5->spn);
109 if(GSS_ERROR(major_status)) {
110 Curl_gss_log_error(data, "gss_import_name() failed: ",
111 major_status, minor_status);
113 curlx_free(spn);
115 return CURLE_AUTH_ERROR;
116 }
118 curlx_free(spn);
119 }
121 if(chlg) {
122 if(!Curl_bufref_len(chlg)) {
123 infof(data, "GSSAPI handshake failure (empty challenge message)");
124 return CURLE_BAD_CONTENT_ENCODING;
125 }
126 input_token.value = CURL_UNCONST(Curl_bufref_ptr(chlg));
127 input_token.length = Curl_bufref_len(chlg);
128 }
130 major_status = Curl_gss_init_sec_context(data,
131 &minor_status,
132 &krb5->context,
133 krb5->spn,
134 &Curl_krb5_mech_oid,
135 GSS_C_NO_CHANNEL_BINDINGS,
136 &input_token,
137 &output_token,
138 mutual_auth,
139 NULL,
140 GSS_C_NO_CREDENTIAL);
142 if(GSS_ERROR(major_status)) {
143 if(output_token.value)
144 gss_release_buffer(&unused_status, &output_token);
146 Curl_gss_log_error(data, "gss_init_sec_context() failed: ",
147 major_status, minor_status);
149 return CURLE_AUTH_ERROR;
150 }
152 if(output_token.value && output_token.length) {
153 result = Curl_bufref_memdup0(out, output_token.value, output_token.length);
154 gss_release_buffer(&unused_status, &output_token);
155 }
156 else
157 Curl_bufref_set(out, mutual_auth ? "" : NULL, 0, NULL);
159 return result;
162/*
163 * Curl_auth_create_gssapi_security_message()
164 *
165 * This is used to generate an already encoded GSSAPI (Kerberos V5) security
166 * token message ready for sending to the recipient.
167 *
168 * Parameters:
169 *
170 * data [in] - The session handle.
171 * authzid [in] - The authorization identity if some.
172 * chlg [in] - Optional challenge message.
173 * krb5 [in/out] - The Kerberos 5 data struct being used and modified.
174 * out [out] - The result storage.
175 *
176 * Returns CURLE_OK on success.
177 */
178CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
179 const char *authzid,
180 const struct bufref *chlg,
181 struct kerberos5data *krb5,
182 struct bufref *out)
184 CURLcode result = CURLE_OK;
185 size_t messagelen = 0;
186 unsigned char *message = NULL;
187 OM_uint32 major_status;
188 OM_uint32 minor_status;
189 OM_uint32 unused_status;
190 gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
191 gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
192 unsigned char *indata;
193 gss_qop_t qop = GSS_C_QOP_DEFAULT;
194 unsigned int sec_layer = 0;
195 unsigned int max_size = 0;
197 /* Ensure we have a valid challenge message */
198 if(!Curl_bufref_len(chlg)) {
199 infof(data, "GSSAPI handshake failure (empty security message)");
200 return CURLE_BAD_CONTENT_ENCODING;
201 }
203 /* Setup the challenge "input" security buffer */
204 input_token.value = CURL_UNCONST(Curl_bufref_ptr(chlg));
205 input_token.length = Curl_bufref_len(chlg);
207 /* Decrypt the inbound challenge and obtain the qop */
208 major_status = gss_unwrap(&minor_status, krb5->context, &input_token,
209 &output_token, NULL, &qop);
210 if(GSS_ERROR(major_status)) {
211 Curl_gss_log_error(data, "gss_unwrap() failed: ",
212 major_status, minor_status);
213 return CURLE_BAD_CONTENT_ENCODING;
214 }
216 /* Not 4 octets long so fail as per RFC4752 Section 3.1 */
217 if(output_token.length != 4) {
218 infof(data, "GSSAPI handshake failure (invalid security data)");
219 gss_release_buffer(&unused_status, &output_token);
220 return CURLE_BAD_CONTENT_ENCODING;
221 }
223 /* Extract the security layer and the maximum message size */
224 indata = output_token.value;
225 sec_layer = indata[0];
226 max_size = ((unsigned int)indata[1] << 16) |
227 ((unsigned int)indata[2] << 8) | indata[3];
229 /* Free the challenge as it is not required anymore */
230 gss_release_buffer(&unused_status, &output_token);
232 /* Process the security layer */
233 if(!(sec_layer & GSSAUTH_P_NONE)) {
234 infof(data, "GSSAPI handshake failure (invalid security layer)");
236 return CURLE_BAD_CONTENT_ENCODING;
237 }
238 sec_layer &= GSSAUTH_P_NONE; /* We do not support a security layer */
240 /* Process the maximum message size the server can receive */
241 if(max_size > 0) {
242 /* The server has told us it supports a maximum receive buffer, but as we
243 do not require one unless we are encrypting data, we tell the server
244 our receive buffer is zero. */
245 max_size = 0;
246 }
248 /* Allocate our message */
249 messagelen = 4;
250 if(authzid)
251 messagelen += strlen(authzid);
252 message = curlx_malloc(messagelen);
253 if(!message)
254 return CURLE_OUT_OF_MEMORY;
256 /* Populate the message with the security layer and client supported receive
257 message size. */
258 message[0] = sec_layer & 0xFF;
259 message[1] = (max_size >> 16) & 0xFF;
260 message[2] = (max_size >> 8) & 0xFF;
261 message[3] = max_size & 0xFF;
263 /* If given, append the authorization identity. */
265 if(authzid && *authzid)
266 memcpy(message + 4, authzid, messagelen - 4);
268 /* Setup the "authentication data" security buffer */
269 input_token.value = message;
270 input_token.length = messagelen;
272 /* Encrypt the data */
273 major_status = gss_wrap(&minor_status, krb5->context, 0,
274 GSS_C_QOP_DEFAULT, &input_token, NULL,
275 &output_token);
276 if(GSS_ERROR(major_status)) {
277 Curl_gss_log_error(data, "gss_wrap() failed: ",
278 major_status, minor_status);
279 curlx_free(message);
280 return CURLE_AUTH_ERROR;
281 }
283 /* Return the response. */
284 result = Curl_bufref_memdup0(out, output_token.value, output_token.length);
285 /* Free the output buffer */
286 gss_release_buffer(&unused_status, &output_token);
288 /* Free the message buffer */
289 curlx_free(message);
291 return result;
294/*
295 * Curl_auth_cleanup_gssapi()
296 *
297 * This is used to clean up the GSSAPI (Kerberos V5) specific data.
298 *
299 * Parameters:
300 *
301 * krb5 [in/out] - The Kerberos 5 data struct being cleaned up.
302 *
303 */
304void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5)
306 OM_uint32 minor_status;
308 /* Free our security context */
309 if(krb5->context != GSS_C_NO_CONTEXT) {
310 Curl_gss_delete_sec_context(&minor_status, &krb5->context,
311 GSS_C_NO_BUFFER);
312 krb5->context = GSS_C_NO_CONTEXT;
313 }
315 /* Free the SPN */
316 if(krb5->spn != GSS_C_NO_NAME) {
317 gss_release_name(&minor_status, &krb5->spn);
318 krb5->spn = GSS_C_NO_NAME;
319 }
322#if defined(CURL_HAVE_DIAG) && defined(__APPLE__) && !defined(HAVE_GSSAPPLE)
323#pragma GCC diagnostic pop
324#endif
326#endif /* HAVE_GSSAPI && USE_KERBEROS5 */
Diagnostics4 git calls · 36 ms
CallStatusSizeTime036 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=30
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2003.2 KiB · hit30 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3242
git.response.cache=HIT
git.response.duration_ms=30
git.fetch.wants=6d9a125177430e169b38e018d91f56ccbd40d543
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=3242
git.pkt.payload.max=3221
git.sideband.band1.bytes=3220
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5eafa5f3b6fb1bb
Request
b2f7ef6a…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format