current() {
return Optional.of(readProtectedFile(Path.of(protectedBindingPath)));
} catch (Exception ex) {
// Never expose config contents, file paths, or certificate details through RPC errors.
+ org.slf4j.LoggerFactory.getLogger(AccountJwtSignerMaterializerTrustBinding.class)
+ .debug("JWT materializer trust binding unavailable: {}", ex.getClass().getSimpleName());
return Optional.empty();
}
}
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/AccountProtectedJwksSourceConfiguration.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/AccountProtectedJwksSourceConfiguration.java
index 938fc490d9..fcf4366416 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/AccountProtectedJwksSourceConfiguration.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/AccountProtectedJwksSourceConfiguration.java
@@ -45,6 +45,13 @@ AccountJwtJwksApiBinding accountPublicJwksApiBinding(
// sources on use; a later materializer namespace cannot replace this accepted API identity.
return api;
} catch (RuntimeException failure) {
+ // Fixed, non-secret failure category only; the binding readers never put file contents,
+ // tokens or certificate material in their messages.
+ org.slf4j.LoggerFactory.getLogger(AccountProtectedJwksSourceConfiguration.class)
+ .warn(
+ "Protected Account JWKS API binding unavailable: {}: {}",
+ failure.getClass().getSimpleName(),
+ failure.getMessage());
throw unavailable();
}
}
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/PreV1JwtSignerLifecycleConfiguration.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/PreV1JwtSignerLifecycleConfiguration.java
new file mode 100644
index 0000000000..3529f7ac71
--- /dev/null
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/config/PreV1JwtSignerLifecycleConfiguration.java
@@ -0,0 +1,123 @@
+package net.firedevops.firemud.accountservice.config;
+
+import java.time.Clock;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import net.firedevops.firemud.accountservice.repository.AccountJwtJwksPublicationRepository;
+import net.firedevops.firemud.accountservice.repository.AccountJwtReadinessProbeRepository;
+import net.firedevops.firemud.accountservice.repository.AccountJwtSignerDesiredStateRepository;
+import net.firedevops.firemud.accountservice.service.session.AccountJwtJwksConfigMapClient;
+import net.firedevops.firemud.accountservice.service.session.AccountJwtJwksPrepublicationService;
+import net.firedevops.firemud.accountservice.service.session.AccountJwtReadinessProbeService;
+import net.firedevops.firemud.accountservice.service.session.AccountJwtSignerBootstrapCoordinator;
+import net.firedevops.firemud.accountservice.service.session.AccountJwtValidatorInventorySource;
+import net.firedevops.firemud.accountservice.service.session.PreV1SelfAttestedReadinessDriver;
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.support.TransactionTemplate;
+
+/**
+ * Pre-v1 composition (ADR 0185) of Account's interim JWT signer lifecycle for Compose smoke.
+ *
+ * Nothing in production composes the bootstrap coordinator, validator inventory or readiness
+ * probe service yet. Under the pre-v1 gate waiver this wires them against the Compose stand-ins and
+ * runs the self-attested readiness driver so the materializer stand-in can promote a signer. The
+ * real orchestration and per-Pod verification are owed before v1.
+ */
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(name = PreV1GateWaivers.PROPERTY, havingValue = "true")
+@ConditionalOnProperty(
+ prefix = "firemud.account.jwt-signer.materialization",
+ name = "enabled",
+ havingValue = "true")
+@Import(AccountProtectedJwksSourceConfiguration.class)
+public class PreV1JwtSignerLifecycleConfiguration {
+ @Bean
+ AccountJwtJwksPrepublicationService preV1JwtPrepublication(
+ AccountJwtSignerDesiredStateRepository desiredState,
+ AccountJwtJwksPublicationRepository publications,
+ AccountJwtSignerMaterializerTrustBinding materializerTrust,
+ AccountJwtJwksConfigMapClient configMaps,
+ @Qualifier("transactionManager") PlatformTransactionManager transactions) {
+ return new AccountJwtJwksPrepublicationService(
+ desiredState, publications, materializerTrust, configMaps, transactions);
+ }
+
+ @Bean
+ AccountJwtValidatorInventorySource preV1JwtValidatorInventory(AccountJwtJwksApiBinding api) {
+ return new AccountJwtValidatorInventorySource(
+ api,
+ new AccountJwtValidatorInventoryBinding(
+ true, AccountJwtValidatorInventoryBinding.PROTECTED_BINDING_PATH.toString()),
+ Clock.systemUTC());
+ }
+
+ @Bean
+ AccountJwtReadinessProbeService preV1JwtReadinessProbes(
+ AccountJwtReadinessProbeRepository readiness,
+ AccountJwtValidatorInventorySource inventory,
+ @Qualifier("transactionManager") PlatformTransactionManager transactions) {
+ return new AccountJwtReadinessProbeService(
+ readiness, new TransactionTemplate(transactions), Clock.systemUTC(), inventory);
+ }
+
+ @Bean
+ AccountJwtSignerBootstrapCoordinator preV1JwtSignerBootstrapCoordinator(
+ AccountJwtSignerMaterializerTrustBinding materializerTrust,
+ AccountJwtJwksConfigMapClient configMaps,
+ AccountJwtSignerDesiredStateRepository desiredState,
+ AccountJwtJwksPrepublicationService prepublication,
+ AccountJwtReadinessProbeRepository readiness,
+ ObjectProvider inventory,
+ @Qualifier("transactionManager") PlatformTransactionManager transactions) {
+ return new AccountJwtSignerBootstrapCoordinator(
+ materializerTrust,
+ configMaps,
+ desiredState,
+ prepublication,
+ readiness,
+ inventory,
+ new TransactionTemplate(transactions));
+ }
+
+ @Bean
+ PreV1SelfAttestedReadinessDriver preV1SelfAttestedReadinessDriver(
+ PreV1GateWaivers waivers,
+ AccountJwtSignerMaterializerTrustBinding materializerTrust,
+ AccountJwtReadinessTrustBinding readinessTrust,
+ AccountJwtSignerDesiredStateRepository desiredState,
+ AccountJwtReadinessProbeRepository readiness,
+ AccountJwtReadinessProbeService probes,
+ @Qualifier("transactionManager") PlatformTransactionManager transactions) {
+ return new PreV1SelfAttestedReadinessDriver(
+ waivers,
+ materializerTrust,
+ readinessTrust,
+ desiredState,
+ readiness,
+ probes,
+ new TransactionTemplate(transactions),
+ Clock.systemUTC());
+ }
+
+ @Bean(destroyMethod = "shutdownNow")
+ ScheduledExecutorService preV1SelfAttestedReadinessSchedule(
+ PreV1SelfAttestedReadinessDriver driver) {
+ ScheduledExecutorService executor =
+ Executors.newSingleThreadScheduledExecutor(
+ task -> {
+ Thread thread = new Thread(task, "pre-v1-self-attested-readiness");
+ thread.setDaemon(true);
+ return thread;
+ });
+ executor.scheduleWithFixedDelay(driver::driveOnce, 10, 5, TimeUnit.SECONDS);
+ return executor;
+ }
+}
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeEntitlementsDto.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeEntitlementsDto.java
index 19ad9cfe05..816e74c4ee 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeEntitlementsDto.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeEntitlementsDto.java
@@ -1,7 +1,9 @@
package net.firedevops.firemud.accountservice.dto;
+import java.util.UUID;
+
public record RuntimeEntitlementsDto(
- Long tenantId,
+ UUID tenantId,
boolean gameplayAvailable,
boolean allowPublicJoin,
long entitlementVersion,
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantAuthorityEventRepository.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantAuthorityEventRepository.java
index ac817af7f1..7d625c64f3 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantAuthorityEventRepository.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantAuthorityEventRepository.java
@@ -11,6 +11,7 @@
import net.firedevops.firemud.common.tenant.FreshTenantCreationEvidence;
import org.jooq.DSLContext;
import org.jooq.Record;
+import org.jooq.impl.DSL;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -57,6 +58,17 @@ public AccountTenantAuthorityEventRepository(
this.generations = Objects.requireNonNull(generations);
}
+ /** Whether any current tenant source row exists; it grants no entitlement authority. */
+ @Transactional(propagation = Propagation.MANDATORY)
+ public boolean hasCurrentSource(UUID tenantId) {
+ requireTransaction();
+ requireTenant(tenantId);
+ return dsl.fetchExists(
+ dsl.selectOne()
+ .from(DSL.table(DSL.name("account_tenant_authority_source_records")))
+ .where(DSL.field(DSL.name("tenant_uuid"), UUID.class).eq(tenantId)));
+ }
+
/** Data-only routing hint over the exact current source; it grants no entitlement authority. */
@Transactional(propagation = Propagation.MANDATORY)
public SourceSelection readCurrentSourceSelection(UUID tenantId) {
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountService.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountService.java
index 93c117a14c..1fdb2fe3ca 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountService.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountService.java
@@ -79,7 +79,7 @@ RealmAccessGrantResult getRealmAccessGrantForRuntime(
void revokeRealmAccess(Long accountId, Long tenantId, String worldSlug, String realmSlug);
- RuntimeEntitlementsDto getTenantEntitlementsForRuntime(Long tenantId, String requestId);
+ RuntimeEntitlementsDto getTenantEntitlementsForRuntime(UUID tenantId, String requestId);
ProfileDto getProfile(Long tenantId, Long accountId);
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java
index a0addcc784..eb469c7a02 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java
@@ -725,12 +725,12 @@ public void getTenantEntitlementsForRuntime(
StreamObserver responseObserver) {
try {
requireRuntimeEntitlementsPeer();
- long tenantId = requirePositiveRequestId(request.getTenantId(), "tenantId");
+ UUID tenantId = requireCanonicalUuid(request.getTenantId(), "tenantId");
String requestId = requireText(request.getRequestId(), "requestId");
var dto = accountService.getTenantEntitlementsForRuntime(tenantId, requestId);
GetTenantEntitlementsForRuntimeResponse response =
GetTenantEntitlementsForRuntimeResponse.newBuilder()
- .setTenantId(String.valueOf(dto.tenantId()))
+ .setTenantId(dto.tenantId().toString())
.setGameplayAvailable(dto.gameplayAvailable())
.setAllowPublicJoin(dto.allowPublicJoin())
.setEntitlementVersion(dto.entitlementVersion())
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountJwtSignerMaterializationService.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountJwtSignerMaterializationService.java
index c13cd5aa4c..1d17d9db34 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountJwtSignerMaterializationService.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountJwtSignerMaterializationService.java
@@ -691,9 +691,10 @@ private static Status statusFor(RuntimeException exception) {
return Status.ALREADY_EXISTS.withDescription(
"JWT materialization operation or public result conflicts with retained Account evidence");
}
- if (exception instanceof BootstrapOperationException) {
+ if (exception instanceof BootstrapOperationException bootstrapFailure) {
return Status.FAILED_PRECONDITION.withDescription(
- "Account JWT signer bootstrap enrollment is quarantined");
+ "Account JWT signer bootstrap enrollment is quarantined: "
+ + bootstrapFailure.failureCode());
}
if (exception instanceof AccountJwtSignerDesiredStateRepository.NoPreparedPromotionException) {
return Status.NOT_FOUND.withDescription("No Account-authorized signer promotion is pending");
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountServiceImpl.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountServiceImpl.java
index 17deafaa58..c32b739f58 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountServiceImpl.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountServiceImpl.java
@@ -126,6 +126,7 @@
import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec.PublishedRealmEvidence;
import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec.RetainedTargetSelector;
import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec.Target;
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
import net.firedevops.firemud.common.security.JwtAuthProperties;
import net.firedevops.firemud.common.security.JwtClaims;
import net.firedevops.firemud.common.security.JwtUtil;
@@ -170,6 +171,7 @@ public class AccountServiceImpl implements AccountService {
private volatile AccountCanonicalPublicRealmScopeOwner canonicalPublicRealmScopeOwner;
private volatile CanonicalScopeConsumers canonicalScopeConsumers;
private volatile AccountBootstrapRosterReadClient accountBootstrapRosterReadClient;
+ private volatile RuntimeEntitlementSources runtimeEntitlementSources;
private final AccountRepository accountRepository;
private final AccountAuthorityGenerationRepository accountAuthorityGenerationRepository;
@@ -475,6 +477,24 @@ public List listBootstrapWorlds(String bootstrapToken) {
return owner.listWorlds(bootstrapToken);
}
+ /** Canonical tenant entitlement sources for the runtime PLAY read, keyed by tenant UUID. */
+ @Autowired(required = false)
+ public void setRuntimeEntitlementSources(
+ AccountTenantAuthorityEventRepository tenantSources,
+ AccountDemoTenantEntitlementRepository demos,
+ PreV1GateWaivers waivers) {
+ runtimeEntitlementSources =
+ new RuntimeEntitlementSources(
+ Objects.requireNonNull(tenantSources),
+ Objects.requireNonNull(demos),
+ Objects.requireNonNull(waivers));
+ }
+
+ private record RuntimeEntitlementSources(
+ AccountTenantAuthorityEventRepository tenantSources,
+ AccountDemoTenantEntitlementRepository demos,
+ PreV1GateWaivers waivers) {}
+
/**
* Explicit held composition; the owner retains the signed V2 selector before publication. Its
* direct-text entry point authenticates the existing Game Session caller separately.
@@ -1240,12 +1260,47 @@ private String responseAccountUuid(Account account, Long accountId) {
}
}
- private RuntimeEntitlementsDto readTenantEntitlements(long tenantId, boolean lockSubscription) {
- // Retained numeric rows cannot supply canonical identity, provider provenance, current-row
- // selection, or a committed billing checkpoint. Deny before any historical evidence read.
- throw new AuthenticationException(
- "ENTITLEMENT_UNAVAILABLE",
- "Canonical tenant entitlement authority is unavailable; retry later");
+ private RuntimeEntitlementsDto readTenantEntitlements(UUID tenantId) {
+ RuntimeEntitlementSources sources = runtimeEntitlementSources;
+ if (sources == null) {
+ throw new AuthenticationException(
+ "ENTITLEMENT_UNAVAILABLE",
+ "Canonical tenant entitlement authority is unavailable; retry later");
+ }
+ try {
+ return Objects.requireNonNull(
+ joinTransactionTemplate.execute(status -> readTenantEntitlements(sources, tenantId)));
+ } catch (AuthenticationException denied) {
+ throw denied;
+ } catch (RuntimeException failure) {
+ throw new AuthenticationException(
+ "ENTITLEMENT_UNAVAILABLE",
+ "Canonical tenant entitlement authority is unavailable; retry later",
+ failure);
+ }
+ }
+
+ private RuntimeEntitlementsDto readTenantEntitlements(
+ RuntimeEntitlementSources sources, UUID tenantId) {
+ if (sources.waivers().enabled() && !sources.tenantSources().hasCurrentSource(tenantId)) {
+ // Pre-v1 waiver (ADR 0185): script-seeded preview tenants have no Account tenant-creation
+ // source yet, so they are entitled for gameplay without one.
+ return new RuntimeEntitlementsDto(tenantId, true, true, 1L, 1L, Instant.now().toString());
+ }
+ SourceSelection source = sources.tenantSources().readCurrentSourceSelection(tenantId);
+ if (source.kind() != AccountTenantAuthorityEventRepository.SourceKind.NON_PAID_DEMO) {
+ // Paid hosting needs the provider observation outside SQL; it is not composed here yet.
+ throw new AuthenticationException(
+ "ENTITLEMENT_UNAVAILABLE", "Paid tenant entitlement read is unavailable; retry later");
+ }
+ var demo = sources.demos().readCurrent(tenantId);
+ return new RuntimeEntitlementsDto(
+ tenantId,
+ demo.gameplayAvailable(),
+ demo.allowPublicJoin(),
+ demo.entitlementVersion(),
+ demo.tenantBillingSequence(),
+ Instant.now().toString());
}
@Override
@@ -1350,10 +1405,9 @@ public void revokeRealmAccess(Long accountId, Long tenantId, String worldSlug, S
}
@Override
- @Transactional(readOnly = true)
@Timed(value = "account.runtime_entitlements")
- public RuntimeEntitlementsDto getTenantEntitlementsForRuntime(Long tenantId, String requestId) {
- return readTenantEntitlements(tenantId, false);
+ public RuntimeEntitlementsDto getTenantEntitlementsForRuntime(UUID tenantId, String requestId) {
+ return readTenantEntitlements(Objects.requireNonNull(tenantId, "tenantId"));
}
private BootstrapContext requireBootstrapContext(String bootstrapToken) {
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiver.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiver.java
index dc88dc6fdf..aaae35693b 100644
--- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiver.java
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiver.java
@@ -11,8 +11,8 @@
import java.util.Arrays;
import java.util.Objects;
import java.util.UUID;
+import java.util.function.BooleanSupplier;
import net.firedevops.firemud.account.AuthenticationErrorCodes;
-import net.firedevops.firemud.account.v1.AccountServiceGrpc;
import net.firedevops.firemud.account.v1.AuthenticateRequest;
import net.firedevops.firemud.account.v1.AuthenticateResponse;
import net.firedevops.firemud.account.v1.GameplayLoginTransportClass;
@@ -28,16 +28,17 @@
import org.jooq.exception.DataAccessException;
/**
- * Unregistered canonical Authenticate adapter. Construction exposes no endpoint or Spring bean. The
+ * Unregistered canonical Authenticate adapter. It is not a {@code BindableService}: the one
+ * AccountService registration delegates to it, so the bean exposes no second endpoint. The
* certificate-derived Game Session peer attests the source context; this adapter neither
* authenticates the public ingress nor grants gameplay admission.
*/
-public final class AccountGameplayAuthenticateReceiver
- extends AccountServiceGrpc.AccountServiceImplBase {
+public final class AccountGameplayAuthenticateReceiver {
private final AccountGameplayCanonicalLoginOwner owner;
private final AccountGameplayPrimaryCredentialVerifier verifier;
private final String expectedWorkload;
private final AccountInitialGameplayLoginDisposalOwner disposalOwner;
+ private final BooleanSupplier fixtureWebSocketReady;
public AccountGameplayAuthenticateReceiver(
AccountGameplayCanonicalLoginOwner owner,
@@ -51,16 +52,25 @@ public AccountGameplayAuthenticateReceiver(
AccountGameplayPrimaryCredentialVerifier verifier,
String expectedNamespace,
AccountInitialGameplayLoginDisposalOwner disposalOwner) {
+ this(owner, verifier, expectedNamespace, disposalOwner, () -> false);
+ }
+
+ public AccountGameplayAuthenticateReceiver(
+ AccountGameplayCanonicalLoginOwner owner,
+ AccountGameplayPrimaryCredentialVerifier verifier,
+ String expectedNamespace,
+ AccountInitialGameplayLoginDisposalOwner disposalOwner,
+ BooleanSupplier fixtureWebSocketReady) {
if (!GrpcPeerIdentity.isValidNamespace(expectedNamespace)) {
throw new IllegalArgumentException("An exact Account workload namespace is required");
}
this.owner = Objects.requireNonNull(owner, "Canonical LOGIN owner is required");
this.verifier = Objects.requireNonNull(verifier, "Primary credential authority is required");
this.disposalOwner = disposalOwner;
+ this.fixtureWebSocketReady = Objects.requireNonNull(fixtureWebSocketReady);
expectedWorkload = "spiffe://firemud/ns/" + expectedNamespace + "/sa/game-session-service";
}
- @Override
public void retireInitialGameplayLogin(
net.firedevops.firemud.account.v1.RetireInitialGameplayLoginRequest request,
StreamObserver
@@ -186,7 +196,6 @@ public void retireInitialGameplayLogin(
}
}
- @Override
public void authenticate(
AuthenticateRequest request, StreamObserver responseObserver) {
// No request field (especially the credential) is inspected before authenticating the peer.
@@ -211,15 +220,21 @@ public void authenticate(
fail(responseObserver, Status.CANCELLED, "CANCELLED", "Canonical LOGIN call was cancelled");
return;
}
- if (request == null
- || !request.hasSourceContext()
- || request.getSourceContext().getTransportClass()
- != GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY) {
+ var transport =
+ request == null || !request.hasSourceContext()
+ ? GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_UNSPECIFIED
+ : request.getSourceContext().getTransportClass();
+ boolean fixtureWebSocket =
+ transport
+ == GameplayLoginTransportClass
+ .GAMEPLAY_LOGIN_TRANSPORT_CLASS_RUN_OWNED_FIXTURE_WEBSOCKET;
+ if (transport != GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY
+ && !(fixtureWebSocket && fixtureWebSocketReady.getAsBoolean())) {
fail(
responseObserver,
Status.PERMISSION_DENIED,
"PERMISSION_DENIED",
- "Credential LOGIN requires the trusted TCP Proxy source");
+ "Credential LOGIN requires a permitted authenticated transport source");
return;
}
@@ -235,7 +250,7 @@ public void authenticate(
new GameplayCredentialSourceContext(
requireV4(source.getCallerContextId()),
source.getCanonicalClientAddress(),
- "trusted_tcp_proxy");
+ fixtureWebSocket ? "run_owned_fixture_websocket" : "trusted_tcp_proxy");
canonical =
new CanonicalGameplayLoginRequest(
requestId, request.getEmail(), request.getPassword(), context);
diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/PreV1SelfAttestedReadinessDriver.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/PreV1SelfAttestedReadinessDriver.java
new file mode 100644
index 0000000000..13fbd5636e
--- /dev/null
+++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/PreV1SelfAttestedReadinessDriver.java
@@ -0,0 +1,166 @@
+package net.firedevops.firemud.accountservice.service.session;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Clock;
+import java.time.Instant;
+import java.util.Objects;
+import java.util.UUID;
+import net.firedevops.firemud.accountservice.config.AccountJwtReadinessTrustBinding;
+import net.firedevops.firemud.accountservice.config.AccountJwtSignerMaterializerTrustBinding;
+import net.firedevops.firemud.accountservice.repository.AccountJwtReadinessProbeRepository;
+import net.firedevops.firemud.accountservice.repository.AccountJwtReadinessProbeRepository.ProbeEntry;
+import net.firedevops.firemud.accountservice.repository.AccountJwtReadinessProbeRepository.ProbeState;
+import net.firedevops.firemud.accountservice.repository.AccountJwtSignerDesiredStateRepository;
+import net.firedevops.firemud.accountservice.repository.AccountJwtSignerDesiredStateRepository.GenerationPhase;
+import net.firedevops.firemud.accountservice.repository.AccountJwtSignerDesiredStateRepository.TrustFence;
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.support.TransactionTemplate;
+
+/**
+ * Pre-v1 stand-in (ADR 0185) for the missing validator readiness orchestrator.
+ *
+ * Account's signer promotion needs a durable readiness receipt from every expected validator
+ * Pod, but no Pod-bound receiver client or orchestrator exists yet. Under the pre-v1 gate waiver
+ * this driver plans the current generation, issues each probe through the real probe service, and
+ * records a self-attested acceptance for each expected Pod from the protected inventory. Genuine
+ * per-Pod verification is owed before v1 and listed in the player access tracker.
+ */
+@SuppressFBWarnings(
+ value = "EI_EXPOSE_REP2",
+ justification = "Private Account owner collaborators.")
+public final class PreV1SelfAttestedReadinessDriver {
+ private static final Logger LOG = LoggerFactory.getLogger(PreV1SelfAttestedReadinessDriver.class);
+
+ private final PreV1GateWaivers waivers;
+ private final AccountJwtSignerMaterializerTrustBinding materializerTrust;
+ private final AccountJwtReadinessTrustBinding readinessTrust;
+ private final AccountJwtSignerDesiredStateRepository desiredState;
+ private final AccountJwtReadinessProbeRepository readinessRepository;
+ private final AccountJwtReadinessProbeService probes;
+ private final TransactionTemplate transaction;
+ private final Clock clock;
+ // The one-shot claim is durable; reuse it if issuing failed after it was persisted.
+ private AccountJwtReadinessProbeRepository.DeliveryClaim claimed;
+
+ public PreV1SelfAttestedReadinessDriver(
+ PreV1GateWaivers waivers,
+ AccountJwtSignerMaterializerTrustBinding materializerTrust,
+ AccountJwtReadinessTrustBinding readinessTrust,
+ AccountJwtSignerDesiredStateRepository desiredState,
+ AccountJwtReadinessProbeRepository readinessRepository,
+ AccountJwtReadinessProbeService probes,
+ TransactionTemplate transaction,
+ Clock clock) {
+ if (!waivers.enabled()) {
+ throw new IllegalStateException("Self-attested readiness exists only under the waiver");
+ }
+ this.waivers = waivers;
+ this.materializerTrust = Objects.requireNonNull(materializerTrust);
+ this.readinessTrust = Objects.requireNonNull(readinessTrust);
+ this.desiredState = Objects.requireNonNull(desiredState);
+ this.readinessRepository = Objects.requireNonNull(readinessRepository);
+ this.probes = Objects.requireNonNull(probes);
+ this.transaction = Objects.requireNonNull(transaction);
+ this.clock = Objects.requireNonNull(clock);
+ }
+
+ /**
+ * One bounded pass; safe to repeat. Returns true when every planned probe has a receipt. Never
+ * throws, because a scheduled task that throws is silently never run again.
+ */
+ public boolean driveOnce() {
+ if (!waivers.enabled()) {
+ return false;
+ }
+ try {
+ return drive();
+ } catch (AccountJwtSignerDesiredStateRepository.MissingDesiredStateException
+ | AccountJwtSignerDesiredStateRepository.MissingGenerationOperationException idle) {
+ // Not enrolled yet, or no generation is selected (for example after promotion).
+ return false;
+ } catch (RuntimeException notYet) {
+ LOG.info(
+ "Pre-v1 self-attested readiness not complete yet: {}: {}",
+ notYet.getClass().getName(),
+ notYet.getMessage());
+ return false;
+ }
+ }
+
+ private boolean drive() {
+ var materializer = materializerTrust.current().orElse(null);
+ var readiness = readinessTrust.current().orElse(null);
+ if (materializer == null || readiness == null) {
+ return false;
+ }
+ var binding = materializer.accountBinding();
+ TrustFence trust =
+ new TrustFence(
+ materializer.expectedClusterIncarnationUid(),
+ materializer.expectedNamespaceUid(),
+ materializer.bindingDigest(),
+ materializer.configRevision());
+ var request =
+ transaction.execute(status -> desiredState.readCurrentGenerationRequest(binding, trust));
+ if (request == null || request.phase() != GenerationPhase.GENERATION_RECORDED) {
+ return false;
+ }
+ UUID operationId = request.operationId();
+ AccountJwtReadinessProbeRepository.ReadinessProbePlan plan;
+ try {
+ plan = probes.readCurrentPlan(binding, trust, operationId);
+ } catch (RuntimeException absent) {
+ plan = probes.planCurrent(binding, trust);
+ }
+ if (clock.instant().getEpochSecond() < plan.notBeforeEpochSecond()) {
+ return false;
+ }
+ var entries = plan.entries();
+ if (entries.stream().allMatch(entry -> entry.state() == ProbeState.PLANNED)) {
+ var current = plan;
+ if (claimed == null || !claimed.rotationOperationId().equals(operationId)) {
+ claimed =
+ transaction.execute(
+ status ->
+ readinessRepository.claimSingleDelivery(
+ binding,
+ trust,
+ current,
+ readiness,
+ new AccountJwtReadinessTrustBinding.PeerIdentity(
+ readiness.expectedPeerUri(), readiness.peerSpkiSha256Pins().get(0)),
+ Instant.ofEpochSecond(clock.instant().getEpochSecond())));
+ }
+ entries =
+ probes.issueCurrentPlan(binding, trust, operationId, claimed, (metadata, jwt) -> {});
+ }
+ var issued = entries;
+ boolean complete = true;
+ for (ProbeEntry entry : issued) {
+ if (entry.state() != ProbeState.ISSUED) {
+ complete &= entry.verificationReceipt().isPresent();
+ continue;
+ }
+ for (var pod : probes.readCurrentExpectedPods(binding, trust, entry)) {
+ var target = pod.target();
+ var acceptance =
+ AccountJwtReadinessReceiverInvocationPort.authenticatedAcceptance(
+ target.podUid(),
+ target.exactPodEndpoint().orElseThrow().toString(),
+ target.image(),
+ target.verifierConfigSha256(),
+ target.canonicalServiceUri().orElseThrow(),
+ target.podLeafSpkiSha256().orElseThrow(),
+ entry.jti(),
+ entry.compactTokenSha256().orElseThrow(),
+ entry.targetKid(),
+ target.expectation(),
+ clock.instant().getEpochSecond());
+ probes.recordPodAcceptance(binding, trust, entry, pod, acceptance);
+ }
+ }
+ return complete;
+ }
+}
diff --git a/services/account-service/src/main/resources/application.yml b/services/account-service/src/main/resources/application.yml
index c9751cc91f..42ff8731f9 100644
--- a/services/account-service/src/main/resources/application.yml
+++ b/services/account-service/src/main/resources/application.yml
@@ -120,6 +120,12 @@ firemud:
- account.v1.StartSessionOperatorAuthorizationService/RecoverOperatorAuthorizationReference
- account.v1.StartSessionOperatorAuthorizationService/RedeemOperatorAuthorization
- account.v1.StartSessionOperatorAuthorizationService/ReadRedeemedOperationProjection
+ - account.v1.AccountJwtSignerMaterializationService/EnrollBootstrap
+ - account.v1.AccountJwtSignerMaterializationService/GetCurrentGenerationRequest
+ - account.v1.AccountJwtSignerMaterializationService/RecordSecretObservation
+ - account.v1.AccountJwtSignerMaterializationService/RecordGenerationResult
+ - account.v1.AccountJwtSignerMaterializationService/GetCurrentPromotionRequest
+ - account.v1.AccountJwtSignerMaterializationService/RecordPrivatePromotionResult
management:
endpoints:
diff --git a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountRuntimeEntitlementNoWriteIntegrationTest.java b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountRuntimeEntitlementNoWriteIntegrationTest.java
index f5d00ed59b..0db6da68b0 100644
--- a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountRuntimeEntitlementNoWriteIntegrationTest.java
+++ b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountRuntimeEntitlementNoWriteIntegrationTest.java
@@ -103,7 +103,7 @@ class AccountRuntimeEntitlementNoWriteIntegrationTest {
"account_tenant_capacity_recovery_evidence");
private static final GetTenantEntitlementsForRuntimeRequest REQUEST =
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21")
.setRequestId("default-runtime-entitlement-no-write")
.build();
diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/config/AccountGameplayLoginProtectedSourcesConfigurationTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/config/AccountGameplayLoginProtectedSourcesConfigurationTest.java
index 9468d2277e..a98082aca4 100644
--- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/config/AccountGameplayLoginProtectedSourcesConfigurationTest.java
+++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/config/AccountGameplayLoginProtectedSourcesConfigurationTest.java
@@ -23,6 +23,23 @@ class AccountGameplayLoginProtectedSourcesConfigurationTest {
private final AccountGameplayLoginProtectedSourcesConfiguration configuration =
new AccountGameplayLoginProtectedSourcesConfiguration();
+ @Test
+ void plaintextCoordinationIsAcceptedOnlyUnderPreV1Waiver() {
+ String plaintext = "redis://account_coord_app:test-only-password@redis-coord:6379/0";
+ org.assertj.core.api.Assertions.assertThatThrownBy(
+ () ->
+ AccountGameplayLoginProtectedSourcesConfiguration.requiredCoordinationUri(
+ plaintext, 875))
+ .isInstanceOf(IllegalArgumentException.class);
+
+ RedisURI waived =
+ AccountGameplayLoginProtectedSourcesConfiguration.requiredCoordinationUri(
+ plaintext, 875, true);
+
+ assertThat(waived.isSsl()).isFalse();
+ assertThat(waived.getHost()).isEqualTo("redis-coord");
+ }
+
@Test
void dedicatedUriRetainsExplicitTlsAclDatabaseAndCommandDeadline() {
RedisURI uri =
diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/security/RuntimeAccountIdentityGrpcAuthWiringTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/security/RuntimeAccountIdentityGrpcAuthWiringTest.java
index 177df1b335..917d8ecc29 100644
--- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/security/RuntimeAccountIdentityGrpcAuthWiringTest.java
+++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/security/RuntimeAccountIdentityGrpcAuthWiringTest.java
@@ -287,6 +287,23 @@ private static void withConfiguredInterceptor(
READ_REDEEMED_OPERATION_PROJECTION_METHOD)
.doesNotContain("account.v1.StartSessionOperatorAuthorizationService/*")
.doesNotContain(NONPUBLIC_METHOD);
+ // Bearer-free outside prod only: the materializer is gated by its pinned TLS peer
+ // interceptor; the prod bearer gap is flagged for review rather than changed here.
+ String[] materializerMethods = {
+ "account.v1.AccountJwtSignerMaterializationService/EnrollBootstrap",
+ "account.v1.AccountJwtSignerMaterializationService/GetCurrentGenerationRequest",
+ "account.v1.AccountJwtSignerMaterializationService/RecordSecretObservation",
+ "account.v1.AccountJwtSignerMaterializationService/RecordGenerationResult",
+ "account.v1.AccountJwtSignerMaterializationService/GetCurrentPromotionRequest",
+ "account.v1.AccountJwtSignerMaterializationService/RecordPrivatePromotionResult"
+ };
+ if (productionLayer) {
+ assertThat(context.getBean(GrpcAuthProperties.class).getPublicMethods())
+ .doesNotContain(materializerMethods);
+ } else {
+ assertThat(context.getBean(GrpcAuthProperties.class).getPublicMethods())
+ .contains(materializerMethods);
+ }
action.accept(
context.getBean(AuthTokenInterceptor.class), context.getBean(JwtUtil.class));
});
diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java
index 3aae3e801b..b16d289231 100644
--- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java
+++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java
@@ -78,6 +78,9 @@
import org.springframework.transaction.CannotCreateTransactionException;
class AccountGrpcServiceTest {
+ private static final java.util.UUID ENTITLEMENT_TENANT =
+ java.util.UUID.fromString("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21");
+
@Test
void canonicalGameplayEnvelopeNeverFallsBackToLegacyCredentialAuthentication() {
var accounts = Mockito.mock(AccountService.class);
@@ -2608,10 +2611,10 @@ void getRealmAccessGrantForRuntimeFailsUnavailableOnMismatchedAuthorityEvidence(
void getTenantEntitlementsForRuntimeReturnsResponse() {
PingService pingService = Mockito.mock(PingService.class);
AccountService accountService = Mockito.mock(AccountService.class);
- Mockito.when(accountService.getTenantEntitlementsForRuntime(1L, "req-2"))
+ Mockito.when(accountService.getTenantEntitlementsForRuntime(ENTITLEMENT_TENANT, "req-2"))
.thenReturn(
new net.firedevops.firemud.accountservice.dto.RuntimeEntitlementsDto(
- 1L, true, true, 19L, 311L, "2026-03-30T00:00:00Z"));
+ ENTITLEMENT_TENANT, true, true, 19L, 311L, "2026-03-30T00:00:00Z"));
AccountGrpcService service =
new AccountGrpcService(pingService, accountService, null, WORKLOAD_NAMESPACE);
@@ -2621,28 +2624,28 @@ void getTenantEntitlementsForRuntimeReturnsResponse() {
() ->
service.getTenantEntitlementsForRuntime(
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId(ENTITLEMENT_TENANT.toString())
.setRequestId("req-2")
.build(),
observer));
assertNotNull(observer.response());
- assertEquals("1", observer.response().getTenantId());
+ assertEquals(ENTITLEMENT_TENANT.toString(), observer.response().getTenantId());
assertTrue(observer.response().getGameplayAvailable());
assertTrue(observer.response().getAllowPublicJoin());
assertEquals(19L, observer.response().getEntitlementVersion());
assertTrue(observer.completed());
- Mockito.verify(accountService).getTenantEntitlementsForRuntime(1L, "req-2");
+ Mockito.verify(accountService).getTenantEntitlementsForRuntime(ENTITLEMENT_TENANT, "req-2");
}
@Test
void getTenantEntitlementsForRuntimeAllowsWorldManagementPeer() {
PingService pingService = Mockito.mock(PingService.class);
AccountService accountService = Mockito.mock(AccountService.class);
- Mockito.when(accountService.getTenantEntitlementsForRuntime(1L, "req-world"))
+ Mockito.when(accountService.getTenantEntitlementsForRuntime(ENTITLEMENT_TENANT, "req-world"))
.thenReturn(
new net.firedevops.firemud.accountservice.dto.RuntimeEntitlementsDto(
- 1L, true, true, 19L, 311L, "2026-03-30T00:00:00Z"));
+ ENTITLEMENT_TENANT, true, true, 19L, 311L, "2026-03-30T00:00:00Z"));
AccountGrpcService service =
new AccountGrpcService(pingService, accountService, null, WORKLOAD_NAMESPACE);
RecordingObserver observer = new RecordingObserver<>();
@@ -2652,14 +2655,14 @@ void getTenantEntitlementsForRuntimeAllowsWorldManagementPeer() {
() ->
service.getTenantEntitlementsForRuntime(
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId(ENTITLEMENT_TENANT.toString())
.setRequestId("req-world")
.build(),
observer));
- assertEquals("1", observer.response().getTenantId());
+ assertEquals(ENTITLEMENT_TENANT.toString(), observer.response().getTenantId());
assertTrue(observer.completed());
- Mockito.verify(accountService).getTenantEntitlementsForRuntime(1L, "req-world");
+ Mockito.verify(accountService).getTenantEntitlementsForRuntime(ENTITLEMENT_TENANT, "req-world");
}
@Test
@@ -2709,11 +2712,11 @@ void getTenantEntitlementsForRuntimeRejectsMalformedTenantOrRequestBeforeLookup(
.setRequestId("req-1")
.build(),
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId(ENTITLEMENT_TENANT.toString())
.setRequestId(" ")
.build(),
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId(ENTITLEMENT_TENANT.toString())
.setRequestId("x".repeat(129))
.build());
@@ -2729,7 +2732,7 @@ void getTenantEntitlementsForRuntimeRejectsMalformedTenantOrRequestBeforeLookup(
private static GetTenantEntitlementsForRuntimeRequest validEntitlementRequest() {
return GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId(ENTITLEMENT_TENANT.toString())
.setRequestId("req-2")
.build();
}
@@ -2738,7 +2741,8 @@ private static GetTenantEntitlementsForRuntimeRequest validEntitlementRequest()
void getTenantEntitlementsForRuntimeReturnsUnavailableAuthorityError() {
PingService pingService = Mockito.mock(PingService.class);
AccountService accountService = Mockito.mock(AccountService.class);
- Mockito.when(accountService.getTenantEntitlementsForRuntime(1L, "req-ambiguous"))
+ Mockito.when(
+ accountService.getTenantEntitlementsForRuntime(ENTITLEMENT_TENANT, "req-ambiguous"))
.thenThrow(
new AuthenticationException(
"ENTITLEMENT_UNAVAILABLE",
@@ -2752,7 +2756,7 @@ void getTenantEntitlementsForRuntimeReturnsUnavailableAuthorityError() {
() ->
service.getTenantEntitlementsForRuntime(
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("1")
+ .setTenantId(ENTITLEMENT_TENANT.toString())
.setRequestId("req-ambiguous")
.build(),
new StreamObserver() {
@@ -2774,7 +2778,7 @@ public void onCompleted() {}
}
@Test
- void getTenantEntitlementsForRuntimeRejectsZeroTenantIdBeforeLookup() {
+ void getTenantEntitlementsForRuntimeRejectsNonUuidTenantIdBeforeLookup() {
PingService pingService = Mockito.mock(PingService.class);
AccountService accountService = Mockito.mock(AccountService.class);
AccountGrpcService service =
@@ -2804,7 +2808,7 @@ public void onCompleted() {}
assertNotNull(ref.get());
assertEquals("INVALID_ARGUMENT", ref.get().getError().getCode());
- assertEquals("tenantId must be positive", ref.get().getError().getMessage());
+ Mockito.verifyNoInteractions(accountService);
Mockito.verifyNoInteractions(accountService);
}
diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountServiceImplTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountServiceImplTest.java
index ee0851233d..1f83e596ae 100644
--- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountServiceImplTest.java
+++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountServiceImplTest.java
@@ -3589,12 +3589,47 @@ void getTenantMembershipForRuntimeRejectsMissingAccount() {
() -> service.getTenantMembershipForRuntime(11L, 7L, "req-1"));
}
+ @Test
+ void runtimeEntitlementGrantsSourcelessSeededTenantOnlyUnderPreV1Waiver() {
+ var tenant = java.util.UUID.fromString("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21");
+ var sources =
+ org.mockito.Mockito.mock(
+ net.firedevops.firemud.accountservice.repository.AccountTenantAuthorityEventRepository
+ .class);
+ var demos =
+ org.mockito.Mockito.mock(
+ net.firedevops.firemud.accountservice.repository.AccountDemoTenantEntitlementRepository
+ .class);
+ when(sources.hasCurrentSource(tenant)).thenReturn(false);
+ service.setRuntimeEntitlementSources(
+ sources, demos, net.firedevops.firemud.common.prev1.PreV1GateWaivers.enabledForTest());
+
+ var granted = service.getTenantEntitlementsForRuntime(tenant, "req-seeded");
+
+ assertEquals(tenant, granted.tenantId());
+ assertTrue(granted.gameplayAvailable());
+ verifyNoInteractions(demos);
+
+ when(sources.readCurrentSourceSelection(tenant))
+ .thenThrow(new IllegalStateException("Current tenant source is absent"));
+ service.setRuntimeEntitlementSources(
+ sources, demos, net.firedevops.firemud.common.prev1.PreV1GateWaivers.disabled());
+ AuthenticationException denied =
+ assertThrows(
+ AuthenticationException.class,
+ () -> service.getTenantEntitlementsForRuntime(tenant, "req-unwaived"));
+ assertEquals("ENTITLEMENT_UNAVAILABLE", denied.getCode());
+ }
+
@Test
void getTenantEntitlementsForRuntimeFailsClosedBeforeReadingLegacyEvidence() {
AuthenticationException exception =
assertThrows(
AuthenticationException.class,
- () -> service.getTenantEntitlementsForRuntime(7L, "req-current-entitlement"));
+ () ->
+ service.getTenantEntitlementsForRuntime(
+ java.util.UUID.fromString("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21"),
+ "req-current-entitlement"));
assertEquals("ENTITLEMENT_UNAVAILABLE", exception.getCode());
verifyNoInteractions(retainedSubscriptionEvidenceRepository);
diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/LegacySubscriptionContainmentTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/LegacySubscriptionContainmentTest.java
index 51af089c77..2fe8d19951 100644
--- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/LegacySubscriptionContainmentTest.java
+++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/LegacySubscriptionContainmentTest.java
@@ -73,7 +73,10 @@ void retainedStatusAndCountersCannotProduceAPositiveServiceOrRuntimeRpc(String s
AuthenticationException denied =
assertThrows(
AuthenticationException.class,
- () -> service.getTenantEntitlementsForRuntime(7L, "retained-is-not-authority"));
+ () ->
+ service.getTenantEntitlementsForRuntime(
+ java.util.UUID.fromString("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21"),
+ "retained-is-not-authority"));
assertThat(denied.getCode()).isEqualTo("ENTITLEMENT_UNAVAILABLE");
AccountGrpcService rpc = new AccountGrpcService(null, service, null, "test");
@@ -104,7 +107,7 @@ public void onCompleted() {}
() ->
rpc.getTenantEntitlementsForRuntime(
GetTenantEntitlementsForRuntimeRequest.newBuilder()
- .setTenantId("7")
+ .setTenantId("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21")
.setRequestId("retained-is-not-authority")
.build(),
observer));
diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiverTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiverTest.java
index 77943bc790..570689d5bc 100644
--- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiverTest.java
+++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/session/AccountGameplayAuthenticateReceiverTest.java
@@ -83,8 +83,8 @@ void wrongCertificateDerivedPeerDeniesBeforeRequestInspection(String peer) {
}
@ParameterizedTest
- @ValueSource(ints = {0, 2, 77})
- void bootstrapUnknownAndUnspecifiedModeDenyBeforeCredentialAccess(int mode) {
+ @ValueSource(ints = {0, 2, 3, 77})
+ void unavailableOrUnsupportedTransportDeniesBeforeCredentialAccess(int mode) {
var request = mock(AuthenticateRequest.class);
when(request.hasSourceContext()).thenReturn(true);
when(request.getSourceContext()).thenReturn(source().setTransportClassValue(mode).build());
diff --git a/services/account-service/src/testFixtures/java/net/firedevops/firemud/accountservice/service/session/AccountPlayerAdmissionSharedOwnerFixture.java b/services/account-service/src/testFixtures/java/net/firedevops/firemud/accountservice/service/session/AccountPlayerAdmissionSharedOwnerFixture.java
index ad28fb69a8..fe88911972 100644
--- a/services/account-service/src/testFixtures/java/net/firedevops/firemud/accountservice/service/session/AccountPlayerAdmissionSharedOwnerFixture.java
+++ b/services/account-service/src/testFixtures/java/net/firedevops/firemud/accountservice/service/session/AccountPlayerAdmissionSharedOwnerFixture.java
@@ -299,6 +299,29 @@ public AccountGameplayAuthenticateReceiver authenticateReceiver(String namespace
return new AccountGameplayAuthenticateReceiver(login, verifier, namespace, disposal);
}
+ /** Binds the receiver as the Authenticate/Retire surface of AccountService for test servers. */
+ public io.grpc.BindableService authenticateService(String namespace) {
+ var receiver = authenticateReceiver(namespace);
+ return new net.firedevops.firemud.account.v1.AccountServiceGrpc.AccountServiceImplBase() {
+ @Override
+ public void authenticate(
+ AuthenticateRequest request,
+ io.grpc.stub.StreamObserver
+ responseObserver) {
+ receiver.authenticate(request, responseObserver);
+ }
+
+ @Override
+ public void retireInitialGameplayLogin(
+ net.firedevops.firemud.account.v1.RetireInitialGameplayLoginRequest request,
+ io.grpc.stub.StreamObserver<
+ net.firedevops.firemud.account.v1.RetireInitialGameplayLoginResponse>
+ responseObserver) {
+ receiver.retireInitialGameplayLogin(request, responseObserver);
+ }
+ };
+ }
+
/** Actual receipt-backed public source, not a replacement JWKS document. */
public AccountJwtJwksTrustedSource trustedJwksSource() {
return publicSource;
diff --git a/services/common-platform-core/src/main/java/net/firedevops/firemud/common/config/CommonCoreAutoConfiguration.java b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/config/CommonCoreAutoConfiguration.java
index 2937167555..1d7209d326 100644
--- a/services/common-platform-core/src/main/java/net/firedevops/firemud/common/config/CommonCoreAutoConfiguration.java
+++ b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/config/CommonCoreAutoConfiguration.java
@@ -13,6 +13,7 @@
import net.firedevops.firemud.common.health.HttpEndpointAvailabilityChecker;
import net.firedevops.firemud.common.health.ReadinessTransitionTracker;
import net.firedevops.firemud.common.health.TlsCertificateReadinessHealthEndpointGroupsPostProcessor;
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
import net.firedevops.firemud.common.runtime.RuntimeIdentity;
import net.firedevops.firemud.common.runtime.RuntimeIdentityController;
import net.firedevops.firemud.common.runtime.RuntimeIdentityFactory;
@@ -53,6 +54,12 @@
@Import({TracingConfig.class, CommonGrpcServerConfiguration.class, GrpcServerTlsReloader.class})
public class CommonCoreAutoConfiguration {
+ @Bean
+ @ConditionalOnMissingBean(PreV1GateWaivers.class)
+ public PreV1GateWaivers preV1GateWaivers(Environment environment) {
+ return PreV1GateWaivers.from(environment);
+ }
+
@Bean
@ConditionalOnMissingBean(MeterRegistry.class)
@ConditionalOnClass(name = "io.micrometer.core.instrument.simple.SimpleMeterRegistry")
diff --git a/services/common-platform-core/src/main/java/net/firedevops/firemud/common/prev1/PreV1GateWaivers.java b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/prev1/PreV1GateWaivers.java
new file mode 100644
index 0000000000..9702683700
--- /dev/null
+++ b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/prev1/PreV1GateWaivers.java
@@ -0,0 +1,43 @@
+package net.firedevops.firemud.common.prev1;
+
+import java.util.Arrays;
+import org.springframework.core.env.Environment;
+
+/**
+ * Single switch for gates waived before v1 under ADR 0185. Every waived gate reads this switch, and
+ * the waived gates are listed in the player access and session tracker's "Pre-v1 gate waivers"
+ * section. A service refuses to start with the switch on under the {@code prod} profile.
+ */
+public final class PreV1GateWaivers {
+ public static final String PROPERTY = "firemud.pre-v1.gate-waivers.enabled";
+ private static final PreV1GateWaivers DISABLED = new PreV1GateWaivers(false);
+
+ private final boolean enabled;
+
+ private PreV1GateWaivers(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /** Reads the switch and refuses it under the production profile. */
+ public static PreV1GateWaivers from(Environment environment) {
+ boolean enabled = environment.getProperty(PROPERTY, Boolean.class, false);
+ if (enabled
+ && Arrays.stream(environment.getActiveProfiles()).anyMatch("prod"::equalsIgnoreCase)) {
+ throw new IllegalStateException(
+ PROPERTY + " must not be enabled under the prod profile; clear the pre-v1 gate waivers");
+ }
+ return enabled ? new PreV1GateWaivers(true) : DISABLED;
+ }
+
+ public static PreV1GateWaivers disabled() {
+ return DISABLED;
+ }
+
+ public static PreV1GateWaivers enabledForTest() {
+ return new PreV1GateWaivers(true);
+ }
+
+ public boolean enabled() {
+ return enabled;
+ }
+}
diff --git a/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldCanonicalInstanceLifecycleGrpcCodec.java b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldCanonicalInstanceLifecycleGrpcCodec.java
index 9caf305d68..34c7b90ffd 100644
--- a/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldCanonicalInstanceLifecycleGrpcCodec.java
+++ b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldCanonicalInstanceLifecycleGrpcCodec.java
@@ -61,6 +61,39 @@ public static WorldCanonicalInstanceLifecycleEvidence fromResponse(
return evidence;
}
+ /** Encodes the run-owned fixture variant for the exact caller request. */
+ public static ReadWorldCanonicalInstanceLifecycleResponse toFixtureResponse(
+ Request request, WorldRunOwnedFixtureLifecycleEvidence evidence) {
+ Objects.requireNonNull(request, "request");
+ Objects.requireNonNull(evidence, "evidence");
+ if (!request.equals(evidence.request())) {
+ throw new IllegalArgumentException(
+ "World fixture lifecycle evidence differs from exact read request");
+ }
+ return ReadWorldCanonicalInstanceLifecycleResponse.newBuilder()
+ .setCanonicalResponseBytes(ByteString.copyFrom(evidence.canonicalBytes()))
+ .build();
+ }
+
+ /** Validates the closed run-owned fixture response and its exact request echo. */
+ public static WorldRunOwnedFixtureLifecycleEvidence fromFixtureResponse(
+ Request request, ReadWorldCanonicalInstanceLifecycleResponse response) {
+ Objects.requireNonNull(request, "request");
+ Objects.requireNonNull(response, "response");
+ requireNoUnknownFields(response, "ReadWorldCanonicalInstanceLifecycleResponse");
+ if (response.getCanonicalResponseBytes().isEmpty()) {
+ throw new IllegalArgumentException("World fixture lifecycle response bytes are required");
+ }
+ WorldRunOwnedFixtureLifecycleEvidence evidence =
+ WorldRunOwnedFixtureLifecycleEvidence.fromStored(
+ response.getCanonicalResponseBytes().toByteArray());
+ if (!request.equals(evidence.request())) {
+ throw new IllegalArgumentException(
+ "World fixture lifecycle response changed exact read request");
+ }
+ return evidence;
+ }
+
private static void requireNoUnknownFields(Message message, String label) {
if (!message.getUnknownFields().asMap().isEmpty()) {
throw new IllegalArgumentException(label + " contains unsupported fields");
diff --git a/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldRunOwnedFixtureLifecycleEvidence.java b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldRunOwnedFixtureLifecycleEvidence.java
new file mode 100644
index 0000000000..bb33135ef1
--- /dev/null
+++ b/services/common-platform-core/src/main/java/net/firedevops/firemud/common/world/WorldRunOwnedFixtureLifecycleEvidence.java
@@ -0,0 +1,166 @@
+package net.firedevops.firemud.common.world;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.regex.Pattern;
+import net.firedevops.firemud.common.json.Rfc8785CanonicalJson;
+import tools.jackson.core.StreamReadFeature;
+import tools.jackson.databind.DeserializationFeature;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.json.JsonMapper;
+
+/**
+ * Closed World lifecycle observation for a canonical run-owned fixture instance.
+ *
+ * The fixture has no Human capture, graph, start-location or release attestation. It is
+ * identified by the same canonical lifecycle read request, carrying the fixture descriptor digests
+ * and, in place of the release-attestation digest, the fixture policy-seal evidence digest. This is
+ * one owner snapshot, not admission authority.
+ */
+public record WorldRunOwnedFixtureLifecycleEvidence(
+ WorldCanonicalInstanceLifecycleEvidence.Request request,
+ String fixtureProvenanceDigest,
+ String preparationInputDigest,
+ String lifecycleStatus,
+ long lifecycleEpoch,
+ long rowVersion) {
+ public static final String SCHEMA = "world-run-owned-fixture-lifecycle-evidence/v1";
+ private static final int MAX_CANONICAL_BYTES = 64 * 1024;
+ private static final Pattern PREFIXED_SHA256 = Pattern.compile("sha256:[0-9a-f]{64}");
+ private static final Set LIFECYCLE_STATUSES =
+ Set.of("PREPARING", "ACTIVE", "FAILED_PRE_ACTIVATION", "TERMINATING", "TERMINATED");
+ private static final Set FIELDS =
+ Set.of(
+ "schema",
+ "requestBytesBase64",
+ "fixtureProvenanceDigest",
+ "preparationInputDigest",
+ "lifecycleStatus",
+ "lifecycleEpoch",
+ "rowVersion");
+ private static final JsonMapper JSON =
+ JsonMapper.builder()
+ .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
+ .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
+ .enable(StreamReadFeature.STRICT_DUPLICATE_DETECTION)
+ .build();
+
+ public WorldRunOwnedFixtureLifecycleEvidence {
+ Objects.requireNonNull(request, "request");
+ requireDigest(fixtureProvenanceDigest, "fixtureProvenanceDigest");
+ requireDigest(preparationInputDigest, "preparationInputDigest");
+ if (!fixtureProvenanceDigest.equals(request.expectedReleaseAttestationDigest())) {
+ throw new IllegalArgumentException(
+ "Fixture lifecycle request must carry the fixture provenance digest");
+ }
+ if (lifecycleStatus == null || !LIFECYCLE_STATUSES.contains(lifecycleStatus)) {
+ throw new IllegalArgumentException("Unsupported World lifecycle status");
+ }
+ if (lifecycleEpoch <= 0 || rowVersion < 0) {
+ throw new IllegalArgumentException("World fixture lifecycle epoch or row version is invalid");
+ }
+ }
+
+ public byte[] canonicalBytes() {
+ Map value = new LinkedHashMap<>();
+ value.put("schema", SCHEMA);
+ value.put("requestBytesBase64", Base64.getEncoder().encodeToString(request.canonicalBytes()));
+ value.put("fixtureProvenanceDigest", fixtureProvenanceDigest);
+ value.put("preparationInputDigest", preparationInputDigest);
+ value.put("lifecycleStatus", lifecycleStatus);
+ value.put("lifecycleEpoch", Long.toString(lifecycleEpoch));
+ value.put("rowVersion", Long.toString(rowVersion));
+ try {
+ return Rfc8785CanonicalJson.canonicalizeUtf8(JSON.writeValueAsString(value));
+ } catch (IOException impossible) {
+ throw new IllegalStateException(
+ "World fixture lifecycle evidence cannot be encoded", impossible);
+ }
+ }
+
+ /** Decodes only complete, canonical, bounded evidence; this does not authenticate its sender. */
+ public static WorldRunOwnedFixtureLifecycleEvidence fromStored(byte[] stored) {
+ Objects.requireNonNull(stored, "stored");
+ if (stored.length == 0 || stored.length > MAX_CANONICAL_BYTES) {
+ throw new IllegalArgumentException("World fixture lifecycle evidence exceeds its limit");
+ }
+ try {
+ JsonNode root = JSON.readTree(strictUtf8(stored));
+ if (root == null || !root.isObject()) {
+ throw new IllegalArgumentException("World fixture lifecycle evidence must be an object");
+ }
+ Set actual = new HashSet<>();
+ root.propertyNames().forEach(actual::add);
+ if (!actual.equals(FIELDS) || !SCHEMA.equals(text(root, "schema"))) {
+ throw new IllegalArgumentException(
+ "World fixture lifecycle evidence has an unsupported shape");
+ }
+ String encoded = text(root, "requestBytesBase64");
+ byte[] requestBytes = Base64.getDecoder().decode(encoded);
+ if (!Base64.getEncoder().encodeToString(requestBytes).equals(encoded)) {
+ throw new IllegalArgumentException("requestBytesBase64 must use canonical base64");
+ }
+ WorldRunOwnedFixtureLifecycleEvidence evidence =
+ new WorldRunOwnedFixtureLifecycleEvidence(
+ WorldCanonicalInstanceLifecycleEvidence.Request.fromStored(requestBytes),
+ text(root, "fixtureProvenanceDigest"),
+ text(root, "preparationInputDigest"),
+ text(root, "lifecycleStatus"),
+ parseLong(text(root, "lifecycleEpoch")),
+ parseLong(text(root, "rowVersion")));
+ if (!Arrays.equals(stored, evidence.canonicalBytes())) {
+ throw new IllegalArgumentException("World fixture lifecycle evidence is not canonical");
+ }
+ return evidence;
+ } catch (tools.jackson.core.JacksonException invalid) {
+ throw new IllegalArgumentException("World fixture lifecycle evidence is invalid", invalid);
+ }
+ }
+
+ private static long parseLong(String value) {
+ try {
+ long parsed = Long.parseLong(value);
+ if (!Long.toString(parsed).equals(value)) throw new NumberFormatException(value);
+ return parsed;
+ } catch (NumberFormatException invalid) {
+ throw new IllegalArgumentException("World fixture lifecycle number is invalid", invalid);
+ }
+ }
+
+ private static void requireDigest(String value, String label) {
+ if (value == null || !PREFIXED_SHA256.matcher(value).matches()) {
+ throw new IllegalArgumentException(label + " must be a prefixed SHA-256 digest");
+ }
+ }
+
+ private static String text(JsonNode object, String field) {
+ JsonNode value = object.get(field);
+ if (value == null || !value.isTextual()) {
+ throw new IllegalArgumentException(field + " must be text");
+ }
+ return value.textValue();
+ }
+
+ private static String strictUtf8(byte[] bytes) {
+ try {
+ return StandardCharsets.UTF_8
+ .newDecoder()
+ .onMalformedInput(CodingErrorAction.REPORT)
+ .onUnmappableCharacter(CodingErrorAction.REPORT)
+ .decode(ByteBuffer.wrap(bytes))
+ .toString();
+ } catch (java.nio.charset.CharacterCodingException invalid) {
+ throw new IllegalArgumentException(
+ "World fixture lifecycle evidence is not strict UTF-8", invalid);
+ }
+ }
+}
diff --git a/services/common-platform-core/src/test/java/unit/net/firedevops/firemud/common/prev1/PreV1GateWaiversTest.java b/services/common-platform-core/src/test/java/unit/net/firedevops/firemud/common/prev1/PreV1GateWaiversTest.java
new file mode 100644
index 0000000000..d22cab26f6
--- /dev/null
+++ b/services/common-platform-core/src/test/java/unit/net/firedevops/firemud/common/prev1/PreV1GateWaiversTest.java
@@ -0,0 +1,38 @@
+package unit.net.firedevops.firemud.common.prev1;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
+import org.junit.jupiter.api.Test;
+import org.springframework.mock.env.MockEnvironment;
+
+class PreV1GateWaiversTest {
+ @Test
+ void disabledByDefault() {
+ assertThat(PreV1GateWaivers.from(new MockEnvironment()).enabled()).isFalse();
+ }
+
+ @Test
+ void enabledOutsideProd() {
+ var env = new MockEnvironment().withProperty(PreV1GateWaivers.PROPERTY, "true");
+ env.setActiveProfiles("dev");
+ assertThat(PreV1GateWaivers.from(env).enabled()).isTrue();
+ }
+
+ @Test
+ void refusesUnderProdProfile() {
+ var env = new MockEnvironment().withProperty(PreV1GateWaivers.PROPERTY, "true");
+ env.setActiveProfiles("prod");
+ assertThatThrownBy(() -> PreV1GateWaivers.from(env))
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("prod");
+ }
+
+ @Test
+ void prodWithoutWaiversStarts() {
+ var env = new MockEnvironment();
+ env.setActiveProfiles("prod");
+ assertThat(PreV1GateWaivers.from(env).enabled()).isFalse();
+ }
+}
diff --git a/services/common-security/src/main/java/net/firedevops/firemud/common/security/GrpcWorkloadOnlyGuard.java b/services/common-security/src/main/java/net/firedevops/firemud/common/security/GrpcWorkloadOnlyGuard.java
new file mode 100644
index 0000000000..160c464d08
--- /dev/null
+++ b/services/common-security/src/main/java/net/firedevops/firemud/common/security/GrpcWorkloadOnlyGuard.java
@@ -0,0 +1,24 @@
+package net.firedevops.firemud.common.security;
+
+import io.grpc.Status;
+import java.util.Optional;
+import net.firedevops.firemud.common.grpc.GrpcPeerIdentity;
+
+/** Authorizes a certificate-bound workload caller without ambient account or service claims. */
+public final class GrpcWorkloadOnlyGuard {
+ private GrpcWorkloadOnlyGuard() {}
+
+ public static Optional refusal(
+ GrpcPeerIdentity peer, String expectedService, String expectedNamespace) {
+ if (peer == null) {
+ return Optional.of(Status.UNAUTHENTICATED);
+ }
+ if (!peer.isService(expectedService)
+ || !peer.isInNamespace(expectedNamespace)
+ || SessionContext.hasAuthenticatedCallerContext()
+ || SessionContext.isInternalService()) {
+ return Optional.of(Status.PERMISSION_DENIED);
+ }
+ return Optional.empty();
+ }
+}
diff --git a/services/game-design-service/src/main/java/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcService.java b/services/game-design-service/src/main/java/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcService.java
index 952e81d7de..f5b53374de 100644
--- a/services/game-design-service/src/main/java/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcService.java
+++ b/services/game-design-service/src/main/java/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcService.java
@@ -154,6 +154,14 @@ public class GameDesignGrpcService extends GameDesignServiceGrpc.GameDesignServi
justification = "MeterRegistry is injected and not exposed")
private final MeterRegistry meterRegistry;
+ private net.firedevops.firemud.gamedesign.repository.GameRepository gameRepository;
+
+ @org.springframework.beans.factory.annotation.Autowired(required = false)
+ public void setGameRepository(
+ net.firedevops.firemud.gamedesign.repository.GameRepository repository) {
+ this.gameRepository = repository;
+ }
+
@Override
@Timed(value = "gamedesignGrpc.ping")
public void ping(PingRequest request, StreamObserver responseObserver) {
@@ -829,6 +837,49 @@ public void getVersionState(
responseObserver.onCompleted();
}
+ @Override
+ @Timed(value = "gamedesignGrpc.resolveCanonicalTenant")
+ public void resolveCanonicalTenant(
+ net.firedevops.firemud.gamedesign.v1.ResolveCanonicalTenantRequest request,
+ StreamObserver
+ responseObserver) {
+ var builder = net.firedevops.firemud.gamedesign.v1.ResolveCanonicalTenantResponse.newBuilder();
+ try {
+ requireCanonicalTenantReadAccess();
+ if (gameRepository == null) {
+ throw new IllegalStateException("Game Design tenant identity is unavailable");
+ }
+ var identity =
+ gameRepository
+ .findRuntimeTenantIdentityByTenantKey(request.getTenantId())
+ .orElseThrow(() -> new IllegalArgumentException("Unknown Game Design tenant"));
+ if (identity.canonicalTenantId() == null) {
+ throw new IllegalArgumentException("Game Design tenant has no canonical identity");
+ }
+ builder.setCanonicalTenantId(identity.canonicalTenantId().toString());
+ } catch (AdminAuthorizationException ex) {
+ builder.setError(
+ GrpcAppErrors.error(
+ meterRegistry,
+ logger,
+ "ResolveCanonicalTenant",
+ "PERMISSION_DENIED",
+ ex.getMessage()));
+ } catch (IllegalArgumentException ex) {
+ builder.setError(
+ GrpcAppErrors.error(
+ meterRegistry,
+ logger,
+ "ResolveCanonicalTenant",
+ "INVALID_ARGUMENT",
+ ex.getMessage()));
+ } catch (Exception ex) {
+ builder.setError(GrpcAppErrors.internal(meterRegistry, logger, "ResolveCanonicalTenant", ex));
+ }
+ responseObserver.onNext(builder.build());
+ responseObserver.onCompleted();
+ }
+
@Override
@Timed(value = "gamedesignGrpc.compareAndSetVersionState")
public void compareAndSetVersionState(
@@ -2328,6 +2379,18 @@ private void requirePublishedReleaseBundleReadAccess() {
Set.of("game-session-service", "world-management-service", "automation-scripting-service"));
}
+ /** Exact same-namespace Game Session workload; tenant identity grants no launch authority. */
+ private void requireCanonicalTenantReadAccess() {
+ GrpcPeerIdentity peer = GrpcPeerIdentity.current();
+ if (!GrpcPeerIdentity.isValidNamespace(workloadNamespace)
+ || peer == null
+ || !workloadNamespace.equals(peer.namespace())
+ || !peer.isService("game-session-service")) {
+ throw new AdminAuthorizationException(
+ "Exact same-namespace Game Session workload identity is required");
+ }
+ }
+
private void requireCandidatePeerThenDeny(Set candidateServices) {
GrpcPeerIdentity peer = GrpcPeerIdentity.current();
if (!GrpcPeerIdentity.isValidNamespace(workloadNamespace)
diff --git a/services/game-design-service/src/test/java/unit/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcServiceAuthTest.java b/services/game-design-service/src/test/java/unit/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcServiceAuthTest.java
index 31a422d571..7be58a8223 100644
--- a/services/game-design-service/src/test/java/unit/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcServiceAuthTest.java
+++ b/services/game-design-service/src/test/java/unit/net/firedevops/firemud/gamedesign/service/impl/GameDesignGrpcServiceAuthTest.java
@@ -127,6 +127,53 @@ public void onCompleted() {}
assertEquals("Admin role required", ref.get().getError().getMessage());
}
+ @Test
+ void canonicalTenantReadServesOnlySameNamespaceGameSession() {
+ var tenant = java.util.UUID.fromString("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21");
+ var games = Mockito.mock(net.firedevops.firemud.gamedesign.repository.GameRepository.class);
+ Mockito.when(games.findRuntimeTenantIdentityByTenantKey("1"))
+ .thenReturn(
+ Optional.of(
+ new net.firedevops.firemud.gamedesign.repository.GameTenantIdentity(
+ tenant,
+ net.firedevops.firemud.gamedesign.repository.GameTenantIdentity.ProvenanceKind
+ .NEW_GAME_ROW,
+ 1L,
+ null)));
+ GameDesignGrpcService service =
+ newService(
+ Mockito.mock(VersionService.class), Mockito.mock(VersionAssetArtifactService.class));
+ ReflectionTestUtils.setField(service, "workloadNamespace", WORKLOAD_NAMESPACE);
+ service.setGameRepository(games);
+ var request =
+ net.firedevops.firemud.gamedesign.v1.ResolveCanonicalTenantRequest.newBuilder()
+ .setTenantId("1")
+ .build();
+
+ AtomicReference served =
+ new AtomicReference<>();
+ Context.current()
+ .withValue(
+ GrpcPeerIdentity.CONTEXT_KEY,
+ GrpcPeerIdentity.parseUri(
+ "spiffe://firemud/ns/" + WORKLOAD_NAMESPACE + "/sa/game-session-service")
+ .orElseThrow())
+ .run(() -> service.resolveCanonicalTenant(request, responseObserver(served)));
+ assertEquals(tenant.toString(), served.get().getCanonicalTenantId());
+
+ this.assertDeniedMatrix(
+ observer -> service.resolveCanonicalTenant(request, observer),
+ response -> response.getError().getCode(),
+ "world-management-service",
+ "account-service");
+ this.assertDenied(
+ observer -> service.resolveCanonicalTenant(request, observer),
+ response -> response.getError().getCode(),
+ "game-session-service",
+ "other-namespace",
+ Identity.PEER);
+ }
+
@Test
void publishedReleaseBundleReadDeniesEveryIdentityBeforeOwnerServiceAccess() {
VersionService versionService = Mockito.mock(VersionService.class);
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/GameDesignClient.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/GameDesignClient.java
index b51ca577e4..cb9d7a6c31 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/GameDesignClient.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/GameDesignClient.java
@@ -154,6 +154,25 @@ public GetPublishedPluginVersionResponse getPublishedPluginVersion(
}
}
+ /** Canonical tenant UUID for a Game Design tenant key, or empty when Game Design has none. */
+ public java.util.Optional resolveCanonicalTenantId(long tenantId) {
+ var response =
+ callStub()
+ .resolveCanonicalTenant(
+ net.firedevops.firemud.gamedesign.v1.ResolveCanonicalTenantRequest.newBuilder()
+ .setTenantId(Long.toString(tenantId))
+ .build());
+ if (response.hasError() || response.getCanonicalTenantId().isEmpty()) {
+ return java.util.Optional.empty();
+ }
+ var parsed = java.util.UUID.fromString(response.getCanonicalTenantId());
+ if (!parsed.toString().equals(response.getCanonicalTenantId())
+ || parsed.equals(new java.util.UUID(0L, 0L))) {
+ return java.util.Optional.empty();
+ }
+ return java.util.Optional.of(parsed);
+ }
+
public GetVersionStateResponse getVersionState(long tenantId, long versionId) {
return callStub()
.getVersionState(
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/ObservedDirectTextTransport.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/ObservedDirectTextTransport.java
index 4e3b4466b0..3cc4a02626 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/ObservedDirectTextTransport.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/ObservedDirectTextTransport.java
@@ -5,9 +5,9 @@
import net.firedevops.firemud.gamesession.service.SessionIdParsing;
/**
- * Preserves the proxy connection identifier observed at transport intake for direct-text
- * correlation only. This metadata is not authenticated ingress, caller identity, or LOGIN/JOIN
- * authority, and it must never be reconstructed from a numeric transport session ID.
+ * Preserves original direct-text connection correlation. The ID is received from TCP Proxy or
+ * minted once at the authenticated run-owned WebSocket listener. Correlation alone supplies no
+ * LOGIN/JOIN authority and must never be reconstructed from a numeric transport session ID.
*/
public record ObservedDirectTextTransport(String transportSessionId, UUID proxyConnectionId) {
private static final String TRUSTED_TCP_PROXY_MODE = "trusted_tcp_proxy";
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java
index 9bc88481bc..f15b746802 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java
@@ -76,6 +76,7 @@ public class PlayCommandHandler {
private final MeterRegistry meterRegistry;
private final Counter takeoverCounter;
private final Counter resumeCounter;
+ private volatile net.firedevops.firemud.gamesession.client.GameDesignClient gameDesignClient;
public PlayCommandHandler(
SessionAuthenticationService sessionAuthenticationService,
@@ -627,6 +628,25 @@ private static GameplayCommand scriptEventCommand(SessionContext context, TextCo
null);
}
+ /** Game Design owns tenant identity; PLAY reads Account entitlement by canonical tenant UUID. */
+ @org.springframework.beans.factory.annotation.Autowired(required = false)
+ public void setGameDesignClient(
+ net.firedevops.firemud.gamesession.client.GameDesignClient gameDesignClient) {
+ this.gameDesignClient = gameDesignClient;
+ }
+
+ private Optional resolveCanonicalTenantId(long tenantId) {
+ var client = gameDesignClient;
+ if (client == null) {
+ return Optional.empty();
+ }
+ try {
+ return client.resolveCanonicalTenantId(tenantId);
+ } catch (RuntimeException unavailable) {
+ return Optional.empty();
+ }
+ }
+
private Optional validateRuntimeAdmission(
SessionContext context,
GameplayWorldCatalog.WorldView selectedWorld,
@@ -634,9 +654,15 @@ private Optional validateRuntimeAdmission(
String tenantTag,
long requestedCharacterId) {
String requestId = context.sessionId() + ":" + UUID.randomUUID();
+ Optional canonicalTenantId = resolveCanonicalTenantId(selectedRealm.tenantId());
+ if (canonicalTenantId.isEmpty()) {
+ return Optional.of(
+ entitlementUnavailableFailure(
+ tenantTag, Long.toString(selectedRealm.gameInstanceId()), requestedCharacterId));
+ }
GetTenantEntitlementsForRuntimeResponse entitlementResponse =
accountClient.getTenantEntitlementsForRuntime(
- Long.toString(selectedRealm.tenantId()), requestId);
+ canonicalTenantId.orElseThrow().toString(), requestId);
Optional entitlementFailure =
validateEntitlementsResponse(
entitlementResponse,
@@ -644,6 +670,7 @@ private Optional validateRuntimeAdmission(
tenantTag,
selectedWorld,
selectedRealm,
+ canonicalTenantId.orElseThrow(),
requestedCharacterId);
if (entitlementFailure.isPresent()) {
return entitlementFailure;
@@ -928,6 +955,7 @@ private Optional validateEntitlementsResponse(
String tenantTag,
GameplayWorldCatalog.WorldView selectedWorld,
GameplayWorldCatalog.RealmView selectedRealm,
+ UUID canonicalTenantId,
long requestedCharacterId) {
if (response == null) {
return Optional.of(
@@ -947,7 +975,7 @@ private Optional validateEntitlementsResponse(
context, tenantTag, selectedWorld, selectedRealm, requestedCharacterId));
}
try {
- if (!Long.toString(selectedRealm.tenantId()).equals(response.getTenantId())
+ if (!canonicalTenantId.toString().equals(response.getTenantId())
|| response.getEntitlementVersion() <= 0L
|| response.getTenantBillingSequence() <= 0L
|| !isWithinEntitlementReplyWindow(
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/InitialGameplayLoginProtectedSourcesConfiguration.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/InitialGameplayLoginProtectedSourcesConfiguration.java
index 123648aa36..15327449f1 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/InitialGameplayLoginProtectedSourcesConfiguration.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/InitialGameplayLoginProtectedSourcesConfiguration.java
@@ -6,11 +6,16 @@
import java.net.URI;
import java.time.Duration;
import java.util.Arrays;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicLong;
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
+import net.firedevops.firemud.gamesession.service.InitialGameplayLoginCoordinationQualification;
import net.firedevops.firemud.gamesession.service.InitialGameplayLoginRedisBinding;
import net.firedevops.firemud.gamesession.service.InitialGameplayLoginRedisBinding.AcknowledgementPolicy;
import net.firedevops.firemud.gamesession.service.InitialGameplayLoginRedisBinding.Profile;
import net.firedevops.firemud.gamesession.service.LettuceInitialGameplayLoginConnectionProvider;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -31,10 +36,12 @@ LettuceInitialGameplayLoginConnectionProvider initialGameplayLoginCoordinationCo
String configuredUri,
@Value(
"${firemud.game-session.initial-gameplay-login.protected-sources.coordination.command-timeout-millis:0}")
- int commandTimeoutMillis) {
+ int commandTimeoutMillis,
+ org.springframework.beans.factory.ObjectProvider waivers) {
+ boolean waived = waivers.getIfAvailable(PreV1GateWaivers::disabled).enabled();
try {
return new LettuceInitialGameplayLoginConnectionProvider(
- requiredCoordinationUri(configuredUri, commandTimeoutMillis));
+ requiredCoordinationUri(configuredUri, commandTimeoutMillis, waived));
} catch (RuntimeException failure) {
throw unavailable();
}
@@ -73,6 +80,15 @@ InitialGameplayLoginRedisBinding initialGameplayLoginRedisBinding(
}
static RedisURI requiredCoordinationUri(String configuredUri, int timeoutMillis) {
+ return requiredCoordinationUri(configuredUri, timeoutMillis, false);
+ }
+
+ /**
+ * Requires TLS ({@code rediss}). Under the pre-v1 gate waiver (ADR 0185) Compose smoke may use
+ * plaintext {@code redis} with the same ACL principal; TLS is owed before v1.
+ */
+ static RedisURI requiredCoordinationUri(
+ String configuredUri, int timeoutMillis, boolean preV1Plaintext) {
char[] password = null;
try {
if (configuredUri == null
@@ -84,7 +100,8 @@ static RedisURI requiredCoordinationUri(String configuredUri, int timeoutMillis)
URI uri = URI.create(configuredUri);
String userInfo = uri.getUserInfo();
String principal = InitialGameplayLoginRedisBinding.PRINCIPAL;
- if (!"rediss".equals(uri.getScheme())
+ boolean tls = "rediss".equals(uri.getScheme());
+ if (!(tls || preV1Plaintext && "redis".equals(uri.getScheme()))
|| uri.getHost() == null
|| uri.getHost().isBlank()
|| uri.getPort() < 1
@@ -101,8 +118,8 @@ static RedisURI requiredCoordinationUri(String configuredUri, int timeoutMillis)
password = userInfo.substring(principal.length() + 1).toCharArray();
var credentials = RedisCredentials.just(principal, password);
return RedisURI.Builder.redis(uri.getHost(), uri.getPort())
- .withSsl(true)
- .withVerifyPeer(true)
+ .withSsl(tls)
+ .withVerifyPeer(tls)
.withAuthentication(RedisCredentialsProvider.from(() -> credentials))
.withDatabase(0)
.withTimeout(Duration.ofMillis(timeoutMillis))
@@ -115,6 +132,49 @@ static RedisURI requiredCoordinationUri(String configuredUri, int timeoutMillis)
}
}
+ /**
+ * The external qualification authority has no provider yet. Under the pre-v1 gate waiver (ADR
+ * 0185) a process-local lease stands in so Compose smoke can run LOGIN; the real reset, restore
+ * and promotion exclusion is owed before v1. Without the waiver no lease is supplied.
+ */
+ @Bean
+ @ConditionalOnMissingBean(InitialGameplayLoginCoordinationQualification.class)
+ @ConditionalOnProperty(name = PreV1GateWaivers.PROPERTY, havingValue = "true")
+ InitialGameplayLoginCoordinationQualification preV1InitialGameplayLoginQualification(
+ PreV1GateWaivers waivers) {
+ if (!waivers.enabled()) {
+ throw new IllegalStateException(
+ "Initial LOGIN Coordination qualification authority is required");
+ }
+ AtomicLong fences = new AtomicLong(System.currentTimeMillis());
+ return (scope, bindingId) -> {
+ long fence = fences.incrementAndGet();
+ return Optional.of(
+ new InitialGameplayLoginCoordinationQualification.Lease() {
+ @Override
+ public String scope() {
+ return scope;
+ }
+
+ @Override
+ public String protectedBindingId() {
+ return bindingId;
+ }
+
+ @Override
+ public long fence() {
+ return fence;
+ }
+
+ @Override
+ public void requireCurrent() {}
+
+ @Override
+ public void close() {}
+ });
+ };
+ }
+
private static IllegalArgumentException unavailable() {
return new IllegalArgumentException("Protected Game Session initial LOGIN sources required");
}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalGameplayLoginResult.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalGameplayLoginResult.java
index 94b61a6315..9d904bc22f 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalGameplayLoginResult.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalGameplayLoginResult.java
@@ -171,10 +171,12 @@ public static void requireOriginalRequest(AuthenticateRequest request) {
if (request == null
|| !request.getUnknownFields().asMap().isEmpty()
|| !request.hasSourceContext()
- || !request.getSourceContext().getUnknownFields().asMap().isEmpty()
- || request.getSourceContext().getTransportClass()
- != GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY)
- throw invalid();
+ || !request.getSourceContext().getUnknownFields().asMap().isEmpty()) throw invalid();
+ var transport = request.getSourceContext().getTransportClass();
+ if (transport != GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY
+ && transport
+ != GameplayLoginTransportClass
+ .GAMEPLAY_LOGIN_TRANSPORT_CLASS_RUN_OWNED_FIXTURE_WEBSOCKET) throw invalid();
v4(request.getRequestId());
v4(request.getSourceContext().getCallerContextId());
String address = request.getSourceContext().getCanonicalClientAddress();
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalPlayableTarget.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalPlayableTarget.java
index 38a3259ec3..026960144a 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalPlayableTarget.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalPlayableTarget.java
@@ -5,6 +5,7 @@
import java.util.Objects;
import java.util.UUID;
import java.util.regex.Pattern;
+import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec;
import net.firedevops.firemud.common.grpc.GrpcPeerIdentity;
import net.firedevops.firemud.gamesession.dto.CanonicalInitialAdmissionOwnerProof.Outcome;
import net.firedevops.firemud.gamesession.dto.CanonicalInitialAdmissionRequest.OriginKind;
@@ -48,6 +49,44 @@ public record CanonicalPlayableTarget(
Instant ownerProofTerminalAt,
String characterCreationPolicy)
implements Serializable {
+ public CanonicalGameplayAdmissionDecisionReadGrpcCodec.Target admissionDecisionTarget() {
+ return new CanonicalGameplayAdmissionDecisionReadGrpcCodec.Target(
+ targetNamespace(),
+ tenantSlug(),
+ canonicalTenantId(),
+ worldSlug(),
+ worldDisplayName(),
+ realmId(),
+ realmSlug(),
+ realmDisplayName(),
+ gameSessionTenantId(),
+ gameInstanceId(),
+ playableStateNamespaceId(),
+ playableStateScope(),
+ canonicalGameInstanceId(),
+ canonicalVersionId(),
+ runtimeVersionId(),
+ catalogRevision(),
+ pointerVersion(),
+ admissionPointerSnapshotDigest(),
+ activeWorldEpoch(),
+ initialAdmissionRequestId(),
+ initialAdmissionRequestDigest(),
+ CanonicalGameplayAdmissionDecisionReadGrpcCodec.OriginKind.valueOf(
+ initialAdmissionOriginKind().name()),
+ expectedPriorPointerVersion(),
+ holdId(),
+ holdFence(),
+ holdBindingDigest(),
+ auditEventId(),
+ ownerProofDigest(),
+ CanonicalGameplayAdmissionDecisionReadGrpcCodec.OwnerProofOutcome.valueOf(
+ ownerProofOutcome().name()),
+ positiveDurableAbort(),
+ ownerProofTerminalAt(),
+ characterCreationPolicy());
+ }
+
private static final long serialVersionUID = 1L;
private static final UUID NIL_UUID = new UUID(0L, 0L);
private static final Pattern REQUEST_DIGEST = Pattern.compile("[0-9a-f]{64}");
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/AccountPublicJwksReadClient.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/AccountPublicJwksReadClient.java
index 2205e31b20..9cdfe9e9ee 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/AccountPublicJwksReadClient.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/AccountPublicJwksReadClient.java
@@ -30,7 +30,12 @@
/** Same-namespace mTLS current-public-state read, with no bearer or readiness-plan dependency. */
public final class AccountPublicJwksReadClient {
private static final int ACCOUNT_PORT = 6565;
+ private static final org.slf4j.Logger LOG =
+ org.slf4j.LoggerFactory.getLogger(AccountPublicJwksReadClient.class);
private static final long DEADLINE_SECONDS = 3L;
+ // Connection setup (DNS, TCP, mTLS handshake) in a cold JVM is bounded separately, so the RPC
+ // deadline measures only the read itself.
+ private static final long CONNECT_SECONDS = 15L;
private final ServiceEndpointsProperties endpoints;
private final CommonGrpcClientProperties tls;
private final GrpcChannelFactory channels;
@@ -62,6 +67,7 @@ public ReadResult readCurrent() {
ManagedChannel channel = null;
try {
channel = channels.buildChannel(endpoints.getAccountService(), ACCOUNT_PORT, tls, false);
+ awaitConnected(channel);
var authenticated =
ClientInterceptors.intercept(
channel,
@@ -76,6 +82,7 @@ public ReadResult readCurrent() {
return AccountPublicJwksReadCodec.result(response);
} catch (StatusRuntimeException failure) {
Status.Code code = failure.getStatus().getCode();
+ LOG.warn("Account public JWKS read failed with status {}", code);
if (!hasTlsFailure(failure)
&& (code == Status.Code.UNAVAILABLE || code == Status.Code.DEADLINE_EXCEEDED)) {
throw new SourceUnavailableException();
@@ -95,6 +102,31 @@ public ReadResult readCurrent() {
}
}
+ /**
+ * Waits while the channel is still connecting. A transient connection failure (including a TLS
+ * failure) proceeds to the RPC, so its status keeps the existing outage/invalid classification.
+ */
+ private static void awaitConnected(ManagedChannel channel) {
+ long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(CONNECT_SECONDS);
+ io.grpc.ConnectivityState state = channel.getState(true);
+ while (state == io.grpc.ConnectivityState.IDLE
+ || state == io.grpc.ConnectivityState.CONNECTING) {
+ long remaining = deadline - System.nanoTime();
+ if (remaining <= 0) {
+ throw new SourceUnavailableException();
+ }
+ var changed = new java.util.concurrent.CountDownLatch(1);
+ channel.notifyWhenStateChanged(state, changed::countDown);
+ try {
+ changed.await(remaining, TimeUnit.NANOSECONDS);
+ } catch (InterruptedException interrupted) {
+ Thread.currentThread().interrupt();
+ throw new SourceUnavailableException();
+ }
+ state = channel.getState(false);
+ }
+ }
+
/** The shared content fence permits unverified non-OK trailers; do not call those outages. */
private final class EstablishedPeerFailureFence implements ClientInterceptor {
@Override
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/InitialGameplayLoginCredentialPresentation.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/InitialGameplayLoginCredentialPresentation.java
index 1af8214274..7d658c53a8 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/InitialGameplayLoginCredentialPresentation.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/InitialGameplayLoginCredentialPresentation.java
@@ -16,28 +16,42 @@
public final class InitialGameplayLoginCredentialPresentation implements AutoCloseable {
private final String normalizedEmail;
private final String canonicalClientAddress;
+ private final GameplayLoginTransportClass transport;
private final char[] ownedSecret;
private final Object custodyMutex = new Object();
private boolean current = true;
private boolean requestCreated;
/** A receiving transport can present credentials only with its genuine authenticated ingress. */
- public static InitialGameplayLoginCredentialPresentation fromAuthenticatedTcp(
+ public static InitialGameplayLoginCredentialPresentation fromAuthenticatedIngress(
net.firedevops.firemud.gamesession.websocket.AuthenticatedDirectTextIngress ingress,
String normalizedEmail,
char[] ownedSecret) {
- Objects.requireNonNull(ingress, "Authenticated TCP ingress required");
+ Objects.requireNonNull(ingress, "Authenticated gameplay ingress required");
return new InitialGameplayLoginCredentialPresentation(
- normalizedEmail, ingress.clientAddress(), ownedSecret);
+ normalizedEmail, ingress.clientAddress(), ownedSecret, ingress.loginTransport());
}
/** Ownership of {@code ownedSecret} transfers to this presentation. */
InitialGameplayLoginCredentialPresentation(
String normalizedEmail, String canonicalClientAddress, char[] ownedSecret) {
+ this(
+ normalizedEmail,
+ canonicalClientAddress,
+ ownedSecret,
+ GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY);
+ }
+
+ private InitialGameplayLoginCredentialPresentation(
+ String normalizedEmail,
+ String canonicalClientAddress,
+ char[] ownedSecret,
+ GameplayLoginTransportClass transport) {
this.ownedSecret = Objects.requireNonNull(ownedSecret, "Owned credential buffer required");
try {
this.normalizedEmail = requireEmail(normalizedEmail);
this.canonicalClientAddress = requireAddress(canonicalClientAddress);
+ this.transport = Objects.requireNonNull(transport);
if (ownedSecret.length == 0 || ownedSecret.length > 1024) {
throw new IllegalArgumentException("Credential presentation is invalid");
}
@@ -66,9 +80,7 @@ AuthenticateRequest createOriginalRequest(InitialGameplayLoginAttemptCoordinates
GameplayLoginSourceContext.newBuilder()
.setCallerContextId(coordinates.callerContextId().toString())
.setCanonicalClientAddress(canonicalClientAddress)
- .setTransportClass(
- GameplayLoginTransportClass
- .GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY))
+ .setTransportClass(transport))
.build();
CanonicalGameplayLoginResult.requireOriginalRequest(request);
return request;
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/CanonicalGameplayAdmissionDecisionReadGrpcService.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/CanonicalGameplayAdmissionDecisionReadGrpcService.java
index 5a9188b515..3c796c4de2 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/CanonicalGameplayAdmissionDecisionReadGrpcService.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/CanonicalGameplayAdmissionDecisionReadGrpcService.java
@@ -701,42 +701,8 @@ private static Target toTarget(CanonicalGameplayAdmissionDecision decision) {
return toTarget(decision.targetEvidence());
}
- private static Target toTarget(
- net.firedevops.firemud.gamesession.dto.CanonicalPlayableTarget target) {
- return new Target(
- target.targetNamespace(),
- target.tenantSlug(),
- target.canonicalTenantId(),
- target.worldSlug(),
- target.worldDisplayName(),
- target.realmId(),
- target.realmSlug(),
- target.realmDisplayName(),
- target.gameSessionTenantId(),
- target.gameInstanceId(),
- target.playableStateNamespaceId(),
- target.playableStateScope(),
- target.canonicalGameInstanceId(),
- target.canonicalVersionId(),
- target.runtimeVersionId(),
- target.catalogRevision(),
- target.pointerVersion(),
- target.admissionPointerSnapshotDigest(),
- target.activeWorldEpoch(),
- target.initialAdmissionRequestId(),
- target.initialAdmissionRequestDigest(),
- CanonicalGameplayAdmissionDecisionReadGrpcCodec.OriginKind.valueOf(
- target.initialAdmissionOriginKind().name()),
- target.expectedPriorPointerVersion(),
- target.holdId(),
- target.holdFence(),
- target.holdBindingDigest(),
- target.auditEventId(),
- target.ownerProofDigest(),
- OwnerProofOutcome.valueOf(target.ownerProofOutcome().name()),
- target.positiveDurableAbort(),
- target.ownerProofTerminalAt(),
- target.characterCreationPolicy());
+ private static Target toTarget(CanonicalPlayableTarget target) {
+ return target.admissionDecisionTarget();
}
private static boolean hasConnectionFailureSqlState(Throwable failure) {
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextIngress.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextIngress.java
index 4b7929663a..c2f8e990b5 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextIngress.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextIngress.java
@@ -1,7 +1,12 @@
package net.firedevops.firemud.gamesession.websocket;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
+import java.util.HexFormat;
import java.util.UUID;
+import net.firedevops.firemud.account.v1.GameplayLoginTransportClass;
import net.firedevops.firemud.common.grpc.GrpcPeerIdentity;
import net.firedevops.firemud.gamesession.command.text.ObservedDirectTextTransport;
import org.springframework.http.server.ServerHttpRequest;
@@ -10,34 +15,27 @@
/** Immutable transport proof minted only from the dedicated connector's authenticated TLS peer. */
public final class AuthenticatedDirectTextIngress {
static final String ATTRIBUTE = AuthenticatedDirectTextIngress.class.getName();
+ static final String TCP_PATH = "/ws/game/tcp";
+ static final String FIXTURE_WEBSOCKET_PATH = "/ws/game/run-owned-fixture";
private final ObservedDirectTextTransport transport;
private final String clientAddress;
+ private final GameplayLoginTransportClass loginTransport;
private final UUID backendGeneration = UUID.randomUUID();
- private AuthenticatedDirectTextIngress(ObservedDirectTextTransport transport, String address) {
+ private AuthenticatedDirectTextIngress(
+ ObservedDirectTextTransport transport, String address, GameplayLoginTransportClass mode) {
this.transport = transport;
this.clientAddress = address;
+ this.loginTransport = mode;
}
static AuthenticatedDirectTextIngress authenticate(
ServerHttpRequest request, int dedicatedPort, String namespace, String sessionId) {
- if (!(request instanceof ServletServerHttpRequest servlet)
- || !servlet.getServletRequest().isSecure()
- || servlet.getServletRequest().getLocalPort() != dedicatedPort
- || !"/ws/game/tcp".equals(request.getURI().getPath())
- || !GrpcPeerIdentity.isValidNamespace(namespace)) throw unavailable();
- Object value =
- servlet.getServletRequest().getAttribute("jakarta.servlet.request.X509Certificate");
- if (!(value instanceof X509Certificate[] chain) || chain.length == 0) throw unavailable();
- try {
- chain[0].checkValidity();
- if (chain[0].getExtendedKeyUsage() == null
- || !chain[0].getExtendedKeyUsage().contains("1.3.6.1.5.5.7.3.2")
- || GrpcPeerIdentity.fromCertificate(chain[0])
- .filter(
- peer -> peer.isService("spring-cloud-gateway") && peer.isInNamespace(namespace))
- .isEmpty()) throw unavailable();
- } catch (java.security.cert.CertificateException invalid) {
+ if (!TCP_PATH.equals(request.getURI().getPath())
+ || !GrpcPeerIdentity.isValidNamespace(namespace)
+ || GrpcPeerIdentity.fromCertificate(requireClientCertificate(request, dedicatedPort))
+ .filter(peer -> peer.isService("spring-cloud-gateway") && peer.isInNamespace(namespace))
+ .isEmpty()) {
throw unavailable();
}
var headers = request.getHeaders();
@@ -54,7 +52,53 @@ static AuthenticatedDirectTextIngress authenticate(
var observed =
ObservedDirectTextTransport.fromHandshake(mode, sessionId, proxyConnectionId)
.orElseThrow(AuthenticatedDirectTextIngress::unavailable);
- return new AuthenticatedDirectTextIngress(observed, canonicalAddress);
+ return new AuthenticatedDirectTextIngress(
+ observed,
+ canonicalAddress,
+ GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_TRUSTED_TCP_PROXY);
+ }
+
+ static AuthenticatedDirectTextIngress authenticateFixtureWebSocket(
+ ServletServerHttpRequest request,
+ int dedicatedPort,
+ String certificateSha256,
+ String sessionId,
+ UUID connectionId) {
+ if (!FIXTURE_WEBSOCKET_PATH.equals(request.getURI().getPath())) throw unavailable();
+ var certificate = requireClientCertificate(request, dedicatedPort);
+ try {
+ byte[] actualDigest = MessageDigest.getInstance("SHA-256").digest(certificate.getEncoded());
+ if (!MessageDigest.isEqual(actualDigest, HexFormat.of().parseHex(certificateSha256))) {
+ throw unavailable();
+ }
+ } catch (CertificateException | NoSuchAlgorithmException invalid) {
+ throw unavailable();
+ }
+ String address =
+ java.net.InetAddress.ofLiteral(request.getServletRequest().getRemoteAddr())
+ .getHostAddress();
+ return new AuthenticatedDirectTextIngress(
+ new ObservedDirectTextTransport(sessionId, connectionId),
+ address,
+ GameplayLoginTransportClass.GAMEPLAY_LOGIN_TRANSPORT_CLASS_RUN_OWNED_FIXTURE_WEBSOCKET);
+ }
+
+ private static X509Certificate requireClientCertificate(
+ ServerHttpRequest request, int dedicatedPort) {
+ if (!(request instanceof ServletServerHttpRequest servlet)
+ || !servlet.getServletRequest().isSecure()
+ || servlet.getServletRequest().getLocalPort() != dedicatedPort) throw unavailable();
+ Object value =
+ servlet.getServletRequest().getAttribute("jakarta.servlet.request.X509Certificate");
+ if (!(value instanceof X509Certificate[] chain) || chain.length == 0) throw unavailable();
+ try {
+ chain[0].checkValidity();
+ if (chain[0].getExtendedKeyUsage() == null
+ || !chain[0].getExtendedKeyUsage().contains("1.3.6.1.5.5.7.3.2")) throw unavailable();
+ return chain[0];
+ } catch (CertificateException invalid) {
+ throw unavailable();
+ }
}
private static String singleHeader(org.springframework.http.HttpHeaders headers, String name) {
@@ -73,11 +117,15 @@ public String clientAddress() {
return clientAddress;
}
+ public GameplayLoginTransportClass loginTransport() {
+ return loginTransport;
+ }
+
public UUID backendGeneration() {
return backendGeneration;
}
private static IllegalArgumentException unavailable() {
- return new IllegalArgumentException("Authenticated Gateway TCP provenance required");
+ return new IllegalArgumentException("Authenticated gameplay transport provenance required");
}
}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextSessions.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextSessions.java
index ea5812f051..6af0a2ca65 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextSessions.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedDirectTextSessions.java
@@ -130,7 +130,7 @@ public void login(InitialGameplayLoginOwner owner, String email, char[] ownedSec
menu = null;
selectedScope = null;
credentials =
- InitialGameplayLoginCredentialPresentation.fromAuthenticatedTcp(
+ InitialGameplayLoginCredentialPresentation.fromAuthenticatedIngress(
ingress, email, ownedSecret);
requireLive();
InitialGameplayLoginOwner.Outcome received =
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedGameplayListenerConfiguration.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedGameplayListenerConfiguration.java
index 79d832fb04..65977e6d83 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedGameplayListenerConfiguration.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/AuthenticatedGameplayListenerConfiguration.java
@@ -21,7 +21,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.OncePerRequestFilter;
-/** Dedicated internal mTLS connector; the ordinary HTTP connector cannot produce TCP custody. */
+/** Dedicated mTLS connector for authenticated gameplay custody. */
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(
prefix = "firemud.gameplay.authenticated-listener",
@@ -36,7 +36,10 @@ Filter authenticatedGameplayPathFilter(
protected void doFilterInternal(
HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
- if (request.getLocalPort() == port && !"/ws/game/tcp".equals(request.getRequestURI())) {
+ if (request.getLocalPort() == port
+ && !AuthenticatedDirectTextIngress.TCP_PATH.equals(request.getRequestURI())
+ && !AuthenticatedDirectTextIngress.FIXTURE_WEBSOCKET_PATH.equals(
+ request.getRequestURI())) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandshakeInterceptor.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandshakeInterceptor.java
index 6e6ba724cf..c29b086ef0 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandshakeInterceptor.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandshakeInterceptor.java
@@ -6,11 +6,17 @@
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
import java.util.Map;
+import java.util.UUID;
+import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
+import net.firedevops.firemud.gamesession.data.RunOwnedCanonicalLaunchPreparationOwner;
+import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.socket.WebSocketHandler;
@@ -22,19 +28,45 @@ public class GameSessionWebSocketHandshakeInterceptor implements HandshakeInterc
private final boolean authenticatedListenerEnabled;
private final int authenticatedPort;
private final String namespace;
+ private final String fixtureWebSocketCertificateSha256;
+ private final Runnable verifyFixture;
public GameSessionWebSocketHandshakeInterceptor() {
this(false, 8444, "");
}
+ public GameSessionWebSocketHandshakeInterceptor(boolean enabled, int port, String namespace) {
+ this(enabled, port, namespace, "", () -> {});
+ }
+
@Autowired
- public GameSessionWebSocketHandshakeInterceptor(
+ GameSessionWebSocketHandshakeInterceptor(
@Value("${firemud.gameplay.authenticated-listener.enabled:false}") boolean enabled,
@Value("${firemud.gameplay.authenticated-listener.port:8444}") int port,
- @Value("${firemud.grpc.workload-namespace:}") String namespace) {
+ @Value("${firemud.grpc.workload-namespace:}") String namespace,
+ @Value("${FIREMUD_SMOKE_FIXTURE_WEBSOCKET_CERTIFICATE_SHA256:}")
+ String fixtureCertificateSha256,
+ Environment environment,
+ ObjectProvider fixture) {
+ this(
+ enabled,
+ port,
+ namespace,
+ PreV1GateWaivers.from(environment).enabled() ? fixtureCertificateSha256 : "",
+ () -> fixture.getObject().loadFixedVerifiedEvidence().requireVerifiedFixture());
+ }
+
+ GameSessionWebSocketHandshakeInterceptor(
+ boolean enabled,
+ int port,
+ String namespace,
+ String fixtureCertificateSha256,
+ Runnable verifyFixture) {
authenticatedListenerEnabled = enabled;
authenticatedPort = port;
this.namespace = namespace;
+ this.fixtureWebSocketCertificateSha256 = fixtureCertificateSha256;
+ this.verifyFixture = verifyFixture;
}
static final String GAME_INSTANCE_HEADER = "X-Game-Instance-Id";
@@ -68,6 +100,11 @@ public boolean beforeHandshake(
ServerHttpResponse response,
WebSocketHandler wsHandler,
Map attributes) {
+ attributes.remove(AuthenticatedDirectTextIngress.ATTRIBUTE);
+ attributes.remove(OBSERVED_DIRECT_TEXT_TRANSPORT_ATTR);
+ if (AuthenticatedDirectTextIngress.FIXTURE_WEBSOCKET_PATH.equals(request.getURI().getPath())) {
+ return authenticateFixtureWebSocket(request, response, attributes);
+ }
String bootstrapGameInstanceId = request.getHeaders().getFirst(GAME_INSTANCE_HEADER);
String sessionId =
deriveTransportSessionId(
@@ -76,10 +113,8 @@ public boolean beforeHandshake(
bootstrapGameInstanceId,
request.getHeaders().getFirst(CONNECT_CONTEXT_HEADER));
attributes.put(SESSION_ID_ATTR, sessionId);
- attributes.remove(AuthenticatedDirectTextIngress.ATTRIBUTE);
- attributes.remove(OBSERVED_DIRECT_TEXT_TRANSPORT_ATTR);
boolean tcp = "trusted_tcp_proxy".equals(request.getHeaders().getFirst(CONNECTION_MODE_HEADER));
- if (tcp || "/ws/game/tcp".equals(request.getURI().getPath())) {
+ if (tcp || AuthenticatedDirectTextIngress.TCP_PATH.equals(request.getURI().getPath())) {
try {
if (!authenticatedListenerEnabled)
throw new IllegalArgumentException("Listener unavailable");
@@ -122,6 +157,34 @@ public boolean beforeHandshake(
return true;
}
+ private boolean authenticateFixtureWebSocket(
+ ServerHttpRequest request, ServerHttpResponse response, Map attributes) {
+ try {
+ if (!authenticatedListenerEnabled
+ || !fixtureWebSocketCertificateSha256.matches("[0-9a-f]{64}")
+ || !(request instanceof ServletServerHttpRequest servlet)) {
+ throw new IllegalArgumentException("Fixture WebSocket unavailable");
+ }
+ UUID connectionId = UUID.randomUUID();
+ String sessionId = Long.toString(stablePositiveLong(connectionId.toString()));
+ var ingress =
+ AuthenticatedDirectTextIngress.authenticateFixtureWebSocket(
+ servlet,
+ authenticatedPort,
+ fixtureWebSocketCertificateSha256,
+ sessionId,
+ connectionId);
+ verifyFixture.run();
+ attributes.put(SESSION_ID_ATTR, sessionId);
+ attributes.put(AuthenticatedDirectTextIngress.ATTRIBUTE, ingress);
+ attributes.put(OBSERVED_DIRECT_TEXT_TRANSPORT_ATTR, ingress.transport());
+ return true;
+ } catch (RuntimeException failure) {
+ response.setStatusCode(HttpStatus.FORBIDDEN);
+ return false;
+ }
+ }
+
@Override
public void afterHandshake(
ServerHttpRequest request,
diff --git a/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerPartitionBuildRepositoryIntegrationTest.java b/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerPartitionBuildRepositoryIntegrationTest.java
index 5a8ee84c4d..f5b0de92c7 100644
--- a/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerPartitionBuildRepositoryIntegrationTest.java
+++ b/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerPartitionBuildRepositoryIntegrationTest.java
@@ -2391,7 +2391,9 @@ private static String retainedPreBridgeRegionImage(DSLContext dsl) {
Long unexpectedMaterializedFields =
dsl.fetchSingle(
"SELECT count(*) FROM game_session_canonical_binding_region_bridge_obligation g"
- + " WHERE jsonb_strip_nulls(to_jsonb(g) - "
+ + " WHERE jsonb_strip_nulls((CASE"
+ + " WHEN to_jsonb(g)->>'world_source_kind' = 'HUMAN_CAPTURE'"
+ + " THEN to_jsonb(g) - 'world_source_kind' ELSE to_jsonb(g) END) - "
+ originalFields
+ ") <> '{}'::jsonb")
.get(0, Long.class);
diff --git a/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayOriginalNewFinalAdmissionTestFixture.java b/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayOriginalNewFinalAdmissionTestFixture.java
index 5d143c4189..3826e8cd0a 100644
--- a/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayOriginalNewFinalAdmissionTestFixture.java
+++ b/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayOriginalNewFinalAdmissionTestFixture.java
@@ -267,6 +267,44 @@ private static byte[] unsigned(byte[] value) {
/** Real authenticated client decoding over controlled World/Entity response DTOs and test PKI. */
static final class ControlledRegionSources implements AutoCloseable {
+
+ private static final java.util.Map<
+ java.util.List