]> git.ipfire.org Git - thirdparty/git.git/commit - t/t0300-credentials.sh
credential: gate new fields on capability
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 17 Apr 2024 00:02:29 +0000 (00:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Apr 2024 05:39:06 +0000 (22:39 -0700)
commitca9ccbf67450ffcda235970f0693794cee912562
tree22df00af83f47e3ef9a7e16f881ca0f199c76151
parent6a6d6fb12e485a580fc3f219cbee1575481b56eb
credential: gate new fields on capability

We support the new credential and authtype fields, but we lack a way to
indicate to a credential helper that we'd like them to be used.  Without
some sort of indication, the credential helper doesn't know if it should
try to provide us a username and password, or a pre-encoded credential.
For example, the helper might prefer a more restricted Bearer token if
pre-encoded credentials are possible, but might have to fall back to
more general username and password if not.

Let's provide a simple way to indicate whether Git (or, for that matter,
the helper) is capable of understanding the authtype and credential
fields.  We send this capability when we generate a request, and the
other side may reply to indicate to us that it does, too.

For now, don't enable sending capabilities for the HTTP code.  In a
future commit, we'll introduce appropriate handling for that code,
which requires more in-depth work.

The logic for determining whether a capability is supported may seem
complex, but it is not.  At each stage, we emit the capability to the
following stage if all preceding stages have declared it.  Thus, if the
caller to git credential fill didn't declare it, then we won't send it
to the helper, and if fill's caller did send but the helper doesn't
understand it, then we won't send it on in the response.  If we're an
internal user, then we know about all capabilities and will request
them.

For "git credential approve" and "git credential reject", we set the
helper capability before calling the helper, since we assume that the
input we're getting from the external program comes from a previous call
to "git credential fill", and thus we'll invoke send a capability to the
helper if and only if we got one from the standard input, which is the
correct behavior.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/credential-cache--daemon.c
builtin/credential-store.c
builtin/credential.c
credential.c
credential.h
http.c
imap-send.c
remote-curl.c
t/t0300-credentials.sh