#pragma once #include "evo/persistence/postgres.hpp" #include "evo/persistence/region_lease.hpp" #include #include #include #include #include // 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 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 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 revoke_account_grants(Postgres& db, std::uint64_t world, std::string_view issuer, std::string_view subject, std::chrono::milliseconds timeout); } // namespace evo::persistence