aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-02-13 15:19:51 +0100
committerGitHub Enterprise <[email protected]>2026-02-13 15:19:51 +0100
commitdf97b6b2abcc8ce13b1d63e3d2cf27c3bd841768 (patch)
treecd7b89d4a68520ef01a7fb23bc2fb2386013588b /src/zenhttp/include
parentspelling fixes (#755) (diff)
downloadzen-df97b6b2abcc8ce13b1d63e3d2cf27c3bd841768.tar.xz
zen-df97b6b2abcc8ce13b1d63e3d2cf27c3bd841768.zip
add foundation for http password protection (#756)
Diffstat (limited to 'src/zenhttp/include')
-rw-r--r--src/zenhttp/include/zenhttp/security/passwordsecurity.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/zenhttp/include/zenhttp/security/passwordsecurity.h b/src/zenhttp/include/zenhttp/security/passwordsecurity.h
new file mode 100644
index 000000000..026c2865b
--- /dev/null
+++ b/src/zenhttp/include/zenhttp/security/passwordsecurity.h
@@ -0,0 +1,52 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include <zencore/compactbinary.h>
+
+ZEN_THIRD_PARTY_INCLUDES_START
+#include <tsl/robin_map.h>
+ZEN_THIRD_PARTY_INCLUDES_END
+
+namespace zen {
+
+struct PasswordSecurityConfiguration
+{
+ std::string Password; // "password"
+ bool ProtectMachineLocalRequests = false; // "protect-machine-local-requests"
+ std::vector<std::string> UnprotectedUris; // "unprotected-urls"
+};
+
+class PasswordSecurity
+{
+public:
+ PasswordSecurity(const PasswordSecurityConfiguration& Config);
+
+ [[nodiscard]] inline std::string_view Password() const { return m_Config.Password; }
+ [[nodiscard]] inline bool ProtectMachineLocalRequests() const { return m_Config.ProtectMachineLocalRequests; }
+ [[nodiscard]] bool IsUnprotectedUri(std::string_view Uri) const;
+
+ bool IsAllowed(std::string_view Password, std::string_view Uri, bool IsMachineLocalRequest);
+
+private:
+ const PasswordSecurityConfiguration m_Config;
+ tsl::robin_map<uint32_t, uint32_t> m_UnprotectedUrlHashes;
+};
+
+/**
+ * Expected format (Json)
+ * {
+ * "password\": \"1234\",
+ * "protect-machine-local-requests\": false,
+ * "unprotected-urls\": [
+ * "/health\",
+ * "/health/info\",
+ * "/health/version\"
+ * ]
+ * }
+ */
+PasswordSecurityConfiguration ReadPasswordSecurityConfiguration(CbObjectView ConfigObject);
+
+void passwordsecurity_forcelink(); // internal
+
+} // namespace zen