OpenVPN 3 Core Library
Loading...
Searching...
No Matches
awscreds.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12// AWS credentials
13
14#pragma once
15
16#include <string>
17
18namespace openvpn::AWS {
19struct Creds
20{
21 Creds() = default;
22
23 Creds(std::string access_key_arg,
24 std::string secret_key_arg,
25 std::string token_arg = "")
26 : access_key(std::move(access_key_arg)),
27 secret_key(std::move(secret_key_arg)),
28 token(std::move(token_arg))
29 {
30 }
31
32 // can be used to load from HTTP creds
33 template <typename CREDS>
34 Creds(const CREDS &creds)
35 : access_key(creds.username),
36 secret_key(creds.password)
37 {
38 }
39
40 bool defined() const
41 {
42 return !access_key.empty() && !secret_key.empty();
43 }
44
45 std::string to_string() const
46 {
47 return "AWS::Creds[access_key=" + access_key + " len(secret_key)=" + std::to_string(secret_key.length()) + ']';
48 }
49
50 std::string access_key;
51 std::string secret_key;
52 std::string token;
53};
54} // namespace openvpn::AWS
bool defined() const
Definition awscreds.hpp:40
std::string access_key
Definition awscreds.hpp:50
Creds(const CREDS &creds)
Definition awscreds.hpp:34
Creds(std::string access_key_arg, std::string secret_key_arg, std::string token_arg="")
Definition awscreds.hpp:23
std::string token
Definition awscreds.hpp:52
std::string secret_key
Definition awscreds.hpp:51
std::string to_string() const
Definition awscreds.hpp:45