summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-03-22 19:06:46 -1000
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-10 19:58:22 +0100
commit539e62935552c59a3f51b225c67dab5d3e02debd (patch)
tree5aa9d4d6d5da85ab35d145fa163930cde02928bd
parent3e0b4b43c8b3d9d1da71297b8e8f346117624919 (diff)
downloadlibgit2-539e62935552c59a3f51b225c67dab5d3e02debd.tar.gz
http: teach auth mechanisms about connection affinity
Instead of using `is_complete` to decide whether we have connection or request affinity for authentication mechanisms, set a boolean on the mechanism definition itself.
-rw-r--r--src/transports/auth.c1
-rw-r--r--src/transports/auth.h3
-rw-r--r--src/transports/auth_negotiate.c1
-rw-r--r--src/transports/auth_ntlm.c1
-rw-r--r--src/transports/http.c2
5 files changed, 7 insertions, 1 deletions
diff --git a/src/transports/auth.c b/src/transports/auth.c
index c2e2713ea..773e3020a 100644
--- a/src/transports/auth.c
+++ b/src/transports/auth.c
@@ -48,6 +48,7 @@ on_error:
static git_http_auth_context basic_context = {
GIT_AUTHTYPE_BASIC,
GIT_CREDTYPE_USERPASS_PLAINTEXT,
+ 0,
NULL,
basic_next_token,
NULL,
diff --git a/src/transports/auth.h b/src/transports/auth.h
index 0a80d1c85..aeea6ce4c 100644
--- a/src/transports/auth.h
+++ b/src/transports/auth.h
@@ -28,6 +28,9 @@ struct git_http_auth_context {
/** Supported credentials */
git_credtype_t credtypes;
+ /** Connection affinity or request affinity */
+ unsigned connection_affinity : 1;
+
/** Sets the challenge on the authentication context */
int (*set_challenge)(git_http_auth_context *ctx, const char *challenge);
diff --git a/src/transports/auth_negotiate.c b/src/transports/auth_negotiate.c
index 0b6f50eeb..f0f2b08a4 100644
--- a/src/transports/auth_negotiate.c
+++ b/src/transports/auth_negotiate.c
@@ -271,6 +271,7 @@ int git_http_auth_negotiate(
ctx->parent.type = GIT_AUTHTYPE_NEGOTIATE;
ctx->parent.credtypes = GIT_CREDTYPE_DEFAULT;
+ ctx->parent.connection_affinity = 1;
ctx->parent.set_challenge = negotiate_set_challenge;
ctx->parent.next_token = negotiate_next_token;
ctx->parent.is_complete = negotiate_is_complete;
diff --git a/src/transports/auth_ntlm.c b/src/transports/auth_ntlm.c
index 9f709e279..eff09bd8a 100644
--- a/src/transports/auth_ntlm.c
+++ b/src/transports/auth_ntlm.c
@@ -208,6 +208,7 @@ int git_http_auth_ntlm(
ctx->parent.type = GIT_AUTHTYPE_NTLM;
ctx->parent.credtypes = GIT_CREDTYPE_USERPASS_PLAINTEXT;
+ ctx->parent.connection_affinity = 1;
ctx->parent.set_challenge = ntlm_set_challenge;
ctx->parent.next_token = ntlm_next_token;
ctx->parent.is_complete = ntlm_is_complete;
diff --git a/src/transports/http.c b/src/transports/http.c
index 3ee7af78a..8e0af1beb 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -1014,7 +1014,7 @@ static void reset_auth_connection(http_server *server)
if (server->authenticated &&
server->auth_context &&
- server->auth_context->is_complete) {
+ server->auth_context->connection_affinity) {
free_auth_context(server);
server->url_cred_presented = 0;