Skip to content

Commit 20047a4

Browse files
address review feedback
1 parent 205f2db commit 20047a4

19 files changed

Lines changed: 255 additions & 152 deletions

.github/workflows/cpp-linter.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,13 @@ jobs:
4040
- name: Install dependencies
4141
shell: bash
4242
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
43-
- name: Cache vcpkg packages
44-
uses: actions/cache@v4
45-
id: vcpkg-cache
46-
with:
47-
path: /usr/local/share/vcpkg/installed
48-
key: vcpkg-x64-linux-aws-sdk-cpp-core-${{ hashFiles('.github/workflows/cpp-linter.yml') }}
49-
- name: Install AWS SDK via vcpkg
50-
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
51-
shell: bash
52-
run: vcpkg install aws-sdk-cpp[core]:x64-linux
5343
- name: Run build
5444
env:
5545
CC: gcc-14
5646
CXX: g++-14
5747
run: |
5848
mkdir build && cd build
59-
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
60-
-DICEBERG_BUILD_SIGV4=ON \
61-
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake
49+
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
6250
cmake --build .
6351
- uses: cpp-linter/cpp-linter-action@0f6d1b8d7e38b584cbee606eb23d850c217d54f8 # v2.15.1
6452
id: linter

.github/workflows/sigv4_test.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# SigV4 build + unit tests (Linux only; aws-cpp-sdk-core via vcpkg).
19+
name: SigV4 Tests
20+
21+
on:
22+
push:
23+
branches:
24+
- '**'
25+
- '!dependabot/**'
26+
tags:
27+
- '**'
28+
pull_request:
29+
30+
concurrency:
31+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
32+
cancel-in-progress: true
33+
34+
permissions:
35+
contents: read
36+
37+
env:
38+
ICEBERG_HOME: /tmp/iceberg
39+
40+
jobs:
41+
sigv4:
42+
name: SigV4 (AMD64 Ubuntu 24.04)
43+
runs-on: ubuntu-24.04
44+
timeout-minutes: 35
45+
env:
46+
CC: gcc-14
47+
CXX: g++-14
48+
AWS_EC2_METADATA_DISABLED: "TRUE"
49+
steps:
50+
- name: Checkout iceberg-cpp
51+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
52+
with:
53+
persist-credentials: false
54+
- name: Install dependencies
55+
shell: bash
56+
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
57+
- name: Cache vcpkg packages
58+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
59+
id: vcpkg-cache
60+
with:
61+
path: /usr/local/share/vcpkg/installed
62+
key: vcpkg-x64-linux-aws-sdk-cpp-core-${{ hashFiles('.github/workflows/sigv4_test.yml') }}
63+
- name: Install AWS SDK via vcpkg
64+
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
65+
shell: bash
66+
run: vcpkg install aws-sdk-cpp[core]:x64-linux
67+
- name: Build and test Iceberg with SigV4
68+
shell: bash
69+
env:
70+
CMAKE_TOOLCHAIN_FILE: /usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake
71+
run: ci/scripts/build_iceberg.sh "$(pwd)" OFF OFF OFF ON

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ option(ICEBERG_BUILD_BUNDLE "Build the battery included library" ON)
4646
option(ICEBERG_BUILD_REST "Build rest catalog client" ON)
4747
option(ICEBERG_BUILD_REST_INTEGRATION_TESTS "Build rest catalog integration tests" OFF)
4848
option(ICEBERG_S3 "Build with S3 support" OFF)
49-
option(ICEBERG_BUILD_SIGV4 "Build SigV4 authentication support (requires AWS SDK)" OFF)
49+
option(ICEBERG_SIGV4 "Build SigV4 authentication support (requires AWS SDK)" OFF)
5050
option(ICEBERG_ENABLE_ASAN "Enable Address Sanitizer" OFF)
5151
option(ICEBERG_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF)
5252

ci/scripts/build_iceberg.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919
#
20-
# Usage: build_iceberg.sh <source_dir> [rest_integration_tests=OFF] [sccache=OFF] [s3=OFF]
20+
# Usage: build_iceberg.sh <source_dir> [rest_integration_tests=OFF] [sccache=OFF] [s3=OFF] [sigv4=OFF]
2121

2222
set -eux
2323

@@ -26,6 +26,7 @@ build_dir=${1}/build
2626
build_rest_integration_test=${2:-OFF}
2727
build_enable_sccache=${3:-OFF}
2828
build_enable_s3=${4:-OFF}
29+
build_enable_sigv4=${5:-OFF}
2930

3031
mkdir ${build_dir}
3132
pushd ${build_dir}
@@ -48,11 +49,20 @@ else
4849
CMAKE_ARGS+=("-DICEBERG_S3=OFF")
4950
fi
5051

52+
if [[ "${build_enable_sigv4}" == "ON" ]]; then
53+
CMAKE_ARGS+=("-DICEBERG_SIGV4=ON")
54+
else
55+
CMAKE_ARGS+=("-DICEBERG_SIGV4=OFF")
56+
fi
57+
5158
if is_windows; then
5259
CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake")
5360
CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release")
5461
else
5562
CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Debug")
63+
if [[ -n "${CMAKE_TOOLCHAIN_FILE:-}" ]]; then
64+
CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
65+
fi
5666
fi
5767

5868
if [[ "${build_enable_sccache}" == "ON" ]]; then

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ function(resolve_aws_sdk_dependency)
551551
PARENT_SCOPE)
552552
endfunction()
553553

554-
if(ICEBERG_BUILD_SIGV4)
554+
if(ICEBERG_SIGV4)
555555
if(NOT ICEBERG_BUILD_REST)
556-
message(FATAL_ERROR "ICEBERG_BUILD_SIGV4 requires ICEBERG_BUILD_REST to be ON")
556+
message(FATAL_ERROR "ICEBERG_SIGV4 requires ICEBERG_BUILD_REST to be ON")
557557
endif()
558558
resolve_aws_sdk_dependency()
559559
endif()

src/iceberg/catalog/rest/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ set(ICEBERG_REST_SOURCES
3434
rest_util.cc
3535
types.cc)
3636

37-
if(ICEBERG_BUILD_SIGV4)
38-
list(APPEND ICEBERG_REST_SOURCES auth/sigv4_auth_manager.cc)
39-
endif()
37+
list(APPEND ICEBERG_REST_SOURCES auth/sigv4_auth_manager.cc)
4038

4139
set(ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS)
4240
set(ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS)
@@ -56,7 +54,7 @@ list(APPEND
5654
"$<IF:$<TARGET_EXISTS:iceberg::iceberg_shared>,iceberg::iceberg_shared,iceberg::iceberg_static>"
5755
"$<IF:$<BOOL:${CPR_VENDORED}>,iceberg::cpr,cpr::cpr>")
5856

59-
if(ICEBERG_BUILD_SIGV4)
57+
if(ICEBERG_SIGV4)
6058
list(APPEND ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS aws-cpp-sdk-core)
6159
list(APPEND ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS aws-cpp-sdk-core)
6260
list(APPEND ICEBERG_REST_STATIC_INSTALL_INTERFACE_LIBS aws-cpp-sdk-core)
@@ -75,10 +73,10 @@ add_iceberg_lib(iceberg_rest
7573
SHARED_INSTALL_INTERFACE_LIBS
7674
${ICEBERG_REST_SHARED_INSTALL_INTERFACE_LIBS})
7775

78-
if(ICEBERG_BUILD_SIGV4)
76+
if(ICEBERG_SIGV4)
7977
foreach(LIB iceberg_rest_static iceberg_rest_shared)
8078
if(TARGET ${LIB})
81-
target_compile_definitions(${LIB} PUBLIC ICEBERG_BUILD_SIGV4)
79+
target_compile_definitions(${LIB} PUBLIC ICEBERG_SIGV4)
8280
endif()
8381
endforeach()
8482
endif()

src/iceberg/catalog/rest/auth/auth_manager_internal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ Result<std::unique_ptr<AuthManager>> MakeOAuth2Manager(
4747
std::string_view name,
4848
const std::unordered_map<std::string, std::string>& properties);
4949

50-
#ifdef ICEBERG_BUILD_SIGV4
51-
/// \brief Create a SigV4 authentication manager with a delegate.
50+
/// \brief Create a SigV4 authentication manager with a delegate. Returns
51+
/// NotSupported when the library was built without ICEBERG_SIGV4.
5252
Result<std::unique_ptr<AuthManager>> MakeSigV4AuthManager(
5353
std::string_view name,
5454
const std::unordered_map<std::string, std::string>& properties);
55-
#endif
5655

5756
} // namespace iceberg::rest::auth

src/iceberg/catalog/rest/auth/auth_managers.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ AuthManagerRegistry CreateDefaultRegistry() {
6666
{AuthProperties::kAuthTypeNone, MakeNoopAuthManager},
6767
{AuthProperties::kAuthTypeBasic, MakeBasicAuthManager},
6868
{AuthProperties::kAuthTypeOAuth2, MakeOAuth2Manager},
69+
{AuthProperties::kAuthTypeSigV4, MakeSigV4AuthManager},
6970
};
70-
#ifdef ICEBERG_BUILD_SIGV4
71-
registry[AuthProperties::kAuthTypeSigV4] = MakeSigV4AuthManager;
72-
#endif
7371
return registry;
7472
}
7573

src/iceberg/catalog/rest/auth/auth_session.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class DefaultAuthSession : public AuthSession {
3333
explicit DefaultAuthSession(std::unordered_map<std::string, std::string> headers)
3434
: headers_(std::move(headers)) {}
3535

36-
Result<HTTPRequest> Authenticate(const HTTPRequest& request) override {
37-
HTTPRequest authenticated = request;
36+
Result<HttpRequest> Authenticate(const HttpRequest& request) override {
37+
HttpRequest authenticated = request;
3838
for (const auto& [key, value] : headers_) {
3939
authenticated.headers.try_emplace(key, value);
4040
}

src/iceberg/catalog/rest/auth/auth_session.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <string>
2424
#include <unordered_map>
2525

26-
#include "iceberg/catalog/rest/endpoint.h"
26+
#include "iceberg/catalog/rest/http_request.h"
2727
#include "iceberg/catalog/rest/iceberg_rest_export.h"
2828
#include "iceberg/catalog/rest/type_fwd.h"
2929
#include "iceberg/result.h"
@@ -33,17 +33,6 @@
3333

3434
namespace iceberg::rest::auth {
3535

36-
/// \brief An outgoing HTTP request passed through an AuthSession. Mirrors the
37-
/// HTTPRequest type used by the Java reference implementation so signing
38-
/// implementations like SigV4 can operate on method, url, headers, and body
39-
/// as a single value.
40-
struct ICEBERG_REST_EXPORT HTTPRequest {
41-
HttpMethod method = HttpMethod::kGet;
42-
std::string url;
43-
std::unordered_map<std::string, std::string> headers;
44-
std::string body;
45-
};
46-
4736
/// \brief An authentication session that can authenticate outgoing HTTP requests.
4837
class ICEBERG_REST_EXPORT AuthSession {
4938
public:
@@ -63,7 +52,7 @@ class ICEBERG_REST_EXPORT AuthSession {
6352
/// - NotAuthorized: Not authenticated (401)
6453
/// - IOError: Network or connection errors when reaching auth server
6554
/// - RestError: HTTP errors from authentication service
66-
virtual Result<HTTPRequest> Authenticate(const HTTPRequest& request) = 0;
55+
virtual Result<HttpRequest> Authenticate(const HttpRequest& request) = 0;
6756

6857
/// \brief Close the session and release any resources.
6958
///

0 commit comments

Comments
 (0)