Skip to content

Commit

Permalink
feat(thirdparty): compile curl with gssapi (apache#1683)
Browse files Browse the repository at this point in the history
The key manager get EEK from Apache Ranger KMS should set CURLOPT_HTTPAUTH with negotiate.
So it's needed to compile libcurl with gssapi flag.
  • Loading branch information
Samunroyu authored Nov 21, 2023
1 parent a276661 commit 64129e8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/http/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,28 @@ dsn::error_s http_client::set_method(http_method method)
return dsn::error_s::ok();
}

dsn::error_s http_client::set_auth(http_auth_type authType)
{
switch (authType) {
case http_auth_type::SPNEGO:
RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE);
break;
case http_auth_type::DIGEST:
RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
break;
case http_auth_type::BASIC:
RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
break;
case http_auth_type::NONE:
break;
default:
RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_ANY);
break;
}

return dsn::error_s::ok();
}

dsn::error_s http_client::set_timeout(long timeout_ms)
{
RETURN_IF_SETOPT_NOT_OK(CURLOPT_TIMEOUT_MS, timeout_ms);
Expand Down
3 changes: 3 additions & 0 deletions src/http/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class http_client
// Specify the maximum time in milliseconds that a request is allowed to complete.
dsn::error_s set_timeout(long timeout_ms);

// Specify the http auth type which include NONE BASIC DIGEST SPNEGO
dsn::error_s set_auth(http_auth_type authType);

// Operations for the header fields.
void clear_header_fields();
void set_accept(dsn::string_view val);
Expand Down
8 changes: 8 additions & 0 deletions src/http/http_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ enum class http_method
INVALID = 100,
};

enum class http_auth_type
{
NONE,
BASIC,
DIGEST,
SPNEGO,
};

ENUM_BEGIN(http_method, http_method::INVALID)
ENUM_REG2(http_method, GET)
ENUM_REG2(http_method, POST)
Expand Down
7 changes: 4 additions & 3 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,17 @@ set(CURL_OPTIONS
--disable-manual
--disable-pop3
--disable-rtsp
--disable-shared
--disable-smtp
--disable-telnet
--disable-tftp
--disable-shared
--without-libidn
--without-librtmp
--without-zlib
--without-libssh2
--without-ssl
--without-libidn
--without-zlib
--without-zstd
--with-gssapi
)
if (APPLE)
set(CURL_OPTIONS
Expand Down

0 comments on commit 64129e8

Please sign in to comment.