From a2bd22d5f887b409a35b9d72d63c35bace40fb09 Mon Sep 17 00:00:00 2001 From: Sam Fakhreddine Date: Wed, 26 Aug 2026 20:06:16 -0600 Subject: [PATCH] feat(ssoadmin): serve Identity Center ListInstances (#2581) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(sso): serve Identity Center ListInstances under SWBExternalService LZA's Custom::GetIdentityCenterInstanceMetadata Lambda calls SSO Admin ListInstances (target prefix SWBExternalService., the service's AWS-internal codename, cf. config's StarlingDoveService) and requires exactly one instance with InstanceArn and IdentityStoreId. Previously no descriptor matched the target, so the call died with UnknownOperationException. Identifiers are fixed constants so they survive restarts — LZA persists them into SSM parameters between stages. * fix(config): declare ssoadmin enabled toggle in both application.yml files Upstream's ServiceConfigYamlCoverageTest requires every service config with an enabled() toggle to declare it explicitly in both files; this branch predates that test and fails it without the declaration. * docs(ssoadmin): defer the single-op handler from action-table generation * docs(ssoadmin): alias the sso descriptor to the IAM page * fix(ssoadmin): report the caller's account as OwnerAccountId and assert the unsupported-operation error type * fix(ssoadmin): use UnknownOperationException for unrecognized actions Matches this codebase's JSON 1.1 dispatch convention (ServiceQuotas, Network Firewall, and others already use it) and is a real modelled shape unlike the bare UnsupportedOperation string, which has no Exception suffix and isn't in sso-admin's error model. * docs: correct service count to 79 after the #2579 merge The upstream/main merge (8a4d9bd1b) added two new services (servicequotas, ram) on top of this branch's own sso-admin addition. The merge-base count was 76; three disjoint new services (1 ours + 2 upstream) makes 79, not 78 as the merge commit left it. --- README.md | 2 +- docs/index.md | 4 +- docs/services/index.md | 2 +- .../floci/config/EmulatorConfig.java | 6 ++ .../core/common/AwsJson11Controller.java | 5 + .../core/common/ResolvedServiceCatalog.java | 7 ++ .../ssoadmin/SsoAdminJsonHandler.java | 41 ++++++++ .../services/ssoadmin/SsoAdminService.java | 27 ++++++ src/main/resources/application.yml | 2 + .../ssoadmin/SsoAdminIntegrationTest.java | 94 +++++++++++++++++++ src/test/resources/application.yml | 2 + tools/docs/service_matrix.yaml | 1 + tools/docs/services.yaml | 1 + 13 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminJsonHandler.java create mode 100644 src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java create mode 100644 src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminIntegrationTest.java diff --git a/README.md b/README.md index bc6fe97e92..8ce3295706 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ LocalStack's community edition [sunset in March 2026](https://blog.localstack.cl | CodeBuild | Real Docker execution | No | | Native binary | ~40 MB | No | -**78 AWS services. Broad coverage. Free forever.** +**79 AWS services. Broad coverage. Free forever.** ## Architecture Overview diff --git a/docs/index.md b/docs/index.md index 9af7ce3b23..60e31744b3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,7 +12,7 @@ Floci is a fast, free, and open-source local AWS service emulator built for deve ## Supported Services -Floci emulates 78 AWS services. See the [Services Overview](services/index.md) for per-service operation counts, endpoints, and full protocol details. +Floci emulates 79 AWS services. See the [Services Overview](services/index.md) for per-service operation counts, endpoints, and full protocol details. | Service | Protocol | |---|---| @@ -117,7 +117,7 @@ docker compose up -d aws --endpoint-url http://localhost:4566 s3 mb s3://my-bucket ``` -All 78 AWS services are immediately available at `http://localhost:4566`. +All 79 AWS services are immediately available at `http://localhost:4566`. [Get started →](getting-started/quick-start.md){ .md-button .md-button--primary } [View services →](services/index.md){ .md-button } diff --git a/docs/services/index.md b/docs/services/index.md index 469f6b30a5..602b3f5fa4 100644 --- a/docs/services/index.md +++ b/docs/services/index.md @@ -1,6 +1,6 @@ # Services Overview -Floci emulates 78 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification. +Floci emulates 79 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification. This page is the canonical reference for supported service and operation counts. Some services expose separate control-plane and data-plane rows below. Other docs (and the README) should link here rather than duplicating the table. diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java index b278677272..fa1a35a935 100644 --- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java +++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java @@ -672,6 +672,7 @@ public interface EmulatorConfig { RumServiceConfig rum(); GuardDutyServiceConfig guardduty(); EmrServerlessServiceConfig emrserverless(); + SsoAdminServiceConfig ssoadmin(); ServiceQuotasServiceConfig servicequotas(); RamServiceConfig ram(); ControlTowerServiceConfig controltower(); @@ -679,6 +680,11 @@ public interface EmulatorConfig { EfsServiceConfig efs(); } + interface SsoAdminServiceConfig { + @WithDefault("true") + boolean enabled(); + } + interface IotServiceConfig { @WithDefault("true") boolean enabled(); diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java index 5a75eed20f..d5876f4c14 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java @@ -23,6 +23,7 @@ import io.github.hectorvent.floci.services.ce.CostExplorerJsonHandler; import io.github.hectorvent.floci.services.cloudtrail.CloudTrailJsonHandler; import io.github.hectorvent.floci.services.applicationautoscaling.ApplicationAutoScalingJsonHandler; import io.github.hectorvent.floci.services.cloudcontrol.CloudControlJsonHandler; +import io.github.hectorvent.floci.services.ssoadmin.SsoAdminJsonHandler; import io.github.hectorvent.floci.services.configservice.ConfigServiceJsonHandler; import io.github.hectorvent.floci.services.cur.CurJsonHandler; import io.github.hectorvent.floci.services.pricing.PricingJsonHandler; @@ -108,6 +109,7 @@ public class AwsJson11Controller { private final ApplicationAutoScalingJsonHandler applicationAutoScalingJsonHandler; private final CloudHsmV2JsonHandler cloudHsmV2JsonHandler; private final OrganizationsJsonHandler organizationsJsonHandler; + private final SsoAdminJsonHandler ssoAdminJsonHandler; private final ServiceQuotasJsonHandler serviceQuotasJsonHandler; @Inject @@ -147,6 +149,7 @@ public class AwsJson11Controller { ApplicationAutoScalingJsonHandler applicationAutoScalingJsonHandler, CloudHsmV2JsonHandler cloudHsmV2JsonHandler, OrganizationsJsonHandler organizationsJsonHandler, + SsoAdminJsonHandler ssoAdminJsonHandler, ServiceQuotasJsonHandler serviceQuotasJsonHandler) { this.objectMapper = objectMapper; this.strictBodyReader = objectMapper.reader().with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS); @@ -190,6 +193,7 @@ public class AwsJson11Controller { this.applicationAutoScalingJsonHandler = applicationAutoScalingJsonHandler; this.cloudHsmV2JsonHandler = cloudHsmV2JsonHandler; this.organizationsJsonHandler = organizationsJsonHandler; + this.ssoAdminJsonHandler = ssoAdminJsonHandler; this.serviceQuotasJsonHandler = serviceQuotasJsonHandler; } @@ -267,6 +271,7 @@ public class AwsJson11Controller { // action is authorized against the calling account, so pass that instead of region. case "organizations" -> organizationsJsonHandler.handle(action, request, regionResolver.getAccountId()); + case "sso" -> ssoAdminJsonHandler.handle(action, request, regionResolver.getAccountId()); case "servicequotas" -> serviceQuotasJsonHandler.handle( action, request, region, regionResolver.getAccountId()); default -> null; diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java index 7e73adb2d9..947847d847 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java @@ -385,6 +385,13 @@ public class ResolvedServiceCatalog { null, null, 5000L, null, ServiceProtocol.JSON, protocols(ServiceProtocol.JSON), Set.of("CloudApiService."), Set.of("cloudcontrolapi"), Set.of(), Set.of()), + // SSO Admin (IAM Identity Center) signs with scope "sso"; its Smithy target + // prefix is the AWS-internal codename SWBExternalService (cf. config's + // StarlingDoveService above). + descriptor("sso", "ssoadmin", config.services().ssoadmin().enabled(), true, + null, null, 5000L, null, ServiceProtocol.JSON, + protocols(ServiceProtocol.JSON), + Set.of("SWBExternalService."), Set.of("sso"), Set.of(), Set.of()), descriptor("autoscaling", "autoscaling", config.services().autoscaling().enabled(), true, "autoscaling", config.storage().mode(), 5000L, AwsNamespaces.AUTOSCALING, ServiceProtocol.QUERY, protocols(ServiceProtocol.QUERY), diff --git a/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminJsonHandler.java new file mode 100644 index 0000000000..27686e0a50 --- /dev/null +++ b/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminJsonHandler.java @@ -0,0 +1,41 @@ +package io.github.hectorvent.floci.services.ssoadmin; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import io.github.hectorvent.floci.core.common.AwsException; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.core.Response; + +@ApplicationScoped +public class SsoAdminJsonHandler { + + private final SsoAdminService service; + private final ObjectMapper mapper; + + @Inject + public SsoAdminJsonHandler(SsoAdminService service, ObjectMapper mapper) { + this.service = service; + this.mapper = mapper; + } + + public Response handle(String action, JsonNode request, String callerAccountId) { + return switch (action) { + case "ListInstances" -> listInstances(callerAccountId); + default -> throw new AwsException("UnknownOperationException", + "Operation " + action + " is not supported.", 400); + }; + } + + private Response listInstances(String callerAccountId) { + ObjectNode response = mapper.createObjectNode(); + ObjectNode instance = response.putArray("Instances").addObject(); + instance.put("InstanceArn", service.getInstanceArn()); + instance.put("IdentityStoreId", service.getIdentityStoreId()); + instance.put("Name", "floci-identity-center"); + instance.put("OwnerAccountId", callerAccountId); + instance.put("Status", "ACTIVE"); + return Response.ok(response).build(); + } +} diff --git a/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java b/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java new file mode 100644 index 0000000000..361a11818d --- /dev/null +++ b/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java @@ -0,0 +1,27 @@ +package io.github.hectorvent.floci.services.ssoadmin; + +import jakarta.enterprise.context.ApplicationScoped; + +/** + * IAM Identity Center (SSO Admin) business logic. + * + *

Models the single organization Identity Center instance LZA's + * Custom::GetIdentityCenterInstanceMetadata Lambda expects: its {@code ListInstances} call + * succeeds only when exactly one instance is returned, carrying both {@code InstanceArn} and + * {@code IdentityStoreId}. The identifiers are fixed so they stay stable across calls and + * container restarts — LZA persists them into SSM parameters between stages. + */ +@ApplicationScoped +public class SsoAdminService { + + private static final String INSTANCE_ARN = "arn:aws:sso:::instance/ssoins-7223b02a5d9f7c8e"; + private static final String IDENTITY_STORE_ID = "d-9067f2a3c1"; + + public String getInstanceArn() { + return INSTANCE_ARN; + } + + public String getIdentityStoreId() { + return IDENTITY_STORE_ID; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 65ea0d49a8..3b30d59a03 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -547,6 +547,8 @@ floci: enabled: true emrserverless: enabled: true + ssoadmin: + enabled: true controltower: enabled: true lakeformation: diff --git a/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminIntegrationTest.java new file mode 100644 index 0000000000..beba7a53ef --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminIntegrationTest.java @@ -0,0 +1,94 @@ +package io.github.hectorvent.floci.services.ssoadmin; + +import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * IAM Identity Center (SSO Admin, target prefix {@code SWBExternalService.}). + * + *

LZA's Custom::GetIdentityCenterInstanceMetadata Lambda calls {@code ListInstances} and + * requires exactly one instance carrying {@code InstanceArn} and {@code IdentityStoreId}. + */ +@QuarkusTest +class SsoAdminIntegrationTest { + + private static final String AUTH_HEADER = + "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/sso/aws4_request"; + + @BeforeAll + static void configureRestAssured() { + RestAssuredJsonUtils.configureAwsContentTypes(); + } + + @Test + void listInstances_returnsExactlyOneInstanceWithArnAndIdentityStore() { + given() + .contentType("application/x-amz-json-1.1") + .header("Authorization", AUTH_HEADER) + .header("X-Amz-Target", "SWBExternalService.ListInstances") + .body("{}") + .when() + .post("/") + .then() + .statusCode(200) + .body("Instances.size()", equalTo(1)) + .body("Instances[0].InstanceArn", matchesPattern("arn:aws:sso:::instance/ssoins-[0-9a-f]{16}")) + .body("Instances[0].IdentityStoreId", matchesPattern("d-[0-9a-f]{10}")) + .body("Instances[0].Status", equalTo("ACTIVE")); + } + + @Test + void listInstances_isStableAcrossCalls() { + String firstArn = listInstancesArn(); + String secondArn = listInstancesArn(); + org.junit.jupiter.api.Assertions.assertEquals(firstArn, secondArn); + } + + @Test + void unknownAction_returnsUnknownOperationException() { + given() + .contentType("application/x-amz-json-1.1") + .header("Authorization", AUTH_HEADER) + .header("X-Amz-Target", "SWBExternalService.DescribeInstance") + .body("{}") + .when() + .post("/") + .then() + .statusCode(400) + .body("__type", org.hamcrest.Matchers.containsString("UnknownOperationException")); + } + + @Test + void listInstances_ownerAccountIdTracksTheCaller() { + given() + .contentType("application/x-amz-json-1.1") + .header("Authorization", + "AWS4-HMAC-SHA256 Credential=111122223333/20260101/us-east-1/sso/aws4_request") + .header("X-Amz-Target", "SWBExternalService.ListInstances") + .body("{}") + .when() + .post("/") + .then() + .statusCode(200) + .body("Instances[0].OwnerAccountId", org.hamcrest.Matchers.equalTo("111122223333")); + } + + private static String listInstancesArn() { + return given() + .contentType("application/x-amz-json-1.1") + .header("Authorization", AUTH_HEADER) + .header("X-Amz-Target", "SWBExternalService.ListInstances") + .body("{}") + .when() + .post("/") + .then() + .statusCode(200) + .extract().path("Instances[0].InstanceArn"); + } +} diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index f6fe88402d..2c3ab8ceb1 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -341,6 +341,8 @@ floci: enabled: true emrserverless: enabled: true + ssoadmin: + enabled: true controltower: enabled: true lakeformation: diff --git a/tools/docs/service_matrix.yaml b/tools/docs/service_matrix.yaml index 1b191467e9..79594e01bd 100644 --- a/tools/docs/service_matrix.yaml +++ b/tools/docs/service_matrix.yaml @@ -20,6 +20,7 @@ aliases: kafka: msk # MSK's SigV4 signing name is "kafka" mq: amazonmq # Amazon MQ's SigV4 signing name is "mq" signin: iam # AWS Sign-In facet, at iam.md#aws-sign-in-login-credentials + sso: iam # Identity Center ListInstances facet on the IAM page events: eventbridge servicediscovery: cloudmap # Cloud Map's SigV4 signing name elasticmapreduce: emr # EMR's SigV4 signing name diff --git a/tools/docs/services.yaml b/tools/docs/services.yaml index 3531e3b8f1..2d99706a87 100644 --- a/tools/docs/services.yaml +++ b/tools/docs/services.yaml @@ -146,6 +146,7 @@ services: # Switch handlers that exist but are intentionally not yet covered (see reasons). # A NEW switch handler not listed here and not registered above fails `--strict`. deferred_handlers: + - { path: src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminJsonHandler.java } # single-op Identity Center stub, no standalone doc page yet - { path: src/main/java/io/github/hectorvent/floci/services/apigatewayv2/ApiGatewayV2JsonHandler.java } # non-tabular doc (grouped/inline) - { path: src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingQueryHandler.java } # non-tabular doc (grouped/inline) - { path: src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsJsonHandler.java } # no standalone action table yet