credential: add a field for pre-encoded credentials
commit6a6d6fb12e485a580fc3f219cbee1575481b56eb
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 17 Apr 2024 00:02:28 +0000 (17 00:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Apr 2024 05:39:06 +0000 (16 22:39 -0700)
tree59b62dc7ec3e3450e1d213d26c9511e86ef59559
parentd01c76f1cfc96ba56f1c7c0e1b051d121ba6cc48
credential: add a field for pre-encoded credentials

At the moment, our credential code wants to find a username and password
for access, which, for HTTP, it will pass to libcurl to encode and
process.  However, many users want to use authentication schemes that
libcurl doesn't support, such as Bearer authentication.  In these
schemes, the secret is not a username and password pair, but some sort
of token that meets the production for authentication data in the RFC.

In fact, in general, it's useful to allow our credential helper to have
knowledge about what specifically to put in the protocol header.  Thus,
add a field, credential, which contains data that's preencoded to be
suitable for the protocol in question.  If we have such data, we need
neither a username nor a password, so make that adjustment as well.

It is in theory possible to reuse the password field for this.  However,
if we do so, we must know whether the credential helper supports our new
scheme before sending it data, which necessitates some sort of
capability inquiry, because otherwise an uninformed credential helper
would store our preencoded data as a password, which would fail the next
time we attempted to connect to the remote server.  This design is
substantially simpler, and we can hint to the credential helper that we
support this approach with a simple new field instead of needing to
query it first.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
credential.c
credential.h