aws_request_signer.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_EXTERNAL_AWS_REQUEST_SIGNER_H
18 #define GRPC_CORE_LIB_SECURITY_CREDENTIALS_EXTERNAL_AWS_REQUEST_SIGNER_H
19 
21 
22 #include <map>
23 #include <string>
24 
27 
28 namespace grpc_core {
29 
30 // Implements an AWS API request signer based on the AWS Signature Version 4
31 // signing process.
32 // https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
33 // To retrieve the subject token in AwsExternalAccountCredentials, we need to
34 // sign an AWS request server and use the signed request as the subject token.
35 // This class is a utility to sign an AWS request.
37  public:
38  // Construct a signer with the necessary information to sign a request.
39  // `access_key_id`, `secret_access_key` and `token` are the AWS credentials
40  // required for signing. `method` and `url` are the HTTP method and url of the
41  // request. `region` is the region of the AWS environment. `request_payload`
42  // is the payload of the HTTP request. `additional_headers` are additional
43  // headers to be inject into the request.
44  AwsRequestSigner(std::string access_key_id, std::string secret_access_key,
46  std::string region, std::string request_payload,
47  std::map<std::string, std::string> additional_headers,
49 
50  // This method triggers the signing process then returns the headers of the
51  // signed request as a map. In case there is an error, the input `error`
52  // parameter will be updated and an empty map will be returned if there is
53  // error.
54  std::map<std::string, std::string> GetSignedRequestHeaders();
55 
56  private:
64  std::map<std::string, std::string> additional_headers_;
65 
67  std::map<std::string, std::string> request_headers_;
68 };
69 
70 } // namespace grpc_core
71 
72 #endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_EXTERNAL_AWS_REQUEST_SIGNER_H
grpc_core
Definition: call_metric_recorder.h:31
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc_core::URI
Definition: uri_parser.h:31
grpc_core::AwsRequestSigner::request_headers_
std::map< std::string, std::string > request_headers_
Definition: aws_request_signer.h:67
grpc_core::AwsRequestSigner
Definition: aws_request_signer.h:36
grpc_core::AwsRequestSigner::token_
std::string token_
Definition: aws_request_signer.h:59
setup.url
url
Definition: setup.py:547
grpc_core::AwsRequestSigner::region_
std::string region_
Definition: aws_request_signer.h:62
grpc_core::AwsRequestSigner::url_
URI url_
Definition: aws_request_signer.h:61
error.h
grpc_core::AwsRequestSigner::AwsRequestSigner
AwsRequestSigner(std::string access_key_id, std::string secret_access_key, std::string token, std::string method, std::string url, std::string region, std::string request_payload, std::map< std::string, std::string > additional_headers, grpc_error_handle *error)
Definition: aws_request_signer.cc:74
grpc_core::AwsRequestSigner::static_request_date_
std::string static_request_date_
Definition: aws_request_signer.h:66
grpc_core::AwsRequestSigner::method_
std::string method_
Definition: aws_request_signer.h:60
grpc_core::AwsRequestSigner::access_key_id_
std::string access_key_id_
Definition: aws_request_signer.h:57
grpc_core::AwsRequestSigner::secret_access_key_
std::string secret_access_key_
Definition: aws_request_signer.h:58
uri_parser.h
grpc_error
Definition: error_internal.h:42
method
NSString * method
Definition: ProtoMethod.h:28
grpc_core::AwsRequestSigner::request_payload_
std::string request_payload_
Definition: aws_request_signer.h:63
grpc_core::AwsRequestSigner::additional_headers_
std::map< std::string, std::string > additional_headers_
Definition: aws_request_signer.h:64
grpc_core::AwsRequestSigner::GetSignedRequestHeaders
std::map< std::string, std::string > GetSignedRequestHeaders()
Definition: aws_request_signer.cc:116
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:35