Foundation / checks (checks) (push) Successful in 42m13s
Foundation / checks (deploy) (push) Successful in 4m5s
Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (network) (push) Successful in 19m18s
Foundation / checks (postgres) (push) Successful in 44m19s
Foundation / checks (tsan) (push) Successful in 9m48s
Foundation / checks (client) (push) Failing after 12m6s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
evo-grant-broker verifies realm aeternalis access tokens offline (RS256 against the pinned JWKS; audience aevolution-grants, client aevolution-game, verified email) and issues 10-minute session grants: - POST /grant routes to the region holding the account's life, or the default. - POST /logout makes every issued grant stale and expires current control. - GET /healthz. Schema v39 maps (issuer, subject) to stable accounts with strictly increasing serials. The binary ships in the server image. The DEV manifests are in deploy/kubernetes/grant-broker-dev and are not yet enabled in region/dev; that waits for the image promotion and the out-of-band Secrets and Ingress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.0 KiB
C++
55 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "evo/network/session_grant.hpp"
|
|
#include "evo/persistence/postgres.hpp"
|
|
#include "evo/server/broker/access_token.hpp"
|
|
#include "evo/server/ops_http.hpp"
|
|
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// ADR-0131: turns a verified Keycloak access token into a short-lived session grant
|
|
// for the region holding the account's life, and revokes an account's grants on logout.
|
|
namespace evo::server::broker {
|
|
struct BrokerRoute {
|
|
std::uint64_t region{};
|
|
std::string endpoint, server_name; // "host:port" and the region's TLS name.
|
|
};
|
|
struct BrokerConfig {
|
|
std::uint64_t world{}, frame{}, default_region{};
|
|
std::vector<BrokerRoute> routes; // Every region a grant may name.
|
|
std::uint64_t grant_lifetime_seconds{600};
|
|
std::chrono::seconds min_interval{2}; // Per account, between grants.
|
|
std::chrono::milliseconds db_timeout{3000};
|
|
};
|
|
using BrokerConnect = std::function<std::unique_ptr<persistence::Postgres>()>;
|
|
// Supplies fresh 64-bit grant ids (random); false when randomness is unavailable.
|
|
using GrantIdSource = std::function<bool(std::uint64_t&)>;
|
|
|
|
class GrantBroker {
|
|
public:
|
|
GrantBroker(BrokerConfig config, TokenVerifier verifier, network::GrantSigningKey key,
|
|
BrokerConnect connect, GrantIdSource ids);
|
|
// GET /healthz, POST /grant and POST /logout. `now_seconds` is wall time.
|
|
[[nodiscard]] OpsResponse handle(const ApiRequest& request, std::uint64_t now_seconds);
|
|
|
|
private:
|
|
[[nodiscard]] OpsResponse issue(const AccessTokenClaims& claims, std::uint64_t now_seconds);
|
|
[[nodiscard]] OpsResponse logout(const AccessTokenClaims& claims);
|
|
persistence::Postgres* database();
|
|
|
|
BrokerConfig config_;
|
|
TokenVerifier verifier_;
|
|
network::GrantSigningKey key_;
|
|
BrokerConnect connect_;
|
|
GrantIdSource ids_;
|
|
std::unique_ptr<persistence::Postgres> db_;
|
|
std::map<std::string, std::uint64_t> last_grant_; // Subject to wall seconds; bounded.
|
|
};
|
|
} // namespace evo::server::broker
|