From 4421e87a86080f55702dbcbc6af830f7de3eed8f Mon Sep 17 00:00:00 2001 From: yujingwei Date: Thu, 16 Nov 2023 15:31:25 +0800 Subject: [PATCH 1/6] feat(thirdparty): introduce gssapi into http client --- src/http/http_client.cpp | 22 ++++++++++++++++++++++ src/http/http_client.h | 3 +++ src/http/http_method.h | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/src/http/http_client.cpp b/src/http/http_client.cpp index 32ae5eaea1..6e4b805a13 100644 --- a/src/http/http_client.cpp +++ b/src/http/http_client.cpp @@ -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); diff --git a/src/http/http_client.h b/src/http/http_client.h index 190af11f2b..f5dfcbe6a7 100644 --- a/src/http/http_client.h +++ b/src/http/http_client.h @@ -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); diff --git a/src/http/http_method.h b/src/http/http_method.h index f337d24e78..2fa5adb1d0 100644 --- a/src/http/http_method.h +++ b/src/http/http_method.h @@ -28,6 +28,13 @@ 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) From 7cd7c24b6e9289ec5fafe1b3edb3a0dc73759a88 Mon Sep 17 00:00:00 2001 From: yujingwei Date: Thu, 16 Nov 2023 15:32:19 +0800 Subject: [PATCH 2/6] feat(thirdparty): introduce gssapi into http client --- thirdparty/CMakeLists.txt | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 80a94828cb..aee6c00ac4 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -306,7 +306,37 @@ ExternalProject_Add(curl URL ${OSS_URL_PREFIX}/curl-8.4.0.tar.gz http://curl.haxx.se/download/curl-8.4.0.tar.gz URL_MD5 533e8a3b1228d5945a6a512537bea4c7 - CONFIGURE_COMMAND ./configure --prefix=${TP_OUTPUT} + CONFIGURE_COMMAND ./configure + --prefix=${TP_OUTPUT} + --disable-alt-svc + --disable-dict + --disable-doh + --disable-file + --disable-ftp + --disable-gopher + --disable-imap + --disable-ipv6 + --disable-ldap + --disable-ldaps + --disable-libcurl-option + --disable-manual + --disable-mime + --disable-netrc + --disable-parsedate + --disable-pop3 + --disable-progress-meter + --disable-rtsp + --disable-smb + --disable-smtp + --disable-telnet + --disable-tftp + --without-brotli + --without-libidn2 + --without-libpsl + --without-librtmp + --without-libssh2 + --without-nghttp2 + --with-gssapi ${CURL_OPTIONS} BUILD_IN_SOURCE 1 ) From 2025e3318ae42ef28e451d8188059625d91ed285 Mon Sep 17 00:00:00 2001 From: yujingwei Date: Thu, 16 Nov 2023 15:36:28 +0800 Subject: [PATCH 3/6] feat(thirdparty): introduce gssapi into http client --- src/http/http_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/http_client.h b/src/http/http_client.h index f5dfcbe6a7..fe4b0ed18a 100644 --- a/src/http/http_client.h +++ b/src/http/http_client.h @@ -95,7 +95,7 @@ class http_client // 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); From a94c51ed7ec9e3474df94541b3055c96f075b287 Mon Sep 17 00:00:00 2001 From: yujingwei Date: Thu, 16 Nov 2023 15:37:37 +0800 Subject: [PATCH 4/6] feat(thirdparty): introduce gssapi into http client --- src/http/http_client.cpp | 20 ++++++++++---------- src/http/http_method.h | 11 ++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/http/http_client.cpp b/src/http/http_client.cpp index 6e4b805a13..41e6b7f426 100644 --- a/src/http/http_client.cpp +++ b/src/http/http_client.cpp @@ -221,21 +221,21 @@ dsn::error_s http_client::set_method(http_method method) dsn::error_s http_client::set_auth(http_auth_type authType) { - switch(authType){ + switch (authType) { case http_auth_type::SPNEGO: - RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE); - break; + 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; + 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; + RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + break; case http_auth_type::NONE: - break; + break; default: - RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_ANY); - break; + RETURN_IF_SETOPT_NOT_OK(CURLOPT_HTTPAUTH, CURLAUTH_ANY); + break; } return dsn::error_s::ok(); diff --git a/src/http/http_method.h b/src/http/http_method.h index 2fa5adb1d0..5e13c756fc 100644 --- a/src/http/http_method.h +++ b/src/http/http_method.h @@ -28,11 +28,12 @@ enum class http_method INVALID = 100, }; -enum class http_auth_type { - NONE, - BASIC, - DIGEST, - SPNEGO, +enum class http_auth_type +{ + NONE, + BASIC, + DIGEST, + SPNEGO, }; ENUM_BEGIN(http_method, http_method::INVALID) From 3d1376c408b72c5dd09b21958d47c8f85b222b3a Mon Sep 17 00:00:00 2001 From: yujingwei Date: Mon, 20 Nov 2023 21:20:14 +0800 Subject: [PATCH 5/6] feat(thirdparty): introduce gssapi into http client --- thirdparty/CMakeLists.txt | 40 ++++++--------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index aee6c00ac4..d5b74265c3 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -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 @@ -306,37 +307,7 @@ ExternalProject_Add(curl URL ${OSS_URL_PREFIX}/curl-8.4.0.tar.gz http://curl.haxx.se/download/curl-8.4.0.tar.gz URL_MD5 533e8a3b1228d5945a6a512537bea4c7 - CONFIGURE_COMMAND ./configure - --prefix=${TP_OUTPUT} - --disable-alt-svc - --disable-dict - --disable-doh - --disable-file - --disable-ftp - --disable-gopher - --disable-imap - --disable-ipv6 - --disable-ldap - --disable-ldaps - --disable-libcurl-option - --disable-manual - --disable-mime - --disable-netrc - --disable-parsedate - --disable-pop3 - --disable-progress-meter - --disable-rtsp - --disable-smb - --disable-smtp - --disable-telnet - --disable-tftp - --without-brotli - --without-libidn2 - --without-libpsl - --without-librtmp - --without-libssh2 - --without-nghttp2 - --with-gssapi + CONFIGURE_COMMAND ./configure --prefix=${TP_OUTPUT} ${CURL_OPTIONS} BUILD_IN_SOURCE 1 ) @@ -447,6 +418,7 @@ ExternalProject_Add(abseil https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip URL_MD5 5c6193dbc82834f8e762c6a28c9cc615 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DABSL_FIND_GOOGLETEST=OFF -DCMAKE_CXX_STANDARD=14 ) From d0e39351f992e0c6b372db9a49591d9b11c7ca4a Mon Sep 17 00:00:00 2001 From: yujingwei Date: Mon, 20 Nov 2023 21:21:27 +0800 Subject: [PATCH 6/6] feat(thirdparty): introduce gssapi into http client --- thirdparty/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index d5b74265c3..8645ee1a1c 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -418,7 +418,6 @@ ExternalProject_Add(abseil https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip URL_MD5 5c6193dbc82834f8e762c6a28c9cc615 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DABSL_FIND_GOOGLETEST=OFF -DCMAKE_CXX_STANDARD=14 )