Skip to content

Commit d32a4e8

Browse files
author
shuxu.li
committed
feat: Implement NoopAuthManager and integrate AuthManager into RestCatalog
1 parent 9da9f76 commit d32a4e8

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
@@ -37,13 +37,13 @@ using AuthManagerRegistry =
3737

3838
/// \brief Known authentication types that are defined in the Iceberg spec.
3939
const std::unordered_set<std::string, StringHash, StringEqual>& KnownAuthTypes() {
40-
static const std::unordered_set<std::string, StringHash, StringEqual> types = {
40+
static const std::unordered_set<std::string, StringHash, StringEqual> kAuthTypes = {
4141
AuthProperties::kAuthTypeNone,
4242
AuthProperties::kAuthTypeBasic,
4343
AuthProperties::kAuthTypeOAuth2,
4444
AuthProperties::kAuthTypeSigV4,
4545
};
46-
return types;
46+
return kAuthTypes;
4747
}
4848

4949
// Infer the authentication type from properties.
@@ -68,7 +68,7 @@ std::string InferAuthType(
6868
class NoopAuthManager : public AuthManager {
6969
public:
7070
Result<std::shared_ptr<AuthSession>> CatalogSession(
71-
[[maybe_unused]] HttpClient& shared_client,
71+
[[maybe_unused]] HttpClient& client,
7272
[[maybe_unused]] const std::unordered_map<std::string, std::string>& properties)
7373
override {
7474
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
@@ -103,7 +103,12 @@ iceberg_tests = {
103103
if get_option('rest').enabled()
104104
iceberg_tests += {
105105
'rest_catalog_test': {
106-
'sources': files('rest_json_serde_test.cc', 'rest_util_test.cc'),
106+
'sources': files(
107+
'auth_manager_test.cc',
108+
'endpoint_test.cc',
109+
'rest_json_serde_test.cc',
110+
'rest_util_test.cc',
111+
),
107112
'dependencies': [iceberg_rest_dep],
108113
},
109114
}

0 commit comments

Comments
 (0)