Files
aevolution/include/evo/persistence/account_identity_store.hpp
T
dingoandClaude Opus 5.5 68880ba3b4
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
ADR-0131: Keycloak grant broker and schema v39 account identities
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>
2026-10-15 10:20:27 -04:00

34 lines
1.4 KiB
C++

#pragma once
#include "evo/persistence/postgres.hpp"
#include "evo/persistence/region_lease.hpp"
#include <chrono>
#include <cstdint>
#include <expected>
#include <optional>
#include <string_view>
// Schema v39, ADR-0131: Keycloak identities to game accounts, and grant serials.
namespace evo::persistence {
enum class AccountIdentityError : std::uint8_t {
invalid, // Arguments refused.
store, // Other failure; nothing changed.
unknown // May have executed: reconnect before relying on the serial.
};
struct IssuedGrantSerial {
Uuid account{};
std::uint64_t serial{};
std::optional<std::uint64_t> home_region; // Region holding the active life, if any.
friend bool operator==(const IssuedGrantSerial&, const IssuedGrantSerial&) = default;
};
// The account for (issuer, subject), created on first use, with its next grant serial.
[[nodiscard]] std::expected<IssuedGrantSerial, AccountIdentityError>
issue_account_grant(Postgres& db, std::uint64_t world, std::string_view issuer,
std::string_view subject, std::chrono::milliseconds timeout);
// Logout: every grant issued so far becomes stale and current control expires. False
// when the identity never had an account.
[[nodiscard]] std::expected<bool, AccountIdentityError>
revoke_account_grants(Postgres& db, std::uint64_t world, std::string_view issuer,
std::string_view subject, std::chrono::milliseconds timeout);
} // namespace evo::persistence