This repository was archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcredential.hpp
More file actions
98 lines (78 loc) · 3.33 KB
/
Copy pathcredential.hpp
File metadata and controls
98 lines (78 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once
#include <cppgit2/bitmask_operators.hpp>
#include <cppgit2/libgit2_api.hpp>
#include <cppgit2/ownership.hpp>
#include <git2.h>
#include <string>
namespace cppgit2 {
// Owned by user, cleaned up in destructor
class credential : public libgit2_api {
public:
// Create a "default" credential usable for Negotiate mechanisms like NTLM or
// Kerberos authentication.
credential();
// Create a new plain-text username and password credential object. The
// supplied credential parameter will be internally duplicated.
credential(const std::string &username, const std::string &password);
// Create a new passphrase-protected ssh key credential object. The supplied
// credential parameter will be internally duplicated.
credential(const std::string &username, const std::string &public_key,
const std::string &private_key, const std::string &passphrase);
// Create a new ssh key credential object used for querying an ssh-agent. The
// supplied credential parameter will be internally duplicated.
credential(const std::string &username);
// Create a new ssh keyboard-interactive based credential object. The supplied
// credential parameter will be internally duplicated.
//
// Not much wrapping happening here - More or less same signature as libgit2
credential(const std::string &username,
git_credential_ssh_interactive_cb prompt_callback, void *payload);
// Create an ssh key credential with a custom signing function.
//
// This lets you use your own function to sign the challenge.
// This function and its credential type is provided for completeness and
// wraps libssh2_userauth_publickey(), which is undocumented.
//
// Not much wrapping happening here - More or less same signature as libgit2
credential(const std::string &username, const std::string &public_key,
git_credential_sign_cb sign_callback, void *payload);
// Cleanup credential object
~credential();
// Supported credential types
// This represents the various types of authentication methods supported by
// the library.
enum class type {
// a vanilla user/password request
userpass_plaintext = (1u << 0),
// an ssh key-based authentication request
ssh_key = (1u << 1),
// an ssh key-based authentication request, with a custom signature
ssh_custom = (1u << 2),
// an ntlm/negotiate-based authentication request.
default_ = (1u << 3),
// an ssh interactive authentication request
ssh_interactive = (1u << 4),
// username-only authentication request
//
// used as a pre-authentication step if the underlying transport
// (eg. ssh, with no username in its url) does not know which username
// to use.
username = (1u << 5),
// an ssh key-based authentication request
//
// allows credentials to be read from memory instead of files.
// note that because of differences in crypto backend support, it might
// not be functional.
ssh_memory = (1u << 6),
};
// Return the username associated with a credential object.
std::string username() const;
// Check whether a credential object contains username information.
bool has_username() const;
// Access libgit2 C ptr
const git_credential *c_ptr() const;
private:
git_credential *c_ptr_;
};
ENABLE_BITMASK_OPERATORS(credential::type);
} // namespace cppgit2