NetworkedApplications: live config generations and durable backup/restore (P-NETWORKED-05)

This commit is contained in:
faumaray committed 2026-12-04 10:13:31 +03:00
1 parent 3010b8a913
commit 03542d0d2f
7 files changed
+256 -4

No files matched your search

@@ -3,6 +3,7 @@
#include <algorithm>
#include <charconv>
#include <format>
#include <mutex>
#include <string>
#include <utility>
@@ -185,10 +186,6 @@ namespace NetworkedKv
bool KvApi::authorized(const HttpRequest& request) const
{
// Fail closed: an empty configured token authorizes nothing.
if (m_config.bearer_token.empty()) {
return false;
}
const auto header = request.header("authorization");
if (!header) {
return false;
@@ -198,6 +195,11 @@ namespace NetworkedKv
!iequals(header->substr(0, scheme.size()), scheme)) {
return false;
}
std::lock_guard lock{m_config_mutex};
// Fail closed: an empty configured token authorizes nothing.
if (m_config.bearer_token.empty()) {
return false;
}
return constant_time_equal(header->substr(scheme.size()),
m_config.bearer_token);
}