Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
aws-creds.hh
Go to the documentation of this file.
1
#pragma once
3
#include "nix/store/config.hh"
4
5
#if NIX_WITH_AWS_AUTH
6
7
# include "
nix/store/s3-url.hh
"
8
# include "
nix/util/ref.hh
"
9
# include "
nix/util/error.hh
"
10
11
# include <memory>
12
# include <optional>
13
# include <string>
14
15
namespace
nix {
16
20
struct
AwsCredentials
21
{
22
std::string accessKeyId;
23
std::string secretAccessKey;
24
std::optional<std::string> sessionToken;
25
26
AwsCredentials(
27
const
std::string & accessKeyId,
28
const
std::string & secretAccessKey,
29
const
std::optional<std::string> & sessionToken = std::nullopt)
30
: accessKeyId(accessKeyId)
31
, secretAccessKey(secretAccessKey)
32
, sessionToken(sessionToken)
33
{
34
}
35
};
36
37
class
AwsAuthError final :
public
CloneableError
<AwsAuthError, Error>
38
{
39
private
:
40
void
anchor()
override
;
41
42
public
:
43
std::optional<int> errorCode;
44
45
public
:
46
using
CloneableError::CloneableError;
47
48
AwsAuthError(
int
errorCode);
49
50
std::optional<int> getErrorCode()
const
51
{
52
return
errorCode;
53
}
54
};
55
56
class
AwsCredentialProvider
57
{
58
public
:
66
virtual
AwsCredentials getCredentials(
const
ParsedS3URL & url) = 0;
67
68
std::optional<AwsCredentials> maybeGetCredentials(
const
ParsedS3URL & url)
69
{
70
try
{
71
return
getCredentials(url);
72
}
catch
(AwsAuthError & e) {
73
return
std::nullopt;
74
}
75
}
76
77
virtual
~AwsCredentialProvider();
78
};
79
83
ref<AwsCredentialProvider>
makeAwsCredentialsProvider();
84
88
ref<AwsCredentialProvider>
getAwsCredentialsProvider();
89
90
}
// namespace nix
91
#endif
nix::CloneableError
Definition
error.hh:279
nix::ref
Definition
ref.hh:58
error.hh
This file defines two main structs/classes used in nix error handling.
ref.hh
s3-url.hh
libstore
include
nix
store
aws-creds.hh
Generated by
1.18.0