diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2024-04-17 00:02:30 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-04-16 22:39:07 -0700 |
commit | 2ae6dc686d79a6dcf52e67dbe886f1bfca8876d5 (patch) | |
tree | 1e869a26ec3fa3ad0742f2513d938690c4180379 /credential.c | |
parent | ca9ccbf67450ffcda235970f0693794cee912562 (diff) | |
download | git-2ae6dc686d79a6dcf52e67dbe886f1bfca8876d5.tar.gz |
credential: add a field called "ephemeral"
Now that we have support for a wide variety of types of authentication,
it's important to indicate to other credential helpers whether they
should store credentials, since not every credential helper may
intuitively understand all possible values of the authtype field. Do so
with a boolean field called "ephemeral", to indicate whether the
credential is expected to be temporary.
For example, in HTTP Digest authentication, the Authorization header
value is based off a nonce. It isn't useful to store this value
for later use because reusing the credential long term will not result
in successful authentication due to the nonce necessarily differing.
An additional case is potentially short-lived credentials, which may
last only a few hours. It similarly wouldn't be helper for other
credential helpers to attempt to provide these much later.
We do still pass the value to "git credential store" or "git credential
erase", since it may be helpful to the original helper to know whether
the operation was successful.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'credential.c')
-rw-r--r-- | credential.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/credential.c b/credential.c index f5396629df..3531d74346 100644 --- a/credential.c +++ b/credential.c @@ -289,6 +289,8 @@ int credential_read(struct credential *c, FILE *fp, } else if (!strcmp(key, "path")) { free(c->path); c->path = xstrdup(value); + } else if (!strcmp(key, "ephemeral")) { + c->ephemeral = !!git_config_bool("ephemeral", value); } else if (!strcmp(key, "wwwauth[]")) { strvec_push(&c->wwwauth_headers, value); } else if (!strcmp(key, "capability[]") && !strcmp(value, "authtype")) { @@ -339,6 +341,8 @@ void credential_write(const struct credential *c, FILE *fp, credential_write_item(fp, "capability[]", "authtype", 0); credential_write_item(fp, "authtype", c->authtype, 0); credential_write_item(fp, "credential", c->credential, 0); + if (c->ephemeral) + credential_write_item(fp, "ephemeral", "1", 0); } credential_write_item(fp, "protocol", c->protocol, 1); credential_write_item(fp, "host", c->host, 1); |