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{
22 {
23 }
24
25 Creds(std::string access_key_arg,
26 std::string secret_key_arg,
27 std::string token_arg = "")
28 : access_key(std::move(access_key_arg)),
29 secret_key(std::move(secret_key_arg)),
30 token(std::move(token_arg))
31 {
32 }
33
34 // can be used to load from HTTP creds
35 template <typename CREDS>
36 Creds(const CREDS &creds)
37 : access_key(creds.username),
38 secret_key(creds.password)
39 {
40 }
41
42 bool defined() const
43 {
44 return !access_key.empty() && !secret_key.empty();
45 }
46
47 std::string to_string() const
48 {
49 return "AWS::Creds[access_key=" + access_key + " len(secret_key)=" + std::to_string(secret_key.length()) + ']';
50 }
51
52 std::string access_key;
53 std::string secret_key;
54 std::string token;
55};
56} // namespace openvpn::AWS
bool defined() const
Definition awscreds.hpp:42
std::string access_key
Definition awscreds.hpp:52
Creds(const CREDS &creds)
Definition awscreds.hpp:36
Creds(std::string access_key_arg, std::string secret_key_arg, std::string token_arg="")
Definition awscreds.hpp:25
std::string token
Definition awscreds.hpp:54
std::string secret_key
Definition awscreds.hpp:53
std::string to_string() const
Definition awscreds.hpp:47