|
iceberg-cpp
|
An authentication session that can authenticate outgoing HTTP requests. More...
#include <auth_session.h>
Public Member Functions | |
| virtual Result< HttpRequest > | Authenticate (HttpRequest request)=0 |
| Authenticate an outgoing HTTP request. | |
| virtual Status | Close () |
| Close the session and release any resources. | |
Static Public Member Functions | |
| static std::shared_ptr< AuthSession > | MakeDefault (std::unordered_map< std::string, std::string > headers) |
| Create a default session with static headers. | |
| static Result< std::shared_ptr< AuthSession > > | MakeOAuth2 (const OAuthTokenResponse &initial_token, const std::string &token_endpoint, const std::string &client_id, const std::string &client_secret, const std::string &scope, bool keep_refreshed, const std::unordered_map< std::string, std::string > &optional_oauth_params, HttpClient &client) |
| Create an OAuth2 session with automatic token refresh. | |
An authentication session that can authenticate outgoing HTTP requests.
|
pure virtual |
Authenticate an outgoing HTTP request.
Returns a request with authentication information (e.g., an Authorization header) added. Implementations must be idempotent. The request is passed by value so callers can move request bodies into the authentication path.
| request | The request to authenticate. |
Implemented in iceberg::rest::auth::SigV4AuthSession.
|
inlinevirtual |
Close the session and release any resources.
This method is called when the session is no longer needed. For stateful sessions (e.g., OAuth2 with token refresh), this should stop any background threads and release resources.
Reimplemented in iceberg::rest::auth::SigV4AuthSession.
|
static |
Create a default session with static headers.
This factory method creates a session that adds a fixed set of headers to each request. It is suitable for authentication methods that use static credentials, such as Basic auth or static bearer tokens.
| headers | The headers to add to each request for authentication. |
|
static |
Create an OAuth2 session with automatic token refresh.
This factory method creates a session that holds an access token and, when keep_refreshed is enabled, schedules background refresh based on token expiration. Authenticate() uses the latest cached Authorization header and does not perform a synchronous token refresh.
| initial_token | The initial token response from FetchToken(). |
| token_endpoint | Full URL of the OAuth2 token endpoint for refresh. |
| client_id | OAuth2 client ID for refresh requests. |
| client_secret | OAuth2 client secret for re-fetch if refresh fails. |
| scope | OAuth2 scope for refresh requests. |
| keep_refreshed | Whether to schedule automatic token refresh. |
| optional_oauth_params | Optional OAuth params (audience, resource) for refresh. |
| client | HTTP client for making refresh requests. The caller owns the client and must keep it alive until the session is closed. |