headers: add csrf (#35)

This commit is contained in:
Vaxry
2025-06-15 17:21:23 +02:00
committed by GitHub
parent b606a21912
commit 7c3bb4cbd9
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#include <pistache/http_headers.h>
#include <pistache/net.h>
class XCSRFTokenHeader : public Pistache::Http::Header::Header {
public:
NAME("X-Csrf-Token");
XCSRFTokenHeader() = default;
void parse(const std::string& str) override {
m_data = str;
}
void write(std::ostream& os) const override {
os << m_data;
}
std::string ip() const {
return m_data;
}
private:
std::string m_data = "";
};

View File

@@ -16,6 +16,7 @@
#include "headers/acceptLanguageHeader.hpp"
#include "headers/setCookieHeader.hpp"
#include "headers/xrealip.hpp"
#include "headers/csrfHeader.hpp"
#include "debug/log.hpp"
#include "helpers/FsUtils.hpp"
@@ -88,6 +89,7 @@ int main(int argc, char** argv, char** envp) {
Pistache::Http::Header::Registry::instance().registerHeader<AcceptLanguageHeader>();
Pistache::Http::Header::Registry::instance().registerHeader<SetCookieHeader>();
Pistache::Http::Header::Registry::instance().registerHeader<XRealIPHeader>();
Pistache::Http::Header::Registry::instance().registerHeader<XCSRFTokenHeader>();
g_pCrypto = std::make_unique<CCrypto>();
g_pTrafficLogger = std::make_unique<CTrafficLogger>();