17 #ifndef __CREDENTIALS_HPP__ 18 #define __CREDENTIALS_HPP__ 33 namespace credentials {
37 LOG(INFO) <<
"Loading credentials for authentication from '" << path <<
"'";
41 return Error(
"Failed to read credentials file '" + path.
string() +
42 "': " + read.
error());
43 }
else if (read->empty()) {
49 LOG(WARNING) <<
"Failed to stat credentials file '" << path
50 <<
"': " << permissions.
error();
52 LOG(WARNING) <<
"Permissions on credentials file '" << path
53 <<
"' are too open; it is recommended that your" 54 <<
" credentials file is NOT accessible by others";
59 return Error(
"Invalid json format: " + json.
error());
63 if (credentials.isError()) {
64 return Error(
"Failed to parse credentials: " 65 + credentials.error());
67 return credentials.get();
73 LOG(INFO) <<
"Loading credential for authentication from '" << path <<
"'";
77 return Error(
"Failed to read credential file '" + path.
string() +
78 "': " + read.
error());
79 }
else if (read->empty()) {
85 LOG(WARNING) <<
"Failed to stat credential file '" << path
86 <<
"': " << permissions.
error();
88 LOG(WARNING) <<
"Permissions on credential file '" << path
89 <<
"' are too open; it is recommended that your" 90 <<
" credential file is NOT accessible by others";
95 return Error(
"Invalid json format: " + json.
error());
99 if (credential.isError()) {
100 return Error(
"Failed to parse credential: " 101 + credential.error());
103 return credential.get();
110 #endif // __CREDENTIALS_HPP__
Definition: errorbase.hpp:36
T & get()&
Definition: try.hpp:80
Try< Permissions > permissions(const std::string &path)
Definition: permissions.hpp:61
bool rwx
Definition: permissions.hpp:52
void json(JSON::ObjectWriter *writer, const asV1Protobuf &protobuf)
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
struct os::Permissions::@21 others
static Try error(const E &e)
Definition: try.hpp:43
Result< std::string > read(int_fd fd, size_t size)
Definition: read.hpp:55
Result< Credential > readCredential(const Path &path)
Definition: credentials.hpp:71
Definition: attributes.hpp:24
bool isError() const
Definition: try.hpp:78
Result< Credentials > read(const Path &path)
Definition: credentials.hpp:35
const std::string & string() const
Definition: path.hpp:387