userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
signature_v4.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/s3api/authenticators/signature_v4.hpp
4
/// @brief Authenticator implementing AWS Signature Version 4
5
6
#
include
<
string
>
7
#
include
<
unordered_map
>
8
9
#
include
<
userver
/
s3api
/
authenticators
/
interface
.
hpp
>
10
#
include
<
userver
/
s3api
/
models
/
fwd
.
hpp
>
11
#
include
<
userver
/
s3api
/
models
/
secret
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
s3api::
authenticators
{
16
17
/// @brief Authenticator implementing AWS Signature Version 4.
18
///
19
/// `Auth` signs a request with headers (`Authorization`, `X-Amz-Date`,
20
/// `X-Amz-Content-Sha256`), `Sign` produces query parameters for a presigned
21
/// URL (`X-Amz-Algorithm`, `X-Amz-Credential`, `X-Amz-Date`, `X-Amz-Expires`,
22
/// `X-Amz-SignedHeaders`, `X-Amz-Signature`).
23
///
24
/// See https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
25
class
SignatureV4
:
public
Authenticator
{
26
public
:
27
SignatureV4(std::string access_key, Secret secret_key, std::string region, std::string service =
"s3"
)
28
: access_key_{std::move(access_key)},
29
secret_key_{std::move(secret_key)},
30
region_{std::move(region)},
31
service_{std::move(service)}
32
{}
33
34
std::unordered_map<std::string, std::string> Auth(
const
Request
& request)
const
override
;
35
36
/// @note `expires` is an absolute unix timestamp of the moment the
37
/// presigned URL stops being valid, the same way as in
38
/// @ref AccessKey::Sign. It is converted to the `X-Amz-Expires` duration
39
/// relative to the current time.
40
std::unordered_map<std::string, std::string>
Sign
(
const
Request
& request, std::time_t expires)
const
override
;
41
42
private
:
43
std::string access_key_;
44
Secret secret_key_;
45
std::string region_;
46
std::string service_;
47
};
48
49
}
// namespace s3api::authenticators
50
51
USERVER_NAMESPACE_END
userver
s3api
authenticators
signature_v4.hpp
Generated on
for userver by
Doxygen
1.17.0