zhjwpku commented on code in PR #616: URL: https://github.com/apache/iceberg-cpp/pull/616#discussion_r3254506948
########## src/iceberg/catalog/rest/auth/sigv4_auth_manager.cc: ########## @@ -0,0 +1,383 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "iceberg/catalog/rest/auth/auth_manager_internal.h" +#include "iceberg/catalog/rest/auth/aws_sdk.h" +#include "iceberg/catalog/rest/auth/sigv4_auth_manager_internal.h" + +#ifdef ICEBERG_SIGV4 + +# include <atomic> +# include <mutex> +# include <sstream> + +# include <aws/core/Aws.h> +# include <aws/core/auth/AWSAuthSigner.h> +# include <aws/core/auth/AWSCredentialsProvider.h> +# include <aws/core/auth/AWSCredentialsProviderChain.h> +# include <aws/core/client/ClientConfiguration.h> +# include <aws/core/http/standard/StandardHttpRequest.h> +# include <aws/core/utils/HashingUtils.h> + +# include "iceberg/catalog/rest/auth/auth_managers.h" +# include "iceberg/catalog/rest/auth/auth_properties.h" +# include "iceberg/util/macros.h" +# include "iceberg/util/string_util.h" + +namespace iceberg::rest::auth { + +namespace { + +enum class LifecycleState : uint8_t { kUninitialized, kInitialized, kFinalized }; + +std::atomic<LifecycleState> g_state{LifecycleState::kUninitialized}; +std::mutex g_lifecycle_mutex; +Aws::SDKOptions g_sdk_options; +std::atomic<size_t> g_active_session_count{0}; Review Comment: nit: we can avoid these global states by wrapping them in a Singleton instance. ########## src/iceberg/catalog/rest/CMakeLists.txt: ########## @@ -34,6 +34,8 @@ set(ICEBERG_REST_SOURCES rest_util.cc types.cc) +list(APPEND ICEBERG_REST_SOURCES auth/sigv4_auth_manager.cc) Review Comment: nit: why not just add this to the above set? ########## src/iceberg/catalog/rest/CMakeLists.txt: ########## @@ -63,4 +74,12 @@ add_iceberg_lib(iceberg_rest SHARED_INSTALL_INTERFACE_LIBS ${ICEBERG_REST_SHARED_INSTALL_INTERFACE_LIBS}) +if(ICEBERG_BUILD_SIGV4) + foreach(LIB iceberg_rest_static iceberg_rest_shared) + if(TARGET ${LIB}) + target_compile_definitions(${LIB} PUBLIC ICEBERG_BUILD_SIGV4) + endif() + endforeach() +endif() + iceberg_install_all_headers(iceberg/catalog/rest) Review Comment: but header name with _internal.h won't be installed, is that what you want? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
