2011-12-10 18:31:11 +08:00
|
|
|
#ifndef CREDENTIAL_H
|
|
|
|
#define CREDENTIAL_H
|
|
|
|
|
|
|
|
#include "string-list.h"
|
|
|
|
|
|
|
|
struct credential {
|
|
|
|
struct string_list helpers;
|
2011-12-10 18:31:24 +08:00
|
|
|
unsigned approved:1,
|
credential: make relevance of http path configurable
When parsing a URL into a credential struct, we carefully
record each part of the URL, including the path on the
remote host, and use the result as part of the credential
context.
This had two practical implications:
1. Credential helpers which store a credential for later
access are likely to use the "path" portion as part of
the storage key. That means that a request to
https://example.com/foo.git
would not use the same credential that was stored in an
earlier request for:
https://example.com/bar.git
2. The prompt shown to the user includes all relevant
context, including the path.
In most cases, however, users will have a single password
per host. The behavior in (1) will be inconvenient, and the
prompt in (2) will be overly long.
This patch introduces a config option to toggle the
relevance of http paths. When turned on, we use the path as
before. When turned off, we drop the path component from the
context: helpers don't see it, and it does not appear in the
prompt.
This is nothing you couldn't do with a clever credential
helper at the start of your stack, like:
[credential "http://"]
helper = "!f() { grep -v ^path= ; }; f"
helper = your_real_helper
But doing this:
[credential]
useHttpPath = false
is way easier and more readable. Furthermore, since most
users will want the "off" behavior, that is the new default.
Users who want it "on" can set the variable (either for all
credentials, or just for a subset using
credential.*.useHttpPath).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-10 18:31:34 +08:00
|
|
|
configured:1,
|
credential: let helpers tell us to quit
When we are trying to fill a credential, we loop over the
set of defined credential-helpers, then fall back to running
askpass, and then finally prompt on the terminal. Helpers
which cannot find a credential are free to tell us nothing,
but they cannot currently ask us to stop prompting.
This patch lets them provide a "quit" attribute, which asks
us to stop the process entirely (avoiding running more
helpers, as well as the askpass/terminal prompt).
This has a few possible uses:
1. A helper which prompts the user itself (e.g., in a
dialog) can provide a "cancel" button to the user to
stop further prompts.
2. Some helpers may know that prompting cannot possibly
work. For example, if their role is to broker a ticket
from an external auth system and that auth system
cannot be contacted, there is no point in continuing
(we need a ticket to authenticate, and the user cannot
provide one by typing it in).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-04 11:46:48 +08:00
|
|
|
quit:1,
|
credential: make relevance of http path configurable
When parsing a URL into a credential struct, we carefully
record each part of the URL, including the path on the
remote host, and use the result as part of the credential
context.
This had two practical implications:
1. Credential helpers which store a credential for later
access are likely to use the "path" portion as part of
the storage key. That means that a request to
https://example.com/foo.git
would not use the same credential that was stored in an
earlier request for:
https://example.com/bar.git
2. The prompt shown to the user includes all relevant
context, including the path.
In most cases, however, users will have a single password
per host. The behavior in (1) will be inconvenient, and the
prompt in (2) will be overly long.
This patch introduces a config option to toggle the
relevance of http paths. When turned on, we use the path as
before. When turned off, we drop the path component from the
context: helpers don't see it, and it does not appear in the
prompt.
This is nothing you couldn't do with a clever credential
helper at the start of your stack, like:
[credential "http://"]
helper = "!f() { grep -v ^path= ; }; f"
helper = your_real_helper
But doing this:
[credential]
useHttpPath = false
is way easier and more readable. Furthermore, since most
users will want the "off" behavior, that is the new default.
Users who want it "on" can set the variable (either for all
credentials, or just for a subset using
credential.*.useHttpPath).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-10 18:31:34 +08:00
|
|
|
use_http_path:1;
|
2011-12-10 18:31:11 +08:00
|
|
|
|
|
|
|
char *username;
|
|
|
|
char *password;
|
|
|
|
char *protocol;
|
|
|
|
char *host;
|
|
|
|
char *path;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CREDENTIAL_INIT { STRING_LIST_INIT_DUP }
|
|
|
|
|
|
|
|
void credential_init(struct credential *);
|
|
|
|
void credential_clear(struct credential *);
|
|
|
|
|
|
|
|
void credential_fill(struct credential *);
|
|
|
|
void credential_approve(struct credential *);
|
|
|
|
void credential_reject(struct credential *);
|
|
|
|
|
|
|
|
int credential_read(struct credential *, FILE *);
|
2012-06-24 19:40:00 +08:00
|
|
|
void credential_write(const struct credential *, FILE *);
|
2011-12-10 18:31:17 +08:00
|
|
|
void credential_from_url(struct credential *, const char *url);
|
2011-12-10 18:31:24 +08:00
|
|
|
int credential_match(const struct credential *have,
|
|
|
|
const struct credential *want);
|
2011-12-10 18:31:11 +08:00
|
|
|
|
|
|
|
#endif /* CREDENTIAL_H */
|