Artifactspublic-v0

curl

master
ply4 git calls136 ms288 KiB2 cachedprotocol v2
75 lines2.9 KiBRaw

curl creds

Authorization credentials are kept in struct Curl_creds. This contains:

  • user: the username, maybe the empty string
  • passwd: the password, maybe the empty string
  • sasl_authzid: the SASL authz value, maybe the empty string
  • oauth_bearer: the OAUTH bearer token, maybe the empty string
  • source: where the credentials come from
  • refcount: a reference counter to link/unlink creds

With reference counting, creds can be linked in several places.

Two creds are the same if all values are equal apart from source and refcount. The comparison of strings is done via Curl_timestrcmp() to prevent side channel attacks.

creds locations

Credentials are kept in three places:

  • data->state.creds: the credentials to use for the transfer in talking to the origin (see PEERS)
  • conn->creds: the credentials tied to a connection (more below)
  • conn->*_proxy.creds: credentials used to talk to the conn->*_proxy.peer

data->state.creds

This creds instance is created when the transfer starts looking for a suitable connection. For an easy_perform() this may happen several times if, for example, http redirects are followed.

When an easy_perform() starts, the transfer's data->state.initial_origin peer is cleared. When creating the connection, data->state.origin is calculated (e.g. who the request talks to). If data->state.initial_origin is not set, the first data->state.origin is linked there. Now libcurl knows where the transfer initially talked to on all possible subsequent requests.

Credential information from CURLOPT_* settings is only applicable for the initial origin. Any followup request going to another origin must not use it. Therefore data->state.creds is only created from CURLOPT_* when current origin and initial origin match.

Without credentials from CURLOPT_*, the URL is inspected for user and password and netrc is consulted as well (when built in).

conn->creds

Once data->state.creds is known, the connection credentials are determined. For protocols that tie authorization to everything sent on a connection (protocols without flag PROTOPT_CREDSPERREQUEST), conn->creds is linked to data->state.creds. Only connections carrying the same credentials may be reused.

Protocols with flag PROTOPT_CREDSPERREQUEST leave conn->creds empty, as connections for such protocols may be reused with different credentials.

That being said, there are authentication schemes like NTLM and NEGOTIATE that tie credentials to a connection. Those do set conn->creds once they start to operate, preventing connection reuse from then on for transfers with different credentials.

conn->*_proxy.creds

Those are set during connection setup from the CURLOPT_* values. They do not require any "initial origin" handling as the origin of a proxy does not change for a transfer.

1<!--
2Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
4SPDX-License-Identifier: curl
5-->
7# curl `creds`
9Authorization credentials are kept in `struct Curl_creds`. This contains:
11* `user`: the username, maybe the empty string
12* `passwd`: the password, maybe the empty string
13* `sasl_authzid`: the SASL `authz` value, maybe the empty string
14* `oauth_bearer`: the OAUTH bearer token, maybe the empty string
15* `source`: where the credentials come from
16* `refcount`: a reference counter to link/unlink `creds`
18With reference counting, `creds` can be linked in several places.
20Two `creds` are the same if all values are equal apart from `source`
21and `refcount`. The comparison of strings is done via `Curl_timestrcmp()`
22to prevent side channel attacks.
24## `creds` locations
26Credentials are kept in three places:
28* `data->state.creds`: the credentials to use for the transfer in talking
29 to the `origin` (see PEERS)
30* `conn->creds`: the credentials tied to a connection (more below)
31* `conn->*_proxy.creds`: credentials used to talk to the `conn->*_proxy.peer`
33### `data->state.creds`
35This `creds` instance is created when the transfer starts looking for a
36suitable connection. For an `easy_perform()` this may happen several times
37if, for example, http redirects are followed.
39When an `easy_perform()` starts, the transfer's `data->state.initial_origin`
40peer is cleared. When creating the connection, `data->state.origin` is
41calculated (e.g. who the request talks to). If `data->state.initial_origin`
42is not set, the first `data->state.origin` is linked there.
43Now `libcurl` knows where
44the transfer initially talked to on all possible subsequent requests.
46Credential information from `CURLOPT_*` settings is only applicable for the
47initial origin. Any followup request going to another origin must not
48use it. Therefore `data->state.creds` is *only* created from `CURLOPT_*`
49when current origin and initial origin match.
51Without credentials from `CURLOPT_*`, the URL is inspected for user and
52password and `netrc` is consulted as well (when built in).
54### `conn->creds`
56Once `data->state.creds` is known, the connection credentials are
57determined. For protocols that tie authorization to everything sent
58on a connection (protocols without flag `PROTOPT_CREDSPERREQUEST`),
59`conn->creds` is linked to `data->state.creds`. Only connections
60carrying the same credentials may be reused.
62Protocols with flag `PROTOPT_CREDSPERREQUEST` leave `conn->creds` empty,
63as connections for such protocols may be reused with different
64credentials.
66That being said, there are authentication schemes like `NTLM` and
67`NEGOTIATE` that tie credentials to a connection. Those do set `conn->creds`
68once they start to operate, preventing connection reuse from then on
69for transfers with different credentials.
71### `conn->*_proxy.creds`
73Those are set during connection setup from the `CURLOPT_*` values. They
74do not require any "initial origin" handling as the origin of a proxy
75does not change for a transfer.
Diagnostics4 git calls · 136 ms
CallStatusSizeTime0136 ms
discover200152 B2 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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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=131
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
fetch2001.3 KiB131 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1382
git.response.cache=MISS
git.response.duration_ms=131
git.fetch.wants=5f4aa97885abe488c030dfe4aae6e5b6083a1670
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=1382
git.pkt.payload.max=1361
git.sideband.band1.bytes=1360
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
a5e2df0959f32308
Request
77fcea21…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format