Skip to content

Conversation

@lishuxu
Copy link
Contributor

@lishuxu lishuxu commented Jan 2, 2026

feat: add restcatalog authentication api


} // namespace iceberg::rest

namespace iceberg::rest::auth {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the extra auth namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here mirrors the Java package structure (org.apache.iceberg.rest.auth), making it easier to navigate between implementations.

Comment on lines 31 to 37
/// \brief Convert a string to lowercase for case-insensitive comparison.
std::string ToLower(std::string_view str) {
std::string result(str);
std::ranges::transform(result, result.begin(),
[](unsigned char c) { return std::tolower(c); });
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a StringUtils::ToLower func in util/string_util.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed.

/// (i.e., request headers take precedence).
///
/// \param headers The headers map to add authentication information to.
void Authenticate(std::unordered_map<std::string, std::string>& headers) override;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is worth adding a class HttpRequest? We don't have it yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need an HttpRequest class at this stage. The current design is sufficient for most auth schemes (Basic, Bearer, OAuth2, API keys), but we can add can add it later if needed.

/// OAuth2 authentication. Otherwise, defaults to no authentication.
///
/// This behavior is consistent with Java Iceberg's AuthManagers.
std::string InferAuthType(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a enum class for the auth type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auth types come from external config files/properties as strings, so the string-based approach allows users to register custom auth types without modifying core code. It also matches the Iceberg REST spec.


private:
/// \brief Get the global registry of auth manager factories.
static std::unordered_map<std::string, AuthManagerFactory>& GetRegistry();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this function in the header file, right?

Comment on lines +55 to +57
for (const auto& [key, value] : headers_) {
headers.try_emplace(key, value);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (const auto& [key, value] : headers_) {
headers.try_emplace(key, value);
}
headers.merge(headers_);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge() is destructive - it moves nodes from headers_ to headers, leaving headers_ empty or partially empty.
so, I think the current implementation can be retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants