introduce credentials API
There are a few places in git that need to get a username
and password credential from the user; the most notable one
is HTTP authentication for smart-http pushing.
Right now the only choices for providing credentials are to
put them plaintext into your ~/.netrc, or to have git prompt
you (either on the terminal or via an askpass program). The
former is not very secure, and the latter is not very
convenient.
Unfortunately, there is no "always best" solution for
password management. The details will depend on the tradeoff
you want between security and convenience, as well as how
git can integrate with other security systems (e.g., many
operating systems provide a keychain or password wallet for
single sign-on).
This patch provides an abstract notion of credentials as a
data item, and provides three basic operations:
- fill (i.e., acquire from external storage or from the
user)
- approve (mark a credential as "working" for further
storage)
- reject (mark a credential as "not working", so it can
be removed from storage)
These operations can be backed by external helper processes
that interact with system- or user-specific secure storage.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
89650285d8
commit
abca927dbe
28
credential.h
Normal file
28
credential.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CREDENTIAL_H
|
||||
#define CREDENTIAL_H
|
||||
|
||||
#include "string-list.h"
|
||||
|
||||
struct credential {
|
||||
struct string_list helpers;
|
||||
unsigned approved:1;
|
||||
|
||||
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 *);
|
||||
|
||||
#endif /* CREDENTIAL_H */
|
||||
Reference in New Issue
Block a user