Files
aevolution/include/evo/persistence/account_identity_store.hpp
dingoandClaude Opus 5.5 070c458dc5
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / postgres-tools (push) Successful in 2m9s
Foundation / server-image (push) Successful in 5m23s
Foundation / image (push) Successful in 6m10s
feat(admin): bans, admin logout and time played (schema 64)
ADR-0182 section 11.
- Append-only account bans; a ban also revokes the account's grants (its live
  session closes at the next control renewal) and issue_account_grant refuses a
  banned account (EVL20 -> broker 403 account_banned). Lifting is another row.
- admin_logout_account_v1 revokes by account id.
- Session intervals recorded by claim/renew/release (signatures unchanged):
  time played, sessions and last seen per account.
- The region view carries each cell's lineage root; the portal counts living
  wildlife descended from an account's lives.
- Portal: Ban/Unban and Log out with reason and history; time played column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:50:34 -04:00

35 lines
1.5 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.
banned, // ADR-0182: the account is banned (schema 64); nothing changed.
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