Skip to content

Commit 28e195a

Browse files
author
shuxu.li
committed
feat: add restcatalog authentication api
1 parent 54b4868 commit 28e195a

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/iceberg/catalog/rest/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
# Include auth subdirectory
1918
add_subdirectory(auth)
2019

2120
set(ICEBERG_REST_SOURCES

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,23 @@
3434
namespace iceberg::rest::auth {
3535

3636
/// \brief Produces authentication sessions for catalog and table requests.
37+
///
38+
/// AuthManager is responsible for creating authentication sessions at different scopes:
39+
/// - InitSession: Short-lived session for catalog initialization (optional)
40+
/// - CatalogSession: Long-lived session for catalog-level operations (required)
41+
/// - TableSession: Optional table-specific session or reuse of catalog session
42+
///
43+
/// Implementations are registered via AuthManagers::Register() and loaded by auth type.
3744
class ICEBERG_REST_EXPORT AuthManager {
3845
public:
3946
virtual ~AuthManager() = default;
4047

4148
/// \brief Create a short-lived session used to contact the configuration endpoint.
4249
///
50+
/// This session is used only during catalog initialization to fetch server
51+
/// configuration and perform initial authentication. It is typically discarded after
52+
/// initialization.
53+
///
4354
/// \param init_client HTTP client used for initialization requests.
4455
/// \param properties Client configuration supplied by the catalog.
4556
/// \return Session for initialization or an error if credentials cannot be acquired.
@@ -49,6 +60,10 @@ class ICEBERG_REST_EXPORT AuthManager {
4960

5061
/// \brief Create the long-lived catalog session that acts as the parent session.
5162
///
63+
/// This session is used for all catalog-level operations (list namespaces, list tables,
64+
/// etc.) and serves as the parent session for table-specific operations. It is owned
65+
/// by the catalog and reused throughout the catalog's lifetime.
66+
///
5267
/// \param shared_client HTTP client owned by the catalog and reused for auth calls.
5368
/// \param properties Catalog properties (client config + server defaults).
5469
/// \return Session for catalog operations or an error if authentication cannot be set
@@ -64,8 +79,8 @@ class ICEBERG_REST_EXPORT AuthManager {
6479
///
6580
/// \param table Target table identifier.
6681
/// \param properties Table-specific auth properties returned by the server.
67-
/// \param parent Catalog session to read information from.
68-
/// \return A new session for the table, nullptr to reuse parent, or an error.
82+
/// \param parent Catalog session to inherit from or extract information from.
83+
/// \return A new session for the table, nullptr to reuse parent session, or an error.
6984
virtual Result<std::unique_ptr<AuthSession>> TableSession(
7085
const TableIdentifier& table,
7186
const std::unordered_map<std::string, std::string>& properties,

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ class ICEBERG_REST_EXPORT AuthSession {
6464
/// sessions (e.g., OAuth2 with token refresh), this should stop any background
6565
/// threads and release resources.
6666
///
67-
/// Note: Since sessions may be cached, this method may not be called immediately
68-
/// after the session is no longer needed, but rather when the session is evicted
69-
/// from the cache or the cache itself is closed.
70-
virtual void Close() {}
67+
/// \return Status indicating success or failure of closing the session.
68+
virtual Status Close() { return {}; }
7169
};
7270

7371
/// \brief A default authentication session that adds static headers to requests.

0 commit comments

Comments
 (0)