summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-15 20:01:25 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-15 20:01:25 +0200
commitf6e703a938a95c555b388f79966cf955c5d07dc6 (patch)
treef47eae93adf9f72b1472ced2a1a051e90845dafe /config.cpp
parent1ce0bb7ad50129fbab6c0a75f18eee6149ca1be3 (diff)
HTTP Auth (Basic)
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/config.cpp b/config.cpp
index 0d9c117..3750bcf 100644
--- a/config.cpp
+++ b/config.cpp
@@ -63,8 +63,19 @@ void Config::readConfigfile(std::string filename)
auto attrs = x.second.get_child("<xmlattr>");
path.requested = attrs.get<std::string>("requested");
for (const auto& param: x.second) { // get all sub-elements of <path>
- if (param.first.size() > 0 && param.first[0] != '<') // exclude meta-elements like <xmlattr>
- path.params[param.first.data()] = param.second.data();
+ if (param.first.size() > 0 && param.first[0] != '<') { // exclude meta-elements like <xmlattr>
+ if (param.first == "auth") {
+ try {
+ std::string login{param.second.get<std::string>("<xmlattr>.login")};
+ std::string password{param.second.get<std::string>("<xmlattr>.password")};
+ path.auth[login] = password;
+ } catch (const std::exception& ex) {
+ std::cerr << "Warning: Can't read auth data from config: " << ex.what() << std::endl;
+ }
+ } else {
+ path.params[param.first] = param.second.data();
+ }
+ }
}
site_struct.paths.push_back(path);
} else if (x.first == "certpath"s) {