feat(admin): read-only admin portal and API (ADR-0182 step 1, schema 61)
evo-admin-api serves the portal at srs.aeternalisgames.com and read-only JSON for world 100 behind Keycloak (realm role aevolution-admin, audience aevolution-admin, client aevolution-admin-portal): accounts with session, status, lives, deaths, resets and mutation choices; one account's lives; the world's regions; and a live 2D region view of cells, wildlife, pools and bubbles. The portal is plain HTML/CSS/JS with PKCE sign-in, a strict CSP and no third-party code. - Schema 61: three bounded SECURITY DEFINER read functions, fenced in the privilege audit; no table or existing function changes. - Cellular regions answer GET /admin/view on the ops port (NetworkPolicy: Prometheus and the admin portal only); CellularLives::extent_of reads the existing phenotype budget. No simulation, checkpoint or wire change. - TokenVerifier takes an optional realm role and returns the email; the ops server's response bound is configurable (16 KiB default unchanged). - DEV component admin-portal-dev (Deployment, Service, NetworkPolicies); the Ingress and the aevolution-admin-pg Secret are created out of band. - CI scripts pinned to schema 60 now expect 61. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-4
@@ -17,6 +17,8 @@ const char* reason(int status) {
|
||||
return "Bad Request";
|
||||
case 401:
|
||||
return "Unauthorized";
|
||||
case 403:
|
||||
return "Forbidden";
|
||||
case 404:
|
||||
return "Not Found";
|
||||
case 429:
|
||||
@@ -40,6 +42,7 @@ std::string encode(const OpsResponse& r) {
|
||||
out += "Allow: GET, POST\r\n";
|
||||
if (r.status == 401)
|
||||
out += "WWW-Authenticate: Bearer\r\n";
|
||||
out += r.headers;
|
||||
return out + "\r\n" + r.body;
|
||||
}
|
||||
bool printable(std::string_view s) {
|
||||
@@ -50,7 +53,10 @@ bool printable(std::string_view s) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::expected<std::unique_ptr<OpsServer>, OpsError> OpsServer::listen(std::string_view address) {
|
||||
std::expected<std::unique_ptr<OpsServer>, OpsError> OpsServer::listen(std::string_view address,
|
||||
std::size_t response_limit) {
|
||||
if (response_limit == 0 || response_limit > max_configurable_response_bytes)
|
||||
return std::unexpected{OpsError::address};
|
||||
const auto colon = address.rfind(':');
|
||||
if (colon == std::string_view::npos || colon + 1 >= address.size())
|
||||
return std::unexpected{OpsError::address};
|
||||
@@ -96,7 +102,7 @@ std::expected<std::unique_ptr<OpsServer>, OpsError> OpsServer::listen(std::strin
|
||||
const auto actual = family == AF_INET6
|
||||
? ntohs(reinterpret_cast<sockaddr_in6*>(&bound)->sin6_port)
|
||||
: ntohs(reinterpret_cast<sockaddr_in*>(&bound)->sin_port);
|
||||
return std::unique_ptr<OpsServer>(new OpsServer(fd, actual));
|
||||
return std::unique_ptr<OpsServer>(new OpsServer(fd, actual, response_limit));
|
||||
}
|
||||
|
||||
OpsServer::~OpsServer() {
|
||||
@@ -123,7 +129,7 @@ void OpsServer::respond(Connection& c, const OpsHandler& handler) {
|
||||
else
|
||||
response = handler(path);
|
||||
}
|
||||
if (response.body.size() > max_response_bytes)
|
||||
if (response.body.size() > response_limit_)
|
||||
response = {500, "response too large\n"};
|
||||
c.out = encode(response);
|
||||
}
|
||||
@@ -172,7 +178,7 @@ void OpsServer::respond_api(Connection& c, const ApiHandler& handler) {
|
||||
response = {400, "bad request\n"};
|
||||
else
|
||||
response = handler({method, path, authorization});
|
||||
if (response.body.size() > max_response_bytes)
|
||||
if (response.body.size() > response_limit_)
|
||||
response = {500, "response too large\n"};
|
||||
c.out = encode(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user