mirror of
https://github.com/git/git.git
synced 2025-03-16 17:55:17 +00:00
All of the components of a credential struct can be found in a URL. For example, the URL: http://foo:bar@example.com/repo.git contains: protocol=http host=example.com path=repo.git username=foo password=bar We want to be able to turn URLs into broken-down credential structs so that we know two things: 1. Which parts of the username/password we still need 2. What the context of the request is (for prompting or as a key for storing credentials). This code is based on http_auth_init in http.c, but needed a few modifications in order to get all of the components that the credential object is interested in. Once the http code is switched over to the credential API, then http_auth_init can just go away. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
30 lines
636 B
C
30 lines
636 B
C
#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 *);
|
|
void credential_from_url(struct credential *, const char *url);
|
|
|
|
#endif /* CREDENTIAL_H */
|