Skip to content

Commit aabd4fc

Browse files
authored
Merge pull request #130 from puzza007/negotiate_auth_puz
feat: add HTTP Negotiate (SPNEGO) authentication
2 parents ebc185a + b79e37a commit aabd4fc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

c_src/katipo.c

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#define K_CURLAUTH_DIGEST 101
5252
#define K_CURLAUTH_UNDEFINED 102
5353
#define K_CURLAUTH_NTLM 103
54+
#define K_CURLAUTH_NEGOTIATE 104
5455

5556
struct bufferevent *to_erlang;
5657
struct bufferevent *from_erlang;
@@ -1104,6 +1105,8 @@ static void erl_input(struct bufferevent *ev, void *arg) {
11041105
eopts.curlopt_http_auth = CURLAUTH_DIGEST;
11051106
} else if (eopt_long == K_CURLAUTH_NTLM) {
11061107
eopts.curlopt_http_auth = CURLAUTH_NTLM;
1108+
} else if (eopt_long == K_CURLAUTH_NEGOTIATE) {
1109+
eopts.curlopt_http_auth = CURLAUTH_NEGOTIATE;
11071110
} else if (eopt_long != K_CURLAUTH_UNDEFINED) {
11081111
errx(2, "Unknown curlopt_http_auth value %ld", eopt_long);
11091112
}

src/katipo.erl

+5-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
-define(CURLAUTH_DIGEST, 101).
113113
-define(CURLAUTH_UNDEFINED, 102).
114114
-define(CURLAUTH_NTLM, 103).
115+
-define(CURLAUTH_NEGOTIATE, 104).
115116
-define(TCP_FASTOPEN_FALSE, 0).
116117
-define(TCP_FASTOPEN_TRUE, 1).
117118
-define(LOCK_DATA_SSL_SESSION_FALSE, 0).
@@ -258,8 +259,8 @@
258259
metrics => proplists:proplist()}} |
259260
{error, #{code := error_code(),
260261
message := error_msg()}}.
261-
-type http_auth() :: basic | digest | ntlm.
262-
-type http_auth_int() :: ?CURLAUTH_UNDEFINED | ?CURLAUTH_BASIC | ?CURLAUTH_DIGEST | ?CURLAUTH_NTLM.
262+
-type http_auth() :: basic | digest | ntlm | negotiate.
263+
-type http_auth_int() :: ?CURLAUTH_UNDEFINED | ?CURLAUTH_BASIC | ?CURLAUTH_DIGEST | ?CURLAUTH_NTLM | ?CURLAUTH_NEGOTIATE.
263264
-type pipelining() :: nothing | http1 | multiplex.
264265
-type curlopt_http_version() :: curl_http_version_none |
265266
curl_http_version_1_0 |
@@ -663,6 +664,8 @@ opt(http_auth, digest, {Req, Errors}) ->
663664
{Req#req{http_auth=?CURLAUTH_DIGEST}, Errors};
664665
opt(http_auth, ntlm, {Req, Errors}) ->
665666
{Req#req{http_auth=?CURLAUTH_NTLM}, Errors};
667+
opt(http_auth, negotiate, {Req, Errors}) ->
668+
{Req#req{http_auth=?CURLAUTH_NEGOTIATE}, Errors};
666669
opt(username, Username, {Req, Errors}) when is_binary(Username) ->
667670
{Req#req{username=Username}, Errors};
668671
opt(password, Password, {Req, Errors}) when is_binary(Password) ->

0 commit comments

Comments
 (0)