master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
26#include "vauth/vauth.h"
27#include "creds.h"
28#include "curlx/multibyte.h"
29#include "url.h"
31/*
32 * Curl_auth_build_spn()
33 *
34 * This is used to build an SPN string in the following formats:
35 *
36 * service/host@realm (Not currently used)
37 * service/host (Not used by GSS-API)
38 * service@realm (Not used by Windows SSPI)
39 *
40 * Parameters:
41 *
42 * service [in] - The service type such as http, smtp, pop or imap.
43 * host [in] - The hostname.
44 * realm [in] - The realm.
45 *
46 * Returns a pointer to the newly allocated SPN.
47 */
48#ifndef USE_WINDOWS_SSPI
49char *Curl_auth_build_spn(const char *service, const char *host,
50 const char *realm)
51{
52 char *spn = NULL;
54 /* Generate our SPN */
55 if(host && realm)
56 spn = curl_maprintf("%s/%s@%s", service, host, realm);
57 else if(host)
58 spn = curl_maprintf("%s/%s", service, host);
59 else if(realm)
60 spn = curl_maprintf("%s@%s", service, realm);
62 /* Return our newly allocated SPN */
63 return spn;
64}
65#else
66TCHAR *Curl_auth_build_spn(const char *service, const char *host,
67 const char *realm)
68{
69 char *utf8_spn = NULL;
70 TCHAR *tchar_spn = NULL;
72 (void)realm;
74 /* Note: We could use DsMakeSPN() or DsClientMakeSpnForTargetServer() rather
75 than doing this ourselves but the first is only available in Windows XP
76 and Windows Server 2003 and the latter is only available in Windows 2000
77 but not Windows95/98/ME or Windows NT4.0 unless the Active Directory
78 Client Extensions are installed. As such it is far simpler for us to
79 formulate the SPN instead. */
81 /* Generate our UTF8 based SPN */
82 utf8_spn = curl_maprintf("%s/%s", service, host);
83 if(!utf8_spn)
84 return NULL;
86 /* Allocate and return a TCHAR based SPN. */
87 tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn);
88 curlx_free(utf8_spn);
90 return tchar_spn;
91}
92#endif /* USE_WINDOWS_SSPI */
94/*
95 * Curl_auth_user_contains_domain()
96 *
97 * This is used to test if the specified user contains a Windows domain name as
98 * follows:
99 *
100 * Domain\User (Down-level Logon Name)
101 * Domain/User (curl Down-level format - for compatibility with existing code)
102 * User@Domain (User Principal Name)
103 *
104 * Note: The username may be empty when using a GSS-API library or Windows
105 * SSPI as the user and domain are either obtained from the credentials cache
106 * when using GSS-API or via the currently logged in user's credentials when
107 * using Windows SSPI.
108 *
109 * Parameters:
110 *
111 * user [in] - The username.
112 *
113 * Returns TRUE on success; otherwise FALSE.
114 */
115bool Curl_auth_user_contains_domain(struct Curl_creds *creds)
116{
117 bool valid = FALSE;
119 if(Curl_creds_has_user(creds)) {
120 /* Check we have a domain name or UPN present */
121 const char *p = strpbrk(creds->user, "\\/@");
123 valid = p && (p > creds->user) &&
124 (p < (creds->user + strlen(creds->user) - 1));
125 }
126#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
127 else
128 /* User and domain are obtained from the GSS-API credentials cache or the
129 currently logged in user from Windows */
130 valid = TRUE;
131#endif
133 return valid;
134}
136/*
137 * Curl_auth_allowed_to_host() tells if authentication, cookies or other
138 * "sensitive data" can be sent to the connection's origin.
139 */
140bool Curl_auth_allowed_to_host(struct Curl_easy *data)
141{
142 return Curl_auth_allowed_to_origin(data, data->state.origin);
143}
145bool Curl_auth_allowed_to_origin(struct Curl_easy *data,
146 struct Curl_peer *origin)
147{
148 return data->set.allow_auth_to_other_hosts ||
149 Curl_peer_equal(data->state.initial_origin, origin);
150}
152#ifdef USE_KERBEROS5
153static void krb5_conn_dtor(const void *key, size_t klen, void *entry)
154{
155 struct kerberos5data *krb5 = entry;
156 (void)key;
157 (void)klen;
158 DEBUGASSERT(krb5);
159 Curl_auth_cleanup_gssapi(krb5);
160 curlx_free(krb5);
161}
163struct kerberos5data *Curl_auth_krb5_get(struct connectdata *conn)
164{
165 struct kerberos5data *krb5 = Curl_conn_meta_get(conn, CURL_META_KRB5_CONN);
166 if(!krb5) {
167 krb5 = curlx_calloc(1, sizeof(*krb5));
168 if(!krb5 ||
169 Curl_conn_meta_set(conn, CURL_META_KRB5_CONN, krb5, krb5_conn_dtor))
170 return NULL;
171 }
172 return krb5;
173}
174#endif /* USE_KERBEROS5 */
176#ifdef USE_GSASL
177static void gsasl_conn_dtor(const void *key, size_t klen, void *entry)
178{
179 struct gsasldata *gsasl = entry;
180 (void)key;
181 (void)klen;
182 DEBUGASSERT(gsasl);
183 Curl_auth_gsasl_cleanup(gsasl);
184 curlx_free(gsasl);
185}
187struct gsasldata *Curl_auth_gsasl_get(struct connectdata *conn)
188{
189 struct gsasldata *gsasl = Curl_conn_meta_get(conn, CURL_META_GSASL_CONN);
190 if(!gsasl) {
191 gsasl = curlx_calloc(1, sizeof(*gsasl));
192 if(!gsasl ||
193 Curl_conn_meta_set(conn, CURL_META_GSASL_CONN, gsasl, gsasl_conn_dtor))
194 return NULL;
195 }
196 return gsasl;
197}
198#endif /* USE_GSASL */
200#ifdef USE_SPNEGO
201static void nego_conn_dtor(const void *key, size_t klen, void *entry)
202{
203 struct negotiatedata *nego = entry;
204 (void)key;
205 (void)klen;
206 DEBUGASSERT(nego);
207 Curl_auth_cleanup_spnego(nego);
208 curlx_free(nego);
209}
211struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy)
212{
213 const char *key = proxy ? CURL_META_NEGO_PROXY_CONN : CURL_META_NEGO_CONN;
214 struct negotiatedata *nego = Curl_conn_meta_get(conn, key);
215 if(!nego) {
216 nego = curlx_calloc(1, sizeof(*nego));
217 if(!nego || Curl_conn_meta_set(conn, key, nego, nego_conn_dtor))
218 return NULL;
219 }
220 return nego;
221}
222#endif /* USE_SPNEGO */
Diagnostics4 git calls · 362 ms
CallStatusSizeTime0362 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 · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=356 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 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=86Open pack map
fetch2002.4 KiB357 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2451 git.response.cache=MISS git.response.duration_ms=357 git.fetch.wants=313f7b46f36e1ee654795e7b127a1343a89b9994 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=2451 git.pkt.payload.max=2430 git.sideband.band1.bytes=2429 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
- a5eafa486a43b1bb
- Request
- 6537a64d…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format