Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
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
15namespace nix {
16
20struct 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
37class AwsAuthError final : public CloneableError<AwsAuthError, Error>
38{
39private:
40 void anchor() override;
41
42public:
43 std::optional<int> errorCode;
44
45public:
46 using CloneableError::CloneableError;
47
48 AwsAuthError(int errorCode);
49
50 std::optional<int> getErrorCode() const
51 {
52 return errorCode;
53 }
54};
55
56class AwsCredentialProvider
57{
58public:
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
83ref<AwsCredentialProvider> makeAwsCredentialsProvider();
84
88ref<AwsCredentialProvider> getAwsCredentialsProvider();
89
90} // namespace nix
91#endif
Definition error.hh:279
Definition ref.hh:58
This file defines two main structs/classes used in nix error handling.