Skip to content

Commit 6e12fbd

Browse files
address review feedback
1 parent 4326282 commit 6e12fbd

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ Result<std::unique_ptr<AuthManager>> MakeSigV4AuthManager(
118118

119119
// Prevent circular delegation (sigv4 -> sigv4 -> ...).
120120
ICEBERG_PRECHECK(delegate_type != AuthProperties::kAuthTypeSigV4,
121-
"Cannot delegate a SigV4 auth manager to another SigV4 auth manager");
121+
"Cannot delegate a SigV4 auth manager to another SigV4 auth "
122+
"manager (delegate_type='{}')",
123+
delegate_type);
122124

123125
// Load the delegate auth manager.
124126
auto delegate_props = properties;

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "iceberg/catalog/rest/auth/auth_properties.h"
3333
#include "iceberg/catalog/rest/endpoint.h"
34+
#include "iceberg/util/checked_cast.h"
3435
#include "iceberg/util/macros.h"
3536
#include "iceberg/util/string_util.h"
3637

@@ -207,8 +208,7 @@ Result<std::shared_ptr<AuthSession>> SigV4AuthManager::CatalogSession(
207208
Result<std::shared_ptr<AuthSession>> SigV4AuthManager::ContextualSession(
208209
const std::unordered_map<std::string, std::string>& context,
209210
std::shared_ptr<AuthSession> parent) {
210-
auto* sigv4_parent = dynamic_cast<SigV4AuthSession*>(parent.get());
211-
ICEBERG_PRECHECK(sigv4_parent != nullptr, "Parent session is not SigV4");
211+
auto sigv4_parent = internal::checked_pointer_cast<SigV4AuthSession>(std::move(parent));
212212

213213
ICEBERG_ASSIGN_OR_RAISE(auto delegate_session, delegate_->ContextualSession(
214214
context, sigv4_parent->delegate()));
@@ -221,8 +221,7 @@ Result<std::shared_ptr<AuthSession>> SigV4AuthManager::TableSession(
221221
const TableIdentifier& table,
222222
const std::unordered_map<std::string, std::string>& properties,
223223
std::shared_ptr<AuthSession> parent) {
224-
auto* sigv4_parent = dynamic_cast<SigV4AuthSession*>(parent.get());
225-
ICEBERG_PRECHECK(sigv4_parent != nullptr, "Parent session is not SigV4");
224+
auto sigv4_parent = internal::checked_pointer_cast<SigV4AuthSession>(std::move(parent));
226225

227226
ICEBERG_ASSIGN_OR_RAISE(
228227
auto delegate_session,
@@ -248,15 +247,12 @@ SigV4AuthManager::MakeCredentialsProvider(
248247
AuthProperties::kSigV4AccessKeyId, AuthProperties::kSigV4SecretAccessKey);
249248

250249
if (has_ak) {
250+
Aws::Auth::AWSCredentials credentials(access_key_it->second.c_str(),
251+
secret_key_it->second.c_str());
251252
auto session_token_it = properties.find(AuthProperties::kSigV4SessionToken);
252253
if (session_token_it != properties.end() && !session_token_it->second.empty()) {
253-
Aws::Auth::AWSCredentials credentials(access_key_it->second.c_str(),
254-
secret_key_it->second.c_str(),
255-
session_token_it->second.c_str());
256-
return std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(credentials);
254+
credentials.SetSessionToken(session_token_it->second.c_str());
257255
}
258-
Aws::Auth::AWSCredentials credentials(access_key_it->second.c_str(),
259-
secret_key_it->second.c_str());
260256
return std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(credentials);
261257
}
262258

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class ICEBERG_REST_EXPORT SigV4AuthSession : public AuthSession {
7777
std::string signing_region_;
7878
std::string signing_name_;
7979
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> credentials_provider_;
80-
/// Shared signer instance, matching Java's single Aws4Signer per manager.
8180
std::unique_ptr<Aws::Client::AWSAuthV4Signer> signer_;
8281
};
8382

0 commit comments

Comments
 (0)