]> git.proxmox.com Git - libgit2.git/blob - src/transports/auth.h
New upstream version 0.27.0+dfsg.1
[libgit2.git] / src / transports / auth.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7
8 #ifndef INCLUDE_transports_auth_h__
9 #define INCLUDE_transports_auth_h__
10
11 #include "common.h"
12
13 #include "git2.h"
14 #include "netops.h"
15
16 typedef enum {
17 GIT_AUTHTYPE_BASIC = 1,
18 GIT_AUTHTYPE_NEGOTIATE = 2,
19 } git_http_authtype_t;
20
21 typedef struct git_http_auth_context git_http_auth_context;
22
23 struct git_http_auth_context {
24 /** Type of scheme */
25 git_http_authtype_t type;
26
27 /** Supported credentials */
28 git_credtype_t credtypes;
29
30 /** Sets the challenge on the authentication context */
31 int (*set_challenge)(git_http_auth_context *ctx, const char *challenge);
32
33 /** Gets the next authentication token from the context */
34 int (*next_token)(git_buf *out, git_http_auth_context *ctx, git_cred *cred);
35
36 /** Frees the authentication context */
37 void (*free)(git_http_auth_context *ctx);
38 };
39
40 typedef struct {
41 /** Type of scheme */
42 git_http_authtype_t type;
43
44 /** Name of the scheme (as used in the Authorization header) */
45 const char *name;
46
47 /** Credential types this scheme supports */
48 git_credtype_t credtypes;
49
50 /** Function to initialize an authentication context */
51 int (*init_context)(
52 git_http_auth_context **out,
53 const gitno_connection_data *connection_data);
54 } git_http_auth_scheme;
55
56 int git_http_auth_dummy(
57 git_http_auth_context **out,
58 const gitno_connection_data *connection_data);
59
60 int git_http_auth_basic(
61 git_http_auth_context **out,
62 const gitno_connection_data *connection_data);
63
64 #endif