common/cpp/obj-client/auth/aws_credential_factory.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <aws/core/client/ClientConfiguration.h> |
21 | | |
22 | | #include <memory> |
23 | | #include <string> |
24 | | |
25 | | #include "cpp/aws_common.h" |
26 | | |
27 | | namespace Aws::Auth { |
28 | | class AWSCredentialsProvider; |
29 | | } |
30 | | |
31 | | namespace doris { |
32 | | |
33 | | enum class AwsCredentialProviderVersion { |
34 | | V1, |
35 | | V2, |
36 | | }; |
37 | | |
38 | | enum class EmptyCredentialsBehavior { |
39 | | ANONYMOUS, |
40 | | DEFAULT_CHAIN, |
41 | | }; |
42 | | |
43 | | struct AwsCredentialOptions { |
44 | | AwsCredentialProviderVersion version = AwsCredentialProviderVersion::V1; |
45 | | std::string access_key; |
46 | | std::string secret_key; |
47 | | std::string session_token; |
48 | | CredProviderType provider_type = CredProviderType::Default; |
49 | | std::string role_arn; |
50 | | std::string external_id; |
51 | | EmptyCredentialsBehavior empty_credentials = EmptyCredentialsBehavior::DEFAULT_CHAIN; |
52 | | Aws::Client::ClientConfiguration sts_client_config; |
53 | | }; |
54 | | |
55 | | struct AwsCredentialResult { |
56 | | std::shared_ptr<Aws::Auth::AWSCredentialsProvider> provider {}; |
57 | | std::string error {}; |
58 | | |
59 | 0 | explicit operator bool() const { return provider != nullptr; } |
60 | | }; |
61 | | |
62 | | class AwsCredentialFactory { |
63 | | public: |
64 | | static AwsCredentialResult create(const AwsCredentialOptions& options); |
65 | | }; |
66 | | |
67 | | } // namespace doris |