Skip to content

Commit 4197ceb

Browse files
move MakeSigV4AuthManager to sigv4_auth_manager.cc
1 parent abb2cf6 commit 4197ceb

2 files changed

Lines changed: 24 additions & 29 deletions

File tree

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#include <unordered_set>
2323

2424
#include "iceberg/catalog/rest/auth/auth_manager_internal.h"
25-
#ifdef ICEBERG_BUILD_SIGV4
26-
# include "iceberg/catalog/rest/auth/sigv4_auth_manager.h"
27-
#endif
2825
#include "iceberg/catalog/rest/auth/auth_properties.h"
2926
#include "iceberg/util/string_util.h"
3027

@@ -105,30 +102,4 @@ Result<std::unique_ptr<AuthManager>> AuthManagers::Load(
105102
return it->second(name, properties);
106103
}
107104

108-
#ifdef ICEBERG_BUILD_SIGV4
109-
Result<std::unique_ptr<AuthManager>> MakeSigV4AuthManager(
110-
std::string_view name,
111-
const std::unordered_map<std::string, std::string>& properties) {
112-
// Determine the delegate auth type. Default to OAuth2 if not specified.
113-
std::string delegate_type = AuthProperties::kAuthTypeOAuth2;
114-
auto it = properties.find(AuthProperties::kSigV4DelegateAuthType);
115-
if (it != properties.end() && !it->second.empty()) {
116-
delegate_type = StringUtils::ToLower(it->second);
117-
}
118-
119-
// Prevent circular delegation (sigv4 -> sigv4 -> ...).
120-
ICEBERG_PRECHECK(delegate_type != AuthProperties::kAuthTypeSigV4,
121-
"Cannot delegate a SigV4 auth manager to another SigV4 auth "
122-
"manager (delegate_type='{}')",
123-
delegate_type);
124-
125-
// Load the delegate auth manager.
126-
auto delegate_props = properties;
127-
delegate_props[AuthProperties::kAuthType] = delegate_type;
128-
129-
ICEBERG_ASSIGN_OR_RAISE(auto delegate, AuthManagers::Load(name, delegate_props));
130-
return std::make_unique<SigV4AuthManager>(std::move(delegate));
131-
}
132-
#endif
133-
134105
} // namespace iceberg::rest::auth

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <aws/core/http/standard/StandardHttpRequest.h>
3030
#include <aws/core/utils/HashingUtils.h>
3131

32+
#include "iceberg/catalog/rest/auth/auth_manager_internal.h"
33+
#include "iceberg/catalog/rest/auth/auth_managers.h"
3234
#include "iceberg/catalog/rest/auth/auth_properties.h"
3335
#include "iceberg/catalog/rest/endpoint.h"
3436
#include "iceberg/util/checked_cast.h"
@@ -292,4 +294,26 @@ Result<std::shared_ptr<AuthSession>> SigV4AuthManager::WrapSession(
292294
std::move(credentials));
293295
}
294296

297+
Result<std::unique_ptr<AuthManager>> MakeSigV4AuthManager(
298+
std::string_view name,
299+
const std::unordered_map<std::string, std::string>& properties) {
300+
// Default to OAuth2 when delegate type is not specified.
301+
std::string delegate_type = AuthProperties::kAuthTypeOAuth2;
302+
if (auto it = properties.find(AuthProperties::kSigV4DelegateAuthType);
303+
it != properties.end() && !it->second.empty()) {
304+
delegate_type = StringUtils::ToLower(it->second);
305+
}
306+
307+
// Prevent circular delegation (sigv4 -> sigv4 -> ...).
308+
ICEBERG_PRECHECK(delegate_type != AuthProperties::kAuthTypeSigV4,
309+
"Cannot delegate a SigV4 auth manager to another SigV4 auth "
310+
"manager (delegate_type='{}')",
311+
delegate_type);
312+
313+
auto delegate_props = properties;
314+
delegate_props[AuthProperties::kAuthType] = delegate_type;
315+
ICEBERG_ASSIGN_OR_RAISE(auto delegate, AuthManagers::Load(name, delegate_props));
316+
return std::make_unique<SigV4AuthManager>(std::move(delegate));
317+
}
318+
295319
} // namespace iceberg::rest::auth

0 commit comments

Comments
 (0)