An authentication session that can authenticate outgoing HTTP requests.
More...
#include <auth_session.h>
|
| static std::shared_ptr< AuthSession > | MakeDefault (std::unordered_map< std::string, std::string > headers) |
| | Create a 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, std::shared_ptr< HttpClient > client, Executor *auth_executor=nullptr) |
| | Create an OAuth2 session with automatic token refresh.
|
| |
An authentication session that can authenticate outgoing HTTP requests.
◆ Authenticate()
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.
- Parameters
-
| request | The request to authenticate. |
- Returns
- The authenticated request on success, or one of:
- 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 |
Stop background refresh and release session resources.
- Returns
- Status of the close operation.
◆ MakeDefault()
| static std::shared_ptr< AuthSession > iceberg::rest::auth::AuthSession::MakeDefault |
( |
std::unordered_map< std::string, std::string > |
headers | ) |
|
|
static |
Create a 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()
| static Result< 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, |
|
|
bool |
keep_refreshed, |
|
|
const std::unordered_map< std::string, std::string > & |
optional_oauth_params, |
|
|
std::shared_ptr< HttpClient > |
client, |
|
|
Executor * |
auth_executor = nullptr |
|
) |
| |
|
static |
Create an OAuth2 session with automatic token refresh.
Refreshes expiring tokens in the background when keep_refreshed is true. Authenticate() uses the cached token without refreshing it.
- 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. |
| 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 session retains ownership of the client. |
| auth_executor | Borrowed refresh executor; required if keep_refreshed is true. Ignored otherwise. Must enqueue asynchronously and outlive the session and its tasks. |
- Returns
- The session, or InvalidArgument if refresh is enabled without an executor.
The documentation for this class was generated from the following file: