From 1c8b851bea0eef712382d812edfc75c1f25ffd76 Mon Sep 17 00:00:00 2001 From: Huan Jiang <4230979+billjh@users.noreply.github.com> Date: Fri, 24 Jul 2026 00:27:46 +0800 Subject: [PATCH] fix(cognito): build OIDC URLs from effectiveBaseUrl so FLOCI_HOSTNAME is honored (#1929) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(cognito): build OIDC URLs from effectiveBaseUrl so FLOCI_HOSTNAME is honored CognitoService was wired from the raw emulatorConfig.baseUrl(), so its issuer, JWKS URI, and token/userInfo endpoints ignored FLOCI_HOSTNAME. Every other response-facing service (SQS QueueUrl, SNS, S3 pre-signed URLs, Lambda function URLs) uses effectiveBaseUrl(), which applies the hostname override (and the TLS http->https switch). These Cognito URLs are external-facing — they land in the JWT `iss` claim and the .well-known/openid-configuration document that clients must reach — so in a multi-container / Docker Compose setup with FLOCI_HOSTNAME set they were emitted as http://localhost:4566/... and unreachable, breaking OIDC discovery and JWT validation. Switch the injection to effectiveBaseUrl(). It falls back to baseUrl() when hostname is unset, so the default localhost behavior (and all existing tests) are unchanged. * test(cognito): drive real effectiveBaseUrl so the test reproduces the bug Stub only effectiveBaseUrl()'s inputs (baseUrl, hostname, tls) and call the real default method, instead of stubbing effectiveBaseUrl() itself. The previous version asserted little more than "Cognito calls the getter it was told to" — it stubbed away the very override logic under test and would not fail against the old raw-baseUrl() wiring. Now the localhost->floci host swap actually runs, so the test fails on a revert. Also add a no-hostname case pinning the baseUrl() fallback. * test(cognito): drop dedicated effectiveBaseUrl wiring test On review of the repo's testing patterns this test isn't idiomatic and adds little. Every peer service that reads effectiveBaseUrl() (SQS, SNS, S3, Lambda, ECS, Pipes, IoT, SSM) either stubs it to a literal or is constructed with a literal baseUrl — none has a dedicated test proving the FLOCI_HOSTNAME override reaches its response URLs; the accessor choice is simply trusted. The removed test was also the only thenCallRealMethod on effectiveBaseUrl in the suite. The existing issuerUrlForPinnedPoolResolvesAsBaseUrlSlashPoolId already covers the getIssuer URL shape, and effectiveBaseUrl()'s own override logic is exercised via TlsConfigSource tests. The fix is a one-token consistency change aligning Cognito with its peers. --- .../hectorvent/floci/services/cognito/CognitoService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoService.java b/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoService.java index 78716df602..5b36e76a43 100644 --- a/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoService.java +++ b/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoService.java @@ -91,7 +91,7 @@ public class CognitoService { new TypeReference>() {}), storageFactory.create("cognito", "cognito-revoked-tokens.json", new TypeReference>() {}), - trimTrailingSlash(emulatorConfig.baseUrl()), + trimTrailingSlash(emulatorConfig.effectiveBaseUrl()), regionResolver, lambdaService, new VerificationCodeService(storageFactory, clock),