feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// Spec: plans/01-runtime.md 6.6. Request jar (joins H2-split Cookie fields
|
||||
// with "; ", caps 50 cookies and 8 KB, overflow is 431) and response list
|
||||
// (one Set-Cookie per cookie, never joined). Secure forced on https.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cookie.h"
|
||||
#include "signer.h"
|
||||
|
||||
namespace molo::runtime::cookie {
|
||||
|
||||
enum class JarError {
|
||||
Ok,
|
||||
TooMany, // maps to 431
|
||||
TooLarge, // maps to 431
|
||||
BadCookie, // maps to 400
|
||||
};
|
||||
|
||||
class CookieJar {
|
||||
public:
|
||||
explicit CookieJar(bool secure_context = false)
|
||||
: secure_context_(secure_context) {}
|
||||
|
||||
// Parses request Cookie fields. H2 may split one logical Cookie across
|
||||
// several fields: callers pass them all and the jar joins with "; ".
|
||||
JarError ParseRequest(const std::vector<std::string>& cookie_fields);
|
||||
std::string Get(std::string_view name) const;
|
||||
bool VerifySigned(std::string_view name, ISigner& signer,
|
||||
std::string& payload_out) const;
|
||||
const std::vector<std::pair<std::string, std::string>>& cookies() const {
|
||||
return cookies_;
|
||||
}
|
||||
void Clear() { cookies_.clear(); }
|
||||
|
||||
// Response side.
|
||||
JarError Set(Cookie c); // applies Secure default in secure contexts
|
||||
JarError SetSigned(std::string name, std::string payload, ISigner& signer,
|
||||
std::string path = "/");
|
||||
const std::vector<std::string>& set_cookie_headers() const {
|
||||
return set_headers_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool secure_context_;
|
||||
std::vector<std::pair<std::string, std::string>> cookies_;
|
||||
std::vector<std::string> set_headers_;
|
||||
};
|
||||
|
||||
} // namespace molo::runtime::cookie
|
||||
Reference in New Issue
Block a user