An authentication session that can authenticate outgoing HTTP requests.
More...
#include <auth_session.h>
|
| virtual Status | Authenticate (std::unordered_map< std::string, std::string > &headers)=0 |
| | Authenticate the given request headers.
|
| |
| virtual Status | Close () |
| | Close the session and release any resources.
|
| |
|
| static std::shared_ptr< AuthSession > | MakeDefault (std::unordered_map< std::string, std::string > headers) |
| | Create a default session with static headers.
|
| |
| static 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, HttpClient &client) |
| | Create an OAuth2 session with automatic token refresh.
|
| |
An authentication session that can authenticate outgoing HTTP requests.
◆ Authenticate()
| virtual Status iceberg::rest::auth::AuthSession::Authenticate |
( |
std::unordered_map< std::string, std::string > & |
headers | ) |
|
|
pure virtual |
Authenticate the given request headers.
This method adds authentication information (e.g., Authorization header) to the provided headers map. The implementation should be idempotent.
- Parameters
-
| [in,out] | headers | The headers map to add authentication information to. |
- Returns
- Status indicating success or one of the following errors:
- AuthenticationFailed: General authentication failure (invalid credentials, etc.)
- TokenExpired: Authentication token has expired and needs refresh
- NotAuthorized: Not authenticated (401)
- IOError: Network or connection errors when reaching auth server
- RestError: HTTP errors from authentication service
◆ Close()
| virtual Status iceberg::rest::auth::AuthSession::Close |
( |
| ) |
|
|
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.
- Returns
- Status indicating success or failure of closing the session.
◆ MakeDefault()
| std::shared_ptr< AuthSession > iceberg::rest::auth::AuthSession::MakeDefault |
( |
std::unordered_map< std::string, std::string > |
headers | ) |
|
|
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.
- Parameters
-
| headers | The headers to add to each request for authentication. |
- Returns
- A new session that adds the given headers to requests.
◆ MakeOAuth2()
| std::shared_ptr< AuthSession > iceberg::rest::auth::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, |
|
|
HttpClient & |
client |
|
) |
| |
|
static |
Create an OAuth2 session with automatic token refresh.
This factory method creates a session that holds an access token and optionally a refresh token. When Authenticate() is called and the token is expired, it transparently refreshes the token before setting the Authorization header.
- Parameters
-
| 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. |
| client | HTTP client for making refresh requests. |
- Returns
- A new session that manages token lifecycle automatically.
The documentation for this class was generated from the following files:
- iceberg/catalog/rest/auth/auth_session.h
- iceberg/catalog/rest/auth/auth_session.cc