iceberg-cpp
Loading...
Searching...
No Matches
auth_session.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <memory>
23#include <optional>
24#include <string>
25#include <unordered_map>
26
30#include "iceberg/result.h"
31#include "iceberg/type_fwd.h"
32
35
36namespace iceberg::rest::auth {
37
39struct ICEBERG_REST_EXPORT OAuth2SessionInfo {
40 std::string token;
41 std::string issued_token_type;
42 std::string credential;
43 std::string scope;
44 std::string oauth2_server_uri;
45 std::unordered_map<std::string, std::string> optional_oauth_params;
46 std::unordered_map<std::string, std::string> headers;
47};
48
50class ICEBERG_REST_EXPORT AuthSession {
51 public:
52 virtual ~AuthSession() = default;
53
69
71 virtual std::optional<OAuth2SessionInfo> OAuth2Info() const { return std::nullopt; }
72
75 virtual Status Close() { return {}; }
76
85 static std::shared_ptr<AuthSession> MakeDefault(
86 std::unordered_map<std::string, std::string> headers);
87
107 const OAuthTokenResponse& initial_token, const std::string& token_endpoint,
108 const std::string& client_id, const std::string& client_secret,
109 const std::string& scope, bool keep_refreshed,
110 const std::unordered_map<std::string, std::string>& optional_oauth_params,
111 std::shared_ptr<HttpClient> client, Executor* auth_executor = nullptr);
112};
113
114} // namespace iceberg::rest::auth
Schedules iceberg-cpp tasks.
Definition executor.h:46
Definition expected.h:1199
An authentication session that can authenticate outgoing HTTP requests.
Definition auth_session.h:50
virtual Result< HttpRequest > Authenticate(HttpRequest request)=0
Authenticate an outgoing HTTP request.
static std::shared_ptr< AuthSession > MakeDefault(std::unordered_map< std::string, std::string > headers)
Create a session with static headers.
virtual std::optional< OAuth2SessionInfo > OAuth2Info() const
Return OAuth2 metadata when this is an OAuth2 session.
Definition auth_session.h:71
virtual Status Close()
Stop background refresh and release session resources.
Definition auth_session.h:75
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.
Define REST HTTP request types.
Define symbol visibility macros for the REST catalog library.
REST catalog authentication APIs.
Definition auth_manager.h:34
Define Result, Status, and error helpers.
An outgoing HTTP request. Mirrors Java's HttpRequest so signing implementations like SigV4 see method...
Definition http_request.h:89
Response from an OAuth2 token endpoint.
Definition types.h:318
OAuth2 metadata used to derive child authentication sessions.
Definition auth_session.h:39