2626#include " iceberg/catalog/rest/iceberg_rest_export.h"
2727#include " iceberg/catalog/rest/type_fwd.h"
2828#include " iceberg/result.h"
29- #include " iceberg/table_identifier .h"
29+ #include " iceberg/type_fwd .h"
3030
3131// / \file iceberg/catalog/rest/auth/auth_manager.h
3232// / \brief Authentication manager interface for REST catalog.
3333
3434namespace 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.
4437class ICEBERG_REST_EXPORT AuthManager {
4538 public:
4639 virtual ~AuthManager () = default ;
@@ -54,37 +47,52 @@ class ICEBERG_REST_EXPORT AuthManager {
5447 // / \param init_client HTTP client used for initialization requests.
5548 // / \param properties Client configuration supplied by the catalog.
5649 // / \return Session for initialization or an error if credentials cannot be acquired.
57- virtual Result<std::unique_ptr <AuthSession>> InitSession (
50+ virtual Result<std::shared_ptr <AuthSession>> InitSession (
5851 HttpClient& init_client,
5952 const std::unordered_map<std::string, std::string>& properties);
6053
6154 // / \brief Create the long-lived catalog session that acts as the parent session.
6255 // /
6356 // / 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.
57+ // / etc.) and serves as the parent session for contextual and table-specific sessions.
58+ // / It is owned by the catalog and reused throughout the catalog's lifetime.
6659 // /
6760 // / \param shared_client HTTP client owned by the catalog and reused for auth calls.
6861 // / \param properties Catalog properties (client config + server defaults).
6962 // / \return Session for catalog operations or an error if authentication cannot be set
7063 // / up.
71- virtual Result<std::unique_ptr <AuthSession>> CatalogSession (
64+ virtual Result<std::shared_ptr <AuthSession>> CatalogSession (
7265 HttpClient& shared_client,
7366 const std::unordered_map<std::string, std::string>& properties) = 0;
7467
68+ // / \brief Create or reuse a session for a specific context.
69+ // /
70+ // / This method is used by SessionCatalog to create sessions for different contexts
71+ // / (e.g., different users or tenants). Each REST endpoint call should use the
72+ // / appropriate contextual session before sending the HTTP request.
73+ // /
74+ // / \param context Context properties (e.g., user credentials, tenant info).
75+ // / \param parent Catalog session to inherit from or return as-is.
76+ // / \return A context-specific session, or the parent session if no context-specific
77+ // / session is needed, or an error if session creation fails.
78+ virtual Result<std::shared_ptr<AuthSession>> ContextualSession (
79+ const std::unordered_map<std::string, std::string>& context,
80+ const std::shared_ptr<AuthSession>& parent);
81+
7582 // / \brief Create or reuse a session scoped to a single table/view.
7683 // /
77- // / This method can return a new table-specific session or indicate that the parent
78- // / catalog session should be reused by returning nullptr .
84+ // / This method is called when loading a table that may have table-specific auth
85+ // / properties returned by the server .
7986 // /
8087 // / \param table Target table identifier.
8188 // / \param properties Table-specific auth properties returned by the server.
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.
84- virtual Result<std::unique_ptr<AuthSession>> TableSession (
89+ // / \param parent Catalog or contextual session to inherit from or return as-is.
90+ // / \return A table-specific session, or the parent session if no table-specific
91+ // / session is needed, or an error if session creation fails.
92+ virtual Result<std::shared_ptr<AuthSession>> TableSession (
8593 const TableIdentifier& table,
8694 const std::unordered_map<std::string, std::string>& properties,
87- const AuthSession& parent);
95+ const std::shared_ptr< AuthSession> & parent);
8896
8997 // / \brief Release resources held by the manager.
9098 // /
0 commit comments