From f6e703a938a95c555b388f79966cf955c5d07dc6 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 15 Apr 2020 20:01:25 +0200 Subject: HTTP Auth (Basic) --- config.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'config.cpp') 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(""); path.requested = attrs.get("requested"); for (const auto& param: x.second) { // get all sub-elements of - if (param.first.size() > 0 && param.first[0] != '<') // exclude meta-elements like - path.params[param.first.data()] = param.second.data(); + if (param.first.size() > 0 && param.first[0] != '<') { // exclude meta-elements like + if (param.first == "auth") { + try { + std::string login{param.second.get(".login")}; + std::string password{param.second.get(".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) { -- cgit v1.2.3