Skip to content

Commit cc804e8

Browse files
author
shuxu.li
committed
feat: Implement NoopAuthManager and integrate AuthManager into RestCatalog
1 parent ff0deaf commit cc804e8

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ using AuthManagerRegistry =
3535

3636
/// \brief Known authentication types that are defined in the Iceberg spec.
3737
const std::unordered_set<std::string, StringHash, StringEqual>& KnownAuthTypes() {
38-
static const std::unordered_set<std::string, StringHash, StringEqual> types = {
38+
static const std::unordered_set<std::string, StringHash, StringEqual> kAuthTypes = {
3939
AuthProperties::kAuthTypeNone,
4040
AuthProperties::kAuthTypeBasic,
4141
AuthProperties::kAuthTypeOAuth2,
4242
AuthProperties::kAuthTypeSigV4,
4343
};
44-
return types;
44+
return kAuthTypes;
4545
}
4646

4747
// Infer the authentication type from properties.
@@ -66,7 +66,7 @@ std::string InferAuthType(
6666
class NoopAuthManager : public AuthManager {
6767
public:
6868
Result<std::shared_ptr<AuthSession>> CatalogSession(
69-
[[maybe_unused]] HttpClient& shared_client,
69+
[[maybe_unused]] HttpClient& client,
7070
[[maybe_unused]] const std::unordered_map<std::string, std::string>& properties)
7171
override {
7272
return AuthSession::MakeDefault({});

src/iceberg/catalog/rest/rest_catalog.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ std::unordered_set<Endpoint> GetDefaultEndpoints() {
6969
}
7070

7171
/// \brief Fetch server configuration from the REST catalog server.
72-
Result<CatalogConfig> FetchServerConfig(
73-
const ResourcePaths& paths, const RestCatalogProperties& current_config,
74-
const std::shared_ptr<auth::AuthSession>& session) {
72+
Result<CatalogConfig> FetchServerConfig(const ResourcePaths& paths,
73+
const RestCatalogProperties& current_config,
74+
auth::AuthSession& session) {
7575
ICEBERG_ASSIGN_OR_RAISE(auto config_path, paths.Config());
7676
HttpClient client(current_config.ExtractHeaders());
7777

78-
// Get authentication headers
7978
std::unordered_map<std::string, std::string> auth_headers;
80-
ICEBERG_RETURN_UNEXPECTED(session->Authenticate(auth_headers));
79+
ICEBERG_RETURN_UNEXPECTED(session.Authenticate(auth_headers));
8180

8281
ICEBERG_ASSIGN_OR_RAISE(const auto response,
8382
client.Get(config_path, /*params=*/{}, auth_headers,
@@ -137,7 +136,7 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
137136
ICEBERG_ASSIGN_OR_RAISE(auto init_session,
138137
auth_manager->InitSession(init_client, config.configs()));
139138
ICEBERG_ASSIGN_OR_RAISE(auto server_config,
140-
FetchServerConfig(*paths, config, init_session));
139+
FetchServerConfig(*paths, config, *init_session));
141140

142141
std::unique_ptr<RestCatalogProperties> final_config = RestCatalogProperties::FromMap(
143142
MergeConfigs(server_config.defaults, config.configs(), server_config.overrides));

src/iceberg/test/meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ iceberg_tests = {
104104
if get_option('rest').enabled()
105105
iceberg_tests += {
106106
'rest_catalog_test': {
107-
'sources': files('rest_json_serde_test.cc', 'rest_util_test.cc'),
107+
'sources': files(
108+
'auth_manager_test.cc',
109+
'endpoint_test.cc',
110+
'rest_json_serde_test.cc',
111+
'rest_util_test.cc',
112+
),
108113
'dependencies': [iceberg_rest_dep],
109114
},
110115
}

0 commit comments

Comments
 (0)