Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix: resolve Cognito auth, token, and user lookup issues (#218 #220 #228 #229 #233 #234 #235) (#279)

Hector Ventura5e8b39c1aaec
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CognitoFeaturesTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CognitoFeaturesTest.java
new file mode 100644
index 0000000000..3ff17343d6
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CognitoFeaturesTest.java
@@ -0,0 +1,397 @@
+package com.floci.test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.*;
+import software.amazon.awssdk.services.cognitoidentityprovider.CognitoIdentityProviderClient;
+import software.amazon.awssdk.services.cognitoidentityprovider.model.*;
+
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyFactory;
+import java.security.Signature;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.RSAPublicKeySpec;
+import java.time.Duration;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.*;
+
+/**
+ * Compatibility tests for Cognito fixes (Java SDK-based):
+ * #218 — RS256 JWT signing + JWKS signature verification
+ * #220 — AdminGetUser accepts sub UUID and email alias as Username
+ * #228 — AccessToken contains client_id claim
+ * #229 — InitiateAuth rejects auth when no password hash is set
+ * #233 — ListUsers respects Filter parameter
+ * #235 — AdminSetUserPassword(Permanent=false) changes the password
+ *
+ * Note: Issue #234 (GetTokensFromRefreshToken) is tested in sdk-test-node/tests/cognito-features.test.ts
+ * because GetTokensFromRefreshTokenCommand is not present in Java SDK 2.31.8.
+ */
+@DisplayName("Cognito IDP — bug fixes #218 #220 #228 #229 #233 #235")
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class CognitoFeaturesTest {
+
+ private static final ObjectMapper JSON = new ObjectMapper();
+ private static final HttpClient HTTP = HttpClient.newBuilder()
+ .connectTimeout(Duration.ofSeconds(10))
+ .build();
+
+ private static CognitoIdentityProviderClient cognito;
+
+ private static String poolId;
+ private static String clientId;
+ private static final String USERNAME = "compat-user-" + UUID.randomUUID() + "@example.com";
+ private static final String PASSWORD = "CompatPass1!";
+ private static String userSub;
+
+ @BeforeAll
+ static void setup() {
+ cognito = TestFixtures.cognitoClient();
+ }
+
+ @AfterAll
+ static void cleanup() {
+ if (cognito == null) return;
+ try {
+ if (poolId != null) {
+ cognito.deleteUserPool(b -> b.userPoolId(poolId));
+ }
+ } catch (Exception ignored) {}
+ cognito.close();
+ }
+
+ // ── Setup ─────────────────────────────────────────────────────────────────
+
+ @Test
+ @Order(1)
+ void createPool() {
+ CreateUserPoolResponse resp = cognito.createUserPool(b -> b.poolName("compat-test-pool"));
+ poolId = resp.userPool().id();
+ assertThat(poolId).isNotBlank();
+ }
+
+ @Test
+ @Order(2)
+ void createClient() {
+ CreateUserPoolClientResponse resp = cognito.createUserPoolClient(b -> b
+ .userPoolId(poolId)
+ .clientName("compat-test-client")
+ .explicitAuthFlows(
+ ExplicitAuthFlowsType.ALLOW_USER_PASSWORD_AUTH,
+ ExplicitAuthFlowsType.ALLOW_REFRESH_TOKEN_AUTH));
+ clientId = resp.userPoolClient().clientId();
+ assertThat(clientId).isNotBlank();
+ }
+
+ @Test
+ @Order(3)
+ void createUserWithPermPassword() {
+ cognito.adminCreateUser(b -> b
+ .userPoolId(poolId)
+ .username(USERNAME)
+ .userAttributes(
+ AttributeType.builder().name("email").value(USERNAME).build(),
+ AttributeType.builder().name("email_verified").value("true").build())
+ .messageAction(MessageActionType.SUPPRESS));
+ cognito.adminSetUserPassword(b -> b
+ .userPoolId(poolId)
+ .username(USERNAME)
+ .password(PASSWORD)
+ .permanent(true));
+
+ AdminGetUserResponse user = cognito.adminGetUser(b -> b.userPoolId(poolId).username(USERNAME));
+ userSub = user.userAttributes().stream()
+ .filter(a -> "sub".equals(a.name()))
+ .map(AttributeType::value)
+ .findFirst()
+ .orElse(null);
+ assertThat(userSub).isNotBlank();
+ }
+
+ // ── Issue #229 — InitiateAuth rejects when no password hash is set ────────
+
+ @Test
+ @Order(10)
+ void initiateAuthRejectsAnyPasswordForUserWithNoHashSet() {
+ String noHashUser = "no-hash-" + UUID.randomUUID() + "@example.com";
+ cognito.adminCreateUser(b -> b
+ .userPoolId(poolId)
+ .username(noHashUser)
+ .userAttributes(AttributeType.builder().name("email").value(noHashUser).build())
+ .messageAction(MessageActionType.SUPPRESS));
+
+ assertThatThrownBy(() -> cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", noHashUser, "PASSWORD", "anything"))))
+ .isInstanceOf(CognitoIdentityProviderException.class)
+ .matches(e -> e.getClass().getSimpleName().equals("NotAuthorizedException")
+ || e.getMessage().contains("NotAuthorizedException"));
+ }
+
+ @Test
+ @Order(11)
+ void initiateAuthRejectsWrongPassword() {
+ assertThatThrownBy(() -> cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", "WrongPass1!"))))
+ .isInstanceOf(CognitoIdentityProviderException.class)
+ .matches(e -> e.getClass().getSimpleName().equals("NotAuthorizedException")
+ || e.getMessage().contains("NotAuthorizedException"));
+ }
+
+ // ── Issue #235 — AdminSetUserPassword(Permanent=false) changes the password ─
+
+ @Test
+ @Order(20)
+ void adminSetUserPasswordPermanentFalseChangesPassword() {
+ String tempPass = "TempPass1!";
+
+ cognito.adminSetUserPassword(b -> b
+ .userPoolId(poolId)
+ .username(USERNAME)
+ .password(tempPass)
+ .permanent(false));
+
+ // Old password now rejected
+ assertThatThrownBy(() -> cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", PASSWORD))))
+ .isInstanceOf(CognitoIdentityProviderException.class)
+ .matches(e -> e.getClass().getSimpleName().equals("NotAuthorizedException")
+ || e.getMessage().contains("NotAuthorizedException"));
+
+ // New temp password triggers NEW_PASSWORD_REQUIRED challenge, not tokens
+ InitiateAuthResponse challengeResp = cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", tempPass)));
+ assertThat(challengeResp.challengeName()).isEqualTo(ChallengeNameType.NEW_PASSWORD_REQUIRED);
+
+ // Restore permanent password for subsequent tests
+ cognito.adminSetUserPassword(b -> b
+ .userPoolId(poolId)
+ .username(USERNAME)
+ .password(PASSWORD)
+ .permanent(true));
+ }
+
+ // ── Issue #228 — AccessToken contains client_id claim ─────────────────────
+
+ @Test
+ @Order(30)
+ void accessTokenContainsClientIdClaim() throws Exception {
+ InitiateAuthResponse resp = cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", PASSWORD)));
+
+ JsonNode payload = decodeJwtPayload(resp.authenticationResult().accessToken());
+ assertThat(payload.path("client_id").asText())
+ .as("AccessToken must contain client_id matching the requesting ClientId")
+ .isEqualTo(clientId);
+ }
+
+ @Test
+ @Order(31)
+ void idTokenDoesNotContainClientIdClaim() throws Exception {
+ InitiateAuthResponse resp = cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", PASSWORD)));
+
+ JsonNode payload = decodeJwtPayload(resp.authenticationResult().idToken());
+ assertThat(payload.has("client_id"))
+ .as("IdToken should not contain client_id claim")
+ .isFalse();
+ }
+
+ // ── Issue #218 — RS256 JWT signing and JWKS signature verification ─────────
+
+ @Test
+ @Order(32)
+ void accessTokenIsSignedWithRs256() throws Exception {
+ InitiateAuthResponse resp = cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", PASSWORD)));
+
+ JsonNode header = decodeJwtHeader(resp.authenticationResult().accessToken());
+ assertThat(header.path("alg").asText()).isEqualTo("RS256");
+ assertThat(header.path("kid").asText()).isNotBlank();
+ }
+
+ @Test
+ @Order(33)
+ void accessTokenSignatureVerifiesAgainstJwks() throws Exception {
+ InitiateAuthResponse resp = cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", PASSWORD)));
+
+ String accessToken = resp.authenticationResult().accessToken();
+ String kid = decodeJwtHeader(accessToken).path("kid").asText();
+
+ URI jwksUri = TestFixtures.endpoint().resolve("/" + poolId + "/.well-known/jwks.json");
+ HttpResponse<String> jwksResp = HTTP.send(
+ HttpRequest.newBuilder().uri(jwksUri).GET().timeout(Duration.ofSeconds(10)).build(),
+ HttpResponse.BodyHandlers.ofString());
+ assertThat(jwksResp.statusCode()).isEqualTo(200);
+
+ JsonNode jwk = null;
+ for (JsonNode key : JSON.readTree(jwksResp.body()).path("keys")) {
+ if (kid.equals(key.path("kid").asText())) {
+ jwk = key;
+ break;
+ }
+ }
+ assertThat(jwk).as("JWK with kid=%s must be present in JWKS", kid).isNotNull();
+ assertThat(verifyRs256Signature(accessToken, jwk))
+ .as("AccessToken RS256 signature must verify against published JWKS public key")
+ .isTrue();
+ }
+
+ // ── Issue #220 — AdminGetUser accepts sub UUID and email as Username ───────
+
+ @Test
+ @Order(40)
+ void adminGetUserBySubUuid() {
+ assertThat(userSub).isNotBlank();
+ AdminGetUserResponse resp = cognito.adminGetUser(b -> b
+ .userPoolId(poolId)
+ .username(userSub));
+ assertThat(resp.username())
+ .as("AdminGetUser with sub UUID should resolve to the correct user")
+ .isEqualTo(USERNAME);
+ }
+
+ @Test
+ @Order(41)
+ void adminGetUserByEmailAlias() {
+ AdminGetUserResponse resp = cognito.adminGetUser(b -> b
+ .userPoolId(poolId)
+ .username(USERNAME));
+ assertThat(resp.username()).isEqualTo(USERNAME);
+ }
+
+ @Test
+ @Order(42)
+ void adminSetUserPasswordBySubUuid() {
+ cognito.adminSetUserPassword(b -> b
+ .userPoolId(poolId)
+ .username(userSub)
+ .password(PASSWORD)
+ .permanent(true));
+
+ InitiateAuthResponse resp = cognito.initiateAuth(b -> b
+ .clientId(clientId)
+ .authFlow(AuthFlowType.USER_PASSWORD_AUTH)
+ .authParameters(Map.of("USERNAME", USERNAME, "PASSWORD", PASSWORD)));
+ assertThat(resp.authenticationResult().accessToken()).isNotBlank();
+ }
+
+ // ── Issue #233 — ListUsers respects Filter parameter ─────────────────────
+
+ @Test
+ @Order(50)
+ void listUsersNoFilterReturnsUser() {
+ ListUsersResponse resp = cognito.listUsers(b -> b.userPoolId(poolId));
+ assertThat(resp.users()).extracting(UserType::username).contains(USERNAME);
+ }
+
+ @Test
+ @Order(51)
+ void listUsersFilterByEmailExactMatch() {
+ ListUsersResponse resp = cognito.listUsers(b -> b
+ .userPoolId(poolId)
+ .filter("email = \"" + USERNAME + "\""));
+ System.out.println("Filter: email = \"" + USERNAME + "\"");
+ System.out.println("Users found: " + resp.users().size());
+ for (UserType u : resp.users()) {
+ String email = u.attributes().stream().filter(a -> "email".equals(a.name())).map(AttributeType::value).findFirst().orElse("null");
+ System.out.println(" - User: " + u.username() + ", email: " + email);
+ }
+ assertThat(resp.users()).hasSize(1);
+ assertThat(resp.users().get(0).username()).isEqualTo(USERNAME);
+ }
+
+ @Test
+ @Order(52)
+ void listUsersFilterByEmailPrefixStartsWith() {
+ ListUsersResponse resp = cognito.listUsers(b -> b
+ .userPoolId(poolId)
+ .filter("email ^= \"compat-user-\""));
+ assertThat(resp.users()).extracting(UserType::username).contains(USERNAME);
+ }
+
+ @Test
+ @Order(53)
+ void listUsersFilterBySubExactMatch() {
+ assertThat(userSub).isNotBlank();
+ ListUsersResponse resp = cognito.listUsers(b -> b
+ .userPoolId(poolId)
+ .filter("sub = \"" + userSub + "\""));
+ assertThat(resp.users()).hasSize(1);
+ assertThat(resp.users().get(0).username()).isEqualTo(USERNAME);
+ }
+
+ @Test
+ @Order(54)
+ void listUsersFilterNoMatchReturnsEmpty() {
+ ListUsersResponse resp = cognito.listUsers(b -> b
+ .userPoolId(poolId)
+ .filter("email = \"[email protected]\""));
+ assertThat(resp.users()).isEmpty();
+ }
+
+ // ── Issue #234 note ───────────────────────────────────────────────────────
+ // GetTokensFromRefreshToken is tested in sdk-test-node/tests/cognito-features.test.ts
+ // because GetTokensFromRefreshTokenCommand is not available in Java SDK 2.31.8.
+
+ // ── JWT helpers ───────────────────────────────────────────────────────────
+
+ private static JsonNode decodeJwtPayload(String jwt) throws Exception {
+ return decodeJwtPart(jwt, 1);
+ }
+
+ private static JsonNode decodeJwtHeader(String jwt) throws Exception {
+ return decodeJwtPart(jwt, 0);
+ }
+
+ private static JsonNode decodeJwtPart(String jwt, int index) throws Exception {
+ String[] parts = jwt.split("\\.");
+ if (parts.length != 3) {
+ throw new IllegalArgumentException("JWT must have 3 parts, got " + parts.length);
+ }
+ byte[] decoded = Base64.getUrlDecoder().decode(padBase64(parts[index]));
+ return JSON.readTree(new String(decoded, StandardCharsets.UTF_8));
+ }
+
+ private static boolean verifyRs256Signature(String jwt, JsonNode jwk) throws Exception {
+ String[] parts = jwt.split("\\.");
+ BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(padBase64(jwk.path("n").asText())));
+ BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(padBase64(jwk.path("e").asText())));
+ RSAPublicKey publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA")
+ .generatePublic(new RSAPublicKeySpec(modulus, exponent));
+ Signature verifier = Signature.getInstance("SHA256withRSA");
+ verifier.initVerify(publicKey);
+ verifier.update((parts[0] + "." + parts[1]).getBytes(StandardCharsets.UTF_8));
+ return verifier.verify(Base64.getUrlDecoder().decode(padBase64(parts[2])));
+ }
+
+ private static String padBase64(String value) {
+ int remainder = value.length() % 4;
+ return remainder == 0 ? value : value + "=".repeat(4 - remainder);
+ }
+}
diff --git a/compatibility-tests/sdk-test-node/tests/cognito-features.test.ts b/compatibility-tests/sdk-test-node/tests/cognito-features.test.ts
new file mode 100644
index 0000000000..18f396b8f8
--- /dev/null
+++ b/compatibility-tests/sdk-test-node/tests/cognito-features.test.ts
@@ -0,0 +1,439 @@
+/**
+ * Cognito IDP compatibility tests for bug fixes:
+ * #218 — RS256 JWT signing + JWKS signature verification
+ * #220 — AdminGetUser accepts sub UUID and email alias as Username
+ * #228 — AccessToken contains client_id claim
+ * #229 — InitiateAuth rejects auth when no password hash is set
+ * #233 — ListUsers respects Filter parameter
+ * #234 — GetTokensFromRefreshToken returns new tokens (JS SDK v3 only)
+ * #235 — AdminSetUserPassword(Permanent=false) changes the password
+ */
+
+import { createPublicKey, createVerify } from 'node:crypto';
+import { describe, it, expect, beforeAll, afterAll } from 'vitest';
+import {
+ CognitoIdentityProviderClient,
+ CreateUserPoolCommand,
+ CreateUserPoolClientCommand,
+ AdminCreateUserCommand,
+ AdminSetUserPasswordCommand,
+ AdminGetUserCommand,
+ InitiateAuthCommand,
+ ListUsersCommand,
+ GetTokensFromRefreshTokenCommand,
+ DeleteUserPoolCommand,
+ MessageActionType,
+ ExplicitAuthFlowsType,
+ AuthFlowType,
+ ChallengeNameType,
+} from '@aws-sdk/client-cognito-identity-provider';
+import { makeClient, uniqueName, ENDPOINT } from './setup';
+
+// ── JWT helpers ──────────────────────────────────────────────────────────────
+
+function decodeJwtPart(token: string, index: number): any {
+ const part = token.split('.')[index];
+ return JSON.parse(Buffer.from(part, 'base64url').toString('utf8'));
+}
+
+async function fetchJwk(poolId: string, kid: string): Promise<any> {
+ const resp = await fetch(`${ENDPOINT}/${poolId}/.well-known/jwks.json`);
+ const json = await resp.json();
+ return json.keys?.find((k: any) => k.kid === kid) ?? null;
+}
+
+function verifyRs256(token: string, jwk: any): boolean {
+ const [headerB64, payloadB64, sigB64] = token.split('.');
+ const key = createPublicKey({ key: jwk, format: 'jwk' });
+ const verifier = createVerify('RSA-SHA256');
+ verifier.update(`${headerB64}.${payloadB64}`);
+ return verifier.verify(key, Buffer.from(sigB64, 'base64url'));
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+
+describe('Cognito features (#218 #220 #228 #229 #233 #234 #235)', () => {
+ let cognito: CognitoIdentityProviderClient;
+ let poolId: string;
+ let clientId: string;
+ const username = `compat-${uniqueName()}@example.com`;
+ const password = 'CompatPass1!';
+ let userSub: string;
+
+ beforeAll(() => {
+ cognito = makeClient(CognitoIdentityProviderClient);
+ });
+
+ afterAll(async () => {
+ try {
+ if (poolId) await cognito.send(new DeleteUserPoolCommand({ UserPoolId: poolId }));
+ } catch { /* ignore */ }
+ });
+
+ // ── Setup ──────────────────────────────────────────────────────────────────
+
+ it('creates pool', async () => {
+ const resp = await cognito.send(
+ new CreateUserPoolCommand({ PoolName: `compat-pool-${uniqueName()}` })
+ );
+ poolId = resp.UserPool!.Id!;
+ expect(poolId).toBeTruthy();
+ });
+
+ it('creates client', async () => {
+ const resp = await cognito.send(
+ new CreateUserPoolClientCommand({
+ UserPoolId: poolId,
+ ClientName: `compat-client-${uniqueName()}`,
+ ExplicitAuthFlows: [
+ ExplicitAuthFlowsType.ALLOW_USER_PASSWORD_AUTH,
+ ExplicitAuthFlowsType.ALLOW_REFRESH_TOKEN_AUTH,
+ ],
+ })
+ );
+ clientId = resp.UserPoolClient!.ClientId!;
+ expect(clientId).toBeTruthy();
+ });
+
+ it('creates user with permanent password', async () => {
+ await cognito.send(
+ new AdminCreateUserCommand({
+ UserPoolId: poolId,
+ Username: username,
+ UserAttributes: [
+ { Name: 'email', Value: username },
+ { Name: 'email_verified', Value: 'true' },
+ ],
+ MessageAction: MessageActionType.SUPPRESS,
+ })
+ );
+ await cognito.send(
+ new AdminSetUserPasswordCommand({
+ UserPoolId: poolId,
+ Username: username,
+ Password: password,
+ Permanent: true,
+ })
+ );
+
+ const user = await cognito.send(
+ new AdminGetUserCommand({ UserPoolId: poolId, Username: username })
+ );
+ userSub = user.UserAttributes?.find((a) => a.Name === 'sub')?.Value ?? '';
+ expect(userSub).toBeTruthy();
+ });
+
+ // ── Issue #229 — InitiateAuth rejects when no password hash set ────────────
+
+ it('#229: rejects auth when user has no password set', async () => {
+ const noHashUser = `no-hash-${uniqueName()}@example.com`;
+ await cognito.send(
+ new AdminCreateUserCommand({
+ UserPoolId: poolId,
+ Username: noHashUser,
+ UserAttributes: [{ Name: 'email', Value: noHashUser }],
+ MessageAction: MessageActionType.SUPPRESS,
+ })
+ );
+
+ await expect(
+ cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: noHashUser, PASSWORD: 'anything' },
+ })
+ )
+ ).rejects.toThrow();
+ });
+
+ it('#229: rejects wrong password', async () => {
+ await expect(
+ cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: 'WrongPass1!' },
+ })
+ )
+ ).rejects.toThrow();
+ });
+
+ // ── Issue #235 — AdminSetUserPassword(Permanent=false) changes the password ─
+
+ it('#235: Permanent=false changes password and sets FORCE_CHANGE_PASSWORD status', async () => {
+ const tempPass = 'TempPass1!';
+
+ await cognito.send(
+ new AdminSetUserPasswordCommand({
+ UserPoolId: poolId,
+ Username: username,
+ Password: tempPass,
+ Permanent: false,
+ })
+ );
+
+ // Old password is now rejected
+ await expect(
+ cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ )
+ ).rejects.toThrow();
+
+ // New temp password triggers NEW_PASSWORD_REQUIRED, not tokens
+ const challengeResp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: tempPass },
+ })
+ );
+ expect(challengeResp.ChallengeName).toBe(ChallengeNameType.NEW_PASSWORD_REQUIRED);
+
+ // Restore permanent password for subsequent tests
+ await cognito.send(
+ new AdminSetUserPasswordCommand({
+ UserPoolId: poolId,
+ Username: username,
+ Password: password,
+ Permanent: true,
+ })
+ );
+ });
+
+ // ── Issue #228 — AccessToken contains client_id claim ─────────────────────
+
+ it('#228: AccessToken contains client_id claim matching the ClientId', async () => {
+ const resp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const payload = decodeJwtPart(resp.AuthenticationResult!.AccessToken!, 1);
+ expect(payload.client_id).toBe(clientId);
+ });
+
+ it('#228: IdToken does not contain client_id claim', async () => {
+ const resp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const payload = decodeJwtPart(resp.AuthenticationResult!.IdToken!, 1);
+ expect(payload.client_id).toBeUndefined();
+ });
+
+ // ── Issue #218 — RS256 JWT signing + JWKS verification ────────────────────
+
+ it('#218: AccessToken header declares alg=RS256 with a kid', async () => {
+ const resp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const header = decodeJwtPart(resp.AuthenticationResult!.AccessToken!, 0);
+ expect(header.alg).toBe('RS256');
+ expect(header.kid).toBeTruthy();
+ });
+
+ it('#218: AccessToken RS256 signature verifies against JWKS public key', async () => {
+ const resp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const token = resp.AuthenticationResult!.AccessToken!;
+ const kid = decodeJwtPart(token, 0).kid;
+ const jwk = await fetchJwk(poolId, kid);
+ expect(jwk).toBeTruthy();
+ expect(verifyRs256(token, jwk)).toBe(true);
+ });
+
+ // ── Issue #220 — AdminGetUser accepts sub UUID and email alias ────────────
+
+ it('#220: AdminGetUser resolves by sub UUID', async () => {
+ expect(userSub).toBeTruthy();
+ const resp = await cognito.send(
+ new AdminGetUserCommand({ UserPoolId: poolId, Username: userSub })
+ );
+ expect(resp.Username).toBe(username);
+ });
+
+ it('#220: AdminGetUser resolves by email alias', async () => {
+ const resp = await cognito.send(
+ new AdminGetUserCommand({ UserPoolId: poolId, Username: username })
+ );
+ expect(resp.Username).toBe(username);
+ });
+
+ it('#220: AdminSetUserPassword works with sub UUID as Username', async () => {
+ await cognito.send(
+ new AdminSetUserPasswordCommand({
+ UserPoolId: poolId,
+ Username: userSub,
+ Password: password,
+ Permanent: true,
+ })
+ );
+ const resp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ expect(resp.AuthenticationResult?.AccessToken).toBeTruthy();
+ });
+
+ // ── Issue #233 — ListUsers respects Filter parameter ─────────────────────
+
+ it('#233: ListUsers without filter returns the user', async () => {
+ const resp = await cognito.send(new ListUsersCommand({ UserPoolId: poolId }));
+ expect(resp.Users?.some((u) => u.Username === username)).toBe(true);
+ });
+
+ it('#233: ListUsers with email exact-match filter returns only matching user', async () => {
+ const resp = await cognito.send(
+ new ListUsersCommand({
+ UserPoolId: poolId,
+ Filter: `email = "${username}"`,
+ })
+ );
+ expect(resp.Users).toHaveLength(1);
+ expect(resp.Users![0].Username).toBe(username);
+ });
+
+ it('#233: ListUsers with email starts-with filter returns matching users', async () => {
+ const resp = await cognito.send(
+ new ListUsersCommand({
+ UserPoolId: poolId,
+ Filter: `email ^= "compat-"`,
+ })
+ );
+ expect(resp.Users?.some((u) => u.Username === username)).toBe(true);
+ });
+
+ it('#233: ListUsers with sub exact-match filter returns only that user', async () => {
+ expect(userSub).toBeTruthy();
+ const resp = await cognito.send(
+ new ListUsersCommand({
+ UserPoolId: poolId,
+ Filter: `sub = "${userSub}"`,
+ })
+ );
+ expect(resp.Users).toHaveLength(1);
+ expect(resp.Users![0].Username).toBe(username);
+ });
+
+ it('#233: ListUsers with non-matching filter returns empty list', async () => {
+ const resp = await cognito.send(
+ new ListUsersCommand({
+ UserPoolId: poolId,
+ Filter: `email = "[email protected]"`,
+ })
+ );
+ expect(resp.Users).toHaveLength(0);
+ });
+
+ // ── Issue #234 — GetTokensFromRefreshToken ────────────────────────────────
+
+ it('#234: InitiateAuth returns a structured refresh token', async () => {
+ const resp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ expect(resp.AuthenticationResult?.RefreshToken).toBeTruthy();
+ });
+
+ it('#234: GetTokensFromRefreshToken returns new AccessToken and IdToken', async () => {
+ const loginResp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const refreshToken = loginResp.AuthenticationResult!.RefreshToken!;
+
+ const refreshResp = await cognito.send(
+ new GetTokensFromRefreshTokenCommand({
+ ClientId: clientId,
+ RefreshToken: refreshToken,
+ })
+ );
+
+ expect(refreshResp.AuthenticationResult?.AccessToken).toBeTruthy();
+ expect(refreshResp.AuthenticationResult?.IdToken).toBeTruthy();
+ // Per AWS spec, GetTokensFromRefreshToken does not return a new RefreshToken
+ expect(refreshResp.AuthenticationResult?.RefreshToken).toBeFalsy();
+ });
+
+ it('#234: GetTokensFromRefreshToken returns token with correct client_id claim', async () => {
+ const loginResp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const refreshToken = loginResp.AuthenticationResult!.RefreshToken!;
+
+ const refreshResp = await cognito.send(
+ new GetTokensFromRefreshTokenCommand({
+ ClientId: clientId,
+ RefreshToken: refreshToken,
+ })
+ );
+
+ const payload = decodeJwtPart(refreshResp.AuthenticationResult!.AccessToken!, 1);
+ expect(payload.client_id).toBe(clientId);
+ });
+
+ it('#234: GetTokensFromRefreshToken rejects invalid refresh token', async () => {
+ await expect(
+ cognito.send(
+ new GetTokensFromRefreshTokenCommand({
+ ClientId: clientId,
+ RefreshToken: 'not-a-valid-token',
+ })
+ )
+ ).rejects.toThrow();
+ });
+
+ it('#234: REFRESH_TOKEN_AUTH flow also works with structured token', async () => {
+ const loginResp = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
+ AuthParameters: { USERNAME: username, PASSWORD: password },
+ })
+ );
+ const refreshToken = loginResp.AuthenticationResult!.RefreshToken!;
+
+ const refreshed = await cognito.send(
+ new InitiateAuthCommand({
+ ClientId: clientId,
+ AuthFlow: AuthFlowType.REFRESH_TOKEN_AUTH,
+ AuthParameters: { REFRESH_TOKEN: refreshToken },
+ })
+ );
+
+ expect(refreshed.AuthenticationResult?.AccessToken).toBeTruthy();
+ expect(refreshed.AuthenticationResult?.IdToken).toBeTruthy();
+ });
+});
diff --git a/emulator.log b/emulator.log
new file mode 100644
index 0000000000..86b4d97bb4
--- /dev/null
+++ b/emulator.log
@@ -0,0 +1,214 @@
+ ______ _ ____ _____ _____
+ | ____| | / __ \ / ____|_ _|
+ | |__ | | | | | | | | |
+ | __| | | | | | | | | |
+ | | | |___| |__| | |____ _| |_
+ |_| |______\____/ \_____|_____|
+
+
+ Powered by Quarkus 3.32.3
+2026-04-08 01:03:41,714 INFO [io.github.hectorvent.floci.lifecycle.EmulatorLifecycle] (main) === AWS Local Emulator Starting ===
+2026-04-08 01:03:41,718 INFO [io.github.hectorvent.floci.lifecycle.EmulatorLifecycle] (main) Storage mode: memory
+2026-04-08 01:03:41,719 INFO [io.github.hectorvent.floci.lifecycle.EmulatorLifecycle] (main) Persistent path: ./data
+2026-04-08 01:03:41,719 INFO [io.github.hectorvent.floci.core.common.ServiceRegistry] (main) Enabled services: [ssm, sqs, s3, dynamodb, sns, lambda, apigateway, iam, elasticache, rds, events, scheduler, logs, monitoring, secretsmanager, apigatewayv2, kinesis, kms, cognito-idp, states, cloudformation, acm, email, es]
+2026-04-08 01:03:41,719 INFO [io.github.hectorvent.floci.lifecycle.EmulatorLifecycle] (main) === AWS Local Emulator Ready ===
+2026-04-08 01:03:41,998 INFO [io.github.hectorvent.floci.core.common.BouncyCastleInitializer] (main) Registered BouncyCastle security provider (static initializer)
+2026-04-08 01:03:42,073 INFO [io.quarkus] (main) floci 1.0.11 on JVM (powered by Quarkus 3.32.3) started in 0.889s. Listening on: http://0.0.0.0:4566
+2026-04-08 01:03:42,073 INFO [io.quarkus] (main) Profile prod activated.
+2026-04-08 01:03:42,073 INFO [io.quarkus] (main) Installed features: [cdi, config-yaml, rest, rest-jackson, smallrye-context-propagation, vertx]
+2026-04-08 01:03:44,299 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service s3 (file: ./data/s3-buckets.json)
+2026-04-08 01:03:44,300 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service s3 (file: ./data/s3-objects.json)
+2026-04-08 01:05:39,506 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPool
+2026-04-08 01:05:39,535 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service cognito (file: ./data/cognito-pools.json)
+2026-04-08 01:05:39,536 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service cognito (file: ./data/cognito-clients.json)
+2026-04-08 01:05:39,536 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service cognito (file: ./data/cognito-resource-servers.json)
+2026-04-08 01:05:39,536 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service cognito (file: ./data/cognito-users.json)
+2026-04-08 01:05:39,536 INFO [io.github.hectorvent.floci.core.storage.StorageFactory] (executor-thread-1) Creating memory storage for service cognito (file: ./data/cognito-groups.json)
+2026-04-08 01:05:39,691 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool: us-east-1_6d7144642
+2026-04-08 01:05:39,794 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPoolClient
+2026-04-08 01:05:39,795 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool Client: 7f5e63cc637d4206b6163d7ad9 for pool us-east-1_6d7144642
+2026-04-08 01:05:39,811 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:05:39,812 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_6d7144642
+2026-04-08 01:05:39,822 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:39,822 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_6d7144642 (permanent=true)
+2026-04-08 01:05:39,828 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:05:39,836 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:05:39,837 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_6d7144642
+2026-04-08 01:05:39,845 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,872 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,876 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:39,877 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_6d7144642 (permanent=false)
+2026-04-08 01:05:39,880 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,882 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,892 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:39,893 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_6d7144642 (permanent=true)
+2026-04-08 01:05:39,896 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,919 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,926 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:39,933 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:40,011 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:05:40,016 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:05:40,020 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:40,020 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_6d7144642 (permanent=true)
+2026-04-08 01:05:40,022 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:40,031 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:40,039 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:40,039 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:40,040 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=true
+2026-04-08 01:05:40,044 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:40,044 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-user-"]: attrName=[email], rawValue=[compat-user-], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:40,044 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-user-"]: attrName=[email], rawValue=[compat-user-], attrValue=[[email protected]], matches=true
+2026-04-08 01:05:40,048 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:40,048 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "e5deeefe-846c-4ec5-b9f3-635cf9f4b411"]: attrName=[sub], rawValue=[e5deeefe-846c-4ec5-b9f3-635cf9f4b411], attrValue=[12ea2251-5968-4479-90db-37d16d75ef77], matches=false
+2026-04-08 01:05:40,048 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "e5deeefe-846c-4ec5-b9f3-635cf9f4b411"]: attrName=[sub], rawValue=[e5deeefe-846c-4ec5-b9f3-635cf9f4b411], attrValue=[e5deeefe-846c-4ec5-b9f3-635cf9f4b411], matches=true
+2026-04-08 01:05:40,051 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:40,052 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:40,052 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:40,056 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: DeleteUserPool
+2026-04-08 01:05:49,762 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPool
+2026-04-08 01:05:49,893 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool: us-east-1_74bf25322
+2026-04-08 01:05:49,901 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPoolClient
+2026-04-08 01:05:49,902 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool Client: ad730846525d4f379c26831104 for pool us-east-1_74bf25322
+2026-04-08 01:05:49,904 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:05:49,904 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_74bf25322
+2026-04-08 01:05:49,907 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:49,907 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_74bf25322 (permanent=true)
+2026-04-08 01:05:49,909 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:05:49,912 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:05:49,912 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_74bf25322
+2026-04-08 01:05:49,914 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,918 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,920 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:49,920 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_74bf25322 (permanent=false)
+2026-04-08 01:05:49,925 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,929 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,932 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,934 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,936 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:05:49,938 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:05:49,940 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:05:49,940 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_74bf25322 (permanent=true)
+2026-04-08 01:05:49,942 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,947 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:49,949 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:49,949 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=true
+2026-04-08 01:05:49,949 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:49,951 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:49,952 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-"]: attrName=[email], rawValue=[compat-], attrValue=[[email protected]], matches=true
+2026-04-08 01:05:49,952 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-"]: attrName=[email], rawValue=[compat-], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:49,953 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:49,953 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "41e928d5-6c74-4daf-912d-385435cf1729"]: attrName=[sub], rawValue=[41e928d5-6c74-4daf-912d-385435cf1729], attrValue=[41e928d5-6c74-4daf-912d-385435cf1729], matches=true
+2026-04-08 01:05:49,954 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "41e928d5-6c74-4daf-912d-385435cf1729"]: attrName=[sub], rawValue=[41e928d5-6c74-4daf-912d-385435cf1729], attrValue=[177fae24-1de4-40b2-8469-8db5aabaf5f2], matches=false
+2026-04-08 01:05:49,955 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:05:49,955 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:49,955 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:05:49,957 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,961 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,966 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:05:49,971 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,976 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:05:49,980 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:05:49,982 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,987 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:05:49,991 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: DeleteUserPool
+2026-04-08 01:06:32,337 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPool
+2026-04-08 01:06:32,462 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool: us-east-1_40ada8d8f
+2026-04-08 01:06:32,469 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPoolClient
+2026-04-08 01:06:32,469 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool Client: 68085b4130ef44e983e8b05194 for pool us-east-1_40ada8d8f
+2026-04-08 01:06:32,472 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:06:32,472 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_40ada8d8f
+2026-04-08 01:06:32,475 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:06:32,475 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_40ada8d8f (permanent=true)
+2026-04-08 01:06:32,477 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:06:32,479 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:06:32,479 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_40ada8d8f
+2026-04-08 01:06:32,481 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,485 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,487 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:06:32,487 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_40ada8d8f (permanent=false)
+2026-04-08 01:06:32,493 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,496 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,498 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,501 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,503 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:06:32,505 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:06:32,506 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:06:32,506 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_40ada8d8f (permanent=true)
+2026-04-08 01:06:32,508 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,513 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:06:32,515 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:06:32,515 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:06:32,515 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=true
+2026-04-08 01:06:32,517 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:06:32,517 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-"]: attrName=[email], rawValue=[compat-], attrValue=[[email protected]], matches=false
+2026-04-08 01:06:32,517 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-"]: attrName=[email], rawValue=[compat-], attrValue=[[email protected]], matches=true
+2026-04-08 01:06:32,519 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:06:32,519 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "2bfa0da3-8402-4220-a3bc-c0dd17e80946"]: attrName=[sub], rawValue=[2bfa0da3-8402-4220-a3bc-c0dd17e80946], attrValue=[c9457eb7-be69-4eb9-84d7-3f33725cb32f], matches=false
+2026-04-08 01:06:32,519 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "2bfa0da3-8402-4220-a3bc-c0dd17e80946"]: attrName=[sub], rawValue=[2bfa0da3-8402-4220-a3bc-c0dd17e80946], attrValue=[2bfa0da3-8402-4220-a3bc-c0dd17e80946], matches=true
+2026-04-08 01:06:32,520 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:06:32,521 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:06:32,521 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:06:32,522 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,526 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,531 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:06:32,535 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,539 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:06:32,544 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:06:32,545 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,549 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:06:32,554 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: DeleteUserPool
+2026-04-08 01:07:03,870 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPool
+2026-04-08 01:07:03,984 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool: us-east-1_c739f7507
+2026-04-08 01:07:03,992 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: CreateUserPoolClient
+2026-04-08 01:07:03,993 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created User Pool Client: 481f126ab4ac4a3b92089184cb for pool us-east-1_c739f7507
+2026-04-08 01:07:03,996 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:07:03,996 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_c739f7507
+2026-04-08 01:07:03,998 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:07:03,998 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_c739f7507 (permanent=true)
+2026-04-08 01:07:04,000 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:07:04,002 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminCreateUser
+2026-04-08 01:07:04,002 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Created user [email protected] in pool us-east-1_c739f7507
+2026-04-08 01:07:04,005 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,008 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,010 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:07:04,011 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_c739f7507 (permanent=false)
+2026-04-08 01:07:04,012 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,013 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,015 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:07:04,015 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_c739f7507 (permanent=true)
+2026-04-08 01:07:04,016 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,021 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,026 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,030 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,050 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:07:04,051 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminGetUser
+2026-04-08 01:07:04,053 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: AdminSetUserPassword
+2026-04-08 01:07:04,053 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Set password for user [email protected] in pool us-east-1_c739f7507 (permanent=true)
+2026-04-08 01:07:04,054 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,058 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:07:04,060 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:07:04,060 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=true
+2026-04-08 01:07:04,060 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:07:04,062 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:07:04,062 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-"]: attrName=[email], rawValue=[compat-], attrValue=[[email protected]], matches=true
+2026-04-08 01:07:04,062 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email ^= "compat-"]: attrName=[email], rawValue=[compat-], attrValue=[[email protected]], matches=false
+2026-04-08 01:07:04,064 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:07:04,064 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "77b5cd65-c5f0-440a-b421-f2a9dd75c1bf"]: attrName=[sub], rawValue=[77b5cd65-c5f0-440a-b421-f2a9dd75c1bf], attrValue=[77b5cd65-c5f0-440a-b421-f2a9dd75c1bf], matches=true
+2026-04-08 01:07:04,064 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [sub = "77b5cd65-c5f0-440a-b421-f2a9dd75c1bf"]: attrName=[sub], rawValue=[77b5cd65-c5f0-440a-b421-f2a9dd75c1bf], attrValue=[ae478f1e-5e58-47b1-8b3f-c966bfbe4a1f], matches=false
+2026-04-08 01:07:04,065 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: ListUsers
+2026-04-08 01:07:04,065 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:07:04,065 INFO [io.github.hectorvent.floci.services.cognito.CognitoService] (executor-thread-1) Matching user [email protected] against filter [email = "[email protected]"]: attrName=[email], rawValue=[[email protected]], attrValue=[[email protected]], matches=false
+2026-04-08 01:07:04,066 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,071 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,075 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:07:04,079 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,084 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:07:04,088 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: GetTokensFromRefreshToken
+2026-04-08 01:07:04,089 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,094 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: InitiateAuth
+2026-04-08 01:07:04,098 INFO [io.github.hectorvent.floci.core.common.AwsJson11Controller] (executor-thread-1) AwsJson11Controller Cognito action: DeleteUserPool
+2026-04-08 01:07:07,001 INFO [io.github.hectorvent.floci.lifecycle.EmulatorLifecycle] (Shutdown thread) === AWS Local Emulator Shutting Down ===
+2026-04-08 01:07:07,002 INFO [io.github.hectorvent.floci.services.elasticache.proxy.ElastiCacheProxyManager] (Shutdown thread) Stopped all ElastiCache proxies
+2026-04-08 01:07:07,002 INFO [io.github.hectorvent.floci.services.rds.proxy.RdsProxyManager] (Shutdown thread) Stopped all RDS proxies
+2026-04-08 01:07:07,002 INFO [io.github.hectorvent.floci.lifecycle.EmulatorLifecycle] (Shutdown thread) === AWS Local Emulator Stopped ===
+2026-04-08 01:07:07,009 INFO [io.quarkus] (Shutdown thread) floci stopped in 0.016s
diff --git a/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java
index 74ddb85a86..12577731c1 100644
--- a/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java
@@ -72,6 +72,7 @@ public class CognitoJsonHandler {
case "AdminAddUserToGroup" -> handleAdminAddUserToGroup(request);
case "AdminRemoveUserFromGroup" -> handleAdminRemoveUserFromGroup(request);
case "AdminListGroupsForUser" -> handleAdminListGroupsForUser(request);
+ case "GetTokensFromRefreshToken" -> handleGetTokensFromRefreshToken(request);
default -> Response.status(400)
.entity(new AwsErrorResponse("UnsupportedOperation", "Operation " + action + " is not supported."))
.build();
@@ -285,13 +286,22 @@ public class CognitoJsonHandler {
}
private Response handleListUsers(JsonNode request) {
- List<CognitoUser> users = service.listUsers(request.path("UserPoolId").asText());
+ String filter = request.path("Filter").isMissingNode() ? null : request.path("Filter").asText(null);
+ List<CognitoUser> users = service.listUsers(request.path("UserPoolId").asText(), filter);
ObjectNode response = objectMapper.createObjectNode();
ArrayNode items = response.putArray("Users");
users.forEach(u -> items.add(userToNode(u)));
return Response.ok(response).build();
}
+ private Response handleGetTokensFromRefreshToken(JsonNode request) {
+ Map<String, Object> result = service.getTokensFromRefreshToken(
+ request.path("ClientId").asText(),
+ request.path("RefreshToken").asText()
+ );
+ return Response.ok(objectMapper.valueToTree(result)).build();
+ }
+
private Response handleInitiateAuth(JsonNode request) {
Map<String, String> params = new HashMap<>();
request.path("AuthParameters").fields().forEachRemaining(e -> params.put(e.getKey(), e.getValue().asText()));
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 ae2b13cf6f..a90c0259fd 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
@@ -296,7 +296,16 @@ public class CognitoService {
}
public CognitoUser adminGetUser(String userPoolId, String username) {
- return userStore.get(userKey(userPoolId, username))
+ Optional<CognitoUser> byKey = userStore.get(userKey(userPoolId, username));
+ if (byKey.isPresent()) {
+ return byKey.get();
+ }
+ // Fallback: resolve by sub UUID or email alias
+ String prefix = userPoolId + "::";
+ return userStore.scan(k -> k.startsWith(prefix)).stream()
+ .filter(u -> username.equals(u.getAttributes().get("sub"))
+ || username.equals(u.getAttributes().get("email")))
+ .findFirst()
.orElseThrow(() -> new AwsException("UserNotFoundException", "User not found", 404));
}
@@ -304,12 +313,12 @@ public class CognitoService {
CognitoUser user = adminGetUser(userPoolId, username);
for (String groupName : new ArrayList<>(user.getGroupNames())) {
groupStore.get(groupKey(userPoolId, groupName)).ifPresent(group -> {
- group.removeUserName(username);
+ group.removeUserName(user.getUsername());
group.setLastModifiedDate(System.currentTimeMillis() / 1000L);
groupStore.put(groupKey(userPoolId, groupName), group);
});
}
- userStore.delete(userKey(userPoolId, username));
+ userStore.delete(userKey(userPoolId, user.getUsername()));
}
public void adminSetUserPassword(String userPoolId, String username, String password, boolean permanent) {
@@ -318,20 +327,55 @@ public class CognitoService {
user.setTemporaryPassword(!permanent);
user.setUserStatus(permanent ? "CONFIRMED" : "FORCE_CHANGE_PASSWORD");
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);
- userStore.put(userKey(userPoolId, username), user);
- LOG.infov("Set password for user {0} in pool {1} (permanent={2})", username, userPoolId, permanent);
+ userStore.put(userKey(userPoolId, user.getUsername()), user);
+ LOG.infov("Set password for user {0} in pool {1} (permanent={2})", user.getUsername(), userPoolId, permanent);
}
public void adminUpdateUserAttributes(String userPoolId, String username, Map<String, String> attributes) {
CognitoUser user = adminGetUser(userPoolId, username);
user.getAttributes().putAll(attributes);
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);
- userStore.put(userKey(userPoolId, username), user);
+ userStore.put(userKey(userPoolId, user.getUsername()), user);
}
- public List<CognitoUser> listUsers(String userPoolId) {
+ public List<CognitoUser> listUsers(String userPoolId, String filter) {
String prefix = userPoolId + "::";
- return userStore.scan(k -> k.startsWith(prefix));
+ List<CognitoUser> all = userStore.scan(k -> k.startsWith(prefix));
+ if (filter == null || filter.isBlank()) {
+ return all;
+ }
+ return all.stream().filter(u -> matchesUserFilter(u, filter)).toList();
+ }
+
+ private boolean matchesUserFilter(CognitoUser user, String filter) {
+ String originalFilter = filter;
+ filter = filter.trim();
+ boolean startsWithOp = filter.contains("^=");
+ int opIdx = startsWithOp ? filter.indexOf("^=") : filter.indexOf('=');
+ if (opIdx < 0) {
+ throw new AwsException("InvalidParameterException", "Invalid filter expression: " + filter, 400);
+ }
+ String attrName = filter.substring(0, opIdx).trim();
+ String rawValue = filter.substring(opIdx + (startsWithOp ? 2 : 1)).trim();
+ if (rawValue.length() >= 2 && rawValue.startsWith("\"") && rawValue.endsWith("\"")) {
+ rawValue = rawValue.substring(1, rawValue.length() - 1);
+ }
+ String attrValue = getUserAttribute(user, attrName);
+ boolean matches = false;
+ if (attrValue != null) {
+ matches = startsWithOp ? attrValue.startsWith(rawValue) : attrValue.equals(rawValue);
+ }
+ LOG.infov("Matching user {0} against filter [{1}]: attrName=[{2}], rawValue=[{3}], attrValue=[{4}], matches={5}",
+ user.getUsername(), originalFilter, attrName, rawValue, attrValue, matches);
+ return matches;
+ }
+
+ private String getUserAttribute(CognitoUser user, String attrName) {
+ return switch (attrName) {
+ case "username" -> user.getUsername();
+ case "cognito:user_status", "status" -> user.getUserStatus();
+ default -> user.getAttributes().get(attrName);
+ };
}
// ──────────────────────────── Groups ────────────────────────────
@@ -378,7 +422,7 @@ public class CognitoService {
userStore.get(userKey(userPoolId, username)).ifPresent(user -> {
if (user.getGroupNames().remove(groupName)) {
user.setLastModifiedDate(now);
- userStore.put(userKey(userPoolId, username), user);
+ userStore.put(userKey(userPoolId, user.getUsername()), user);
}
});
}
@@ -390,14 +434,14 @@ public class CognitoService {
CognitoGroup group = getGroup(userPoolId, groupName);
CognitoUser user = adminGetUser(userPoolId, username);
long now = System.currentTimeMillis() / 1000L;
- if (group.addUserName(username)) {
+ if (group.addUserName(user.getUsername())) {
group.setLastModifiedDate(now);
groupStore.put(groupKey(userPoolId, groupName), group);
}
if (!user.getGroupNames().contains(groupName)) {
user.getGroupNames().add(groupName);
user.setLastModifiedDate(now);
- userStore.put(userKey(userPoolId, username), user);
+ userStore.put(userKey(userPoolId, user.getUsername()), user);
}
}
@@ -405,13 +449,13 @@ public class CognitoService {
CognitoGroup group = getGroup(userPoolId, groupName);
CognitoUser user = adminGetUser(userPoolId, username);
long now = System.currentTimeMillis() / 1000L;
- if (group.removeUserName(username)) {
+ if (group.removeUserName(user.getUsername())) {
group.setLastModifiedDate(now);
groupStore.put(groupKey(userPoolId, groupName), group);
}
if (user.getGroupNames().remove(groupName)) {
user.setLastModifiedDate(now);
- userStore.put(userKey(userPoolId, username), user);
+ userStore.put(userKey(userPoolId, user.getUsername()), user);
}
}
@@ -461,7 +505,7 @@ public class CognitoService {
CognitoUser user = adminGetUser(client.getUserPoolId(), username);
user.setUserStatus("CONFIRMED");
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);
- userStore.put(userKey(client.getUserPoolId(), username), user);
+ userStore.put(userKey(client.getUserPoolId(), user.getUsername()), user);
}
// ──────────────────────────── Auth ────────────────────────────
@@ -473,7 +517,7 @@ public class CognitoService {
return switch (authFlow) {
case "USER_PASSWORD_AUTH" -> authenticateWithPassword(pool, authParameters, clientId);
- case "REFRESH_TOKEN_AUTH", "REFRESH_TOKEN" -> handleRefreshToken(pool, authParameters);
+ case "REFRESH_TOKEN_AUTH", "REFRESH_TOKEN" -> handleRefreshToken(pool, authParameters, clientId);
default -> {
// For other flows (USER_SRP_AUTH, etc.), if user exists return tokens
String username = authParameters.get("USERNAME");
@@ -482,7 +526,7 @@ public class CognitoService {
}
CognitoUser user = adminGetUser(pool.getId(), username);
Map<String, Object> result = new HashMap<>();
- result.put("AuthenticationResult", generateAuthResult(user, pool));
+ result.put("AuthenticationResult", generateAuthResult(user, pool, clientId));
yield result;
}
};
@@ -496,12 +540,12 @@ public class CognitoService {
return switch (authFlow) {
case "ADMIN_USER_PASSWORD_AUTH", "USER_PASSWORD_AUTH" ->
authenticateWithPassword(pool, authParameters, clientId);
- case "REFRESH_TOKEN_AUTH", "REFRESH_TOKEN" -> handleRefreshToken(pool, authParameters);
+ case "REFRESH_TOKEN_AUTH", "REFRESH_TOKEN" -> handleRefreshToken(pool, authParameters, clientId);
default -> {
String username = authParameters.get("USERNAME");
CognitoUser user = adminGetUser(userPoolId, username);
Map<String, Object> result = new HashMap<>();
- result.put("AuthenticationResult", generateAuthResult(user, pool));
+ result.put("AuthenticationResult", generateAuthResult(user, pool, clientId));
yield result;
}
};
@@ -522,7 +566,7 @@ public class CognitoService {
adminSetUserPassword(pool.getId(), username, newPassword, true);
CognitoUser user = adminGetUser(pool.getId(), username);
Map<String, Object> result = new HashMap<>();
- result.put("AuthenticationResult", generateAuthResult(user, pool));
+ result.put("AuthenticationResult", generateAuthResult(user, pool, clientId));
return result;
}
@@ -545,7 +589,7 @@ public class CognitoService {
user.setTemporaryPassword(false);
user.setUserStatus("CONFIRMED");
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);
- userStore.put(userKey(poolId, username), user);
+ userStore.put(userKey(poolId, user.getUsername()), user);
}
public void forgotPassword(String clientId, String username) {
@@ -636,7 +680,7 @@ public class CognitoService {
throw new AwsException("UserNotConfirmedException", "User is not confirmed", 400);
}
- if (user.getPasswordHash() != null && !user.getPasswordHash().equals(hashPassword(password))) {
+ if (user.getPasswordHash() == null || !user.getPasswordHash().equals(hashPassword(password))) {
throw new AwsException("NotAuthorizedException", "Incorrect username or password", 400);
}
@@ -655,18 +699,32 @@ public class CognitoService {
}
Map<String, Object> result = new HashMap<>();
- result.put("AuthenticationResult", generateAuthResult(user, pool));
+ result.put("AuthenticationResult", generateAuthResult(user, pool, clientId));
return result;
}
- private Map<String, Object> handleRefreshToken(UserPool pool, Map<String, String> params) {
- // In the emulator, accept any refresh token and return new tokens
- // A real implementation would validate the refresh token
+ private Map<String, Object> handleRefreshToken(UserPool pool, Map<String, String> params, String clientId) {
String refreshToken = params.get("REFRESH_TOKEN");
if (refreshToken == null) {
throw new AwsException("InvalidParameterException", "REFRESH_TOKEN is required", 400);
}
- // We can't look up the user from a stub refresh token, so return a minimal result
+ String[] parts = parseRefreshToken(refreshToken);
+ if (parts != null) {
+ String username = parts[1];
+ String tokenClientId = parts[2];
+ try {
+ CognitoUser user = adminGetUser(pool.getId(), username);
+ Map<String, Object> auth = new HashMap<>();
+ auth.put("AccessToken", generateSignedJwt(user, pool, "access", tokenClientId));
+ auth.put("IdToken", generateSignedJwt(user, pool, "id", tokenClientId));
+ auth.put("ExpiresIn", 3600);
+ auth.put("TokenType", "Bearer");
+ Map<String, Object> result = new HashMap<>();
+ result.put("AuthenticationResult", auth);
+ return result;
+ } catch (AwsException ignored) { }
+ }
+ // Fallback for legacy tokens: emit minimal tokens using clientId from request
Map<String, Object> auth = new HashMap<>();
auth.put("AccessToken", generateTokenString("access", "unknown", pool));
auth.put("IdToken", generateTokenString("id", "unknown", pool));
@@ -677,17 +735,44 @@ public class CognitoService {
return result;
}
- private Map<String, Object> generateAuthResult(CognitoUser user, UserPool pool) {
+ public Map<String, Object> getTokensFromRefreshToken(String clientId, String refreshToken) {
+ if (refreshToken == null) {
+ throw new AwsException("InvalidParameterException", "RefreshToken is required", 400);
+ }
+ UserPoolClient client = clientStore.get(clientId)
+ .orElseThrow(() -> new AwsException("ResourceNotFoundException", "Client not found", 404));
+ String[] parts = parseRefreshToken(refreshToken);
+ if (parts == null) {
+ throw new AwsException("NotAuthorizedException", "Invalid refresh token", 400);
+ }
+ String poolId = parts[0];
+ String username = parts[1];
+ if (!client.getUserPoolId().equals(poolId)) {
+ throw new AwsException("NotAuthorizedException", "Invalid refresh token", 400);
+ }
+ UserPool pool = describeUserPool(poolId);
+ CognitoUser user = adminGetUser(poolId, username);
+ Map<String, Object> auth = new HashMap<>();
+ auth.put("AccessToken", generateSignedJwt(user, pool, "access", clientId));
+ auth.put("IdToken", generateSignedJwt(user, pool, "id", clientId));
+ auth.put("ExpiresIn", 3600);
+ auth.put("TokenType", "Bearer");
+ Map<String, Object> result = new HashMap<>();
+ result.put("AuthenticationResult", auth);
+ return result;
+ }
+
+ private Map<String, Object> generateAuthResult(CognitoUser user, UserPool pool, String clientId) {
Map<String, Object> auth = new HashMap<>();
- auth.put("AccessToken", generateSignedJwt(user, pool, "access"));
- auth.put("IdToken", generateSignedJwt(user, pool, "id"));
- auth.put("RefreshToken", UUID.randomUUID().toString());
+ auth.put("AccessToken", generateSignedJwt(user, pool, "access", clientId));
+ auth.put("IdToken", generateSignedJwt(user, pool, "id", clientId));
+ auth.put("RefreshToken", buildRefreshToken(pool.getId(), user.getUsername(), clientId));
auth.put("ExpiresIn", 3600);
auth.put("TokenType", "Bearer");
return auth;
}
- private String generateSignedJwt(CognitoUser user, UserPool pool, String type) {
+ private String generateSignedJwt(CognitoUser user, UserPool pool, String type, String clientId) {
String headerJson = String.format(
"{\"alg\":\"RS256\",\"typ\":\"JWT\",\"kid\":\"%s\"}",
escapeJson(getSigningKeyId(pool)));
@@ -704,13 +789,16 @@ public class CognitoService {
groupsFragment = ",\"cognito:groups\":" + groupsJson;
}
String sub = user.getAttributes().getOrDefault("sub", user.getUsername());
+ String clientIdFragment = (clientId != null && !clientId.isBlank() && "access".equals(type))
+ ? ",\"client_id\":\"" + escapeJson(clientId) + "\""
+ : "";
String payloadJson = String.format(
"{\"sub\":\"%s\",\"event_id\":\"%s\",\"token_use\":\"%s\",\"auth_time\":%d," +
"\"iss\":\"%s\",\"exp\":%d,\"iat\":%d," +
- "\"username\":\"%s\",\"email\":\"%s\",\"cognito:username\":\"%s\"%s}",
+ "\"username\":\"%s\",\"email\":\"%s\",\"cognito:username\":\"%s\"%s%s}",
escapeJson(sub), UUID.randomUUID(), type, now,
escapeJson(getIssuer(pool.getId())), now + 3600, now,
- user.getUsername(), email, user.getUsername(), groupsFragment
+ user.getUsername(), email, user.getUsername(), clientIdFragment, groupsFragment
);
String payload = Base64.getUrlEncoder().withoutPadding()
.encodeToString(payloadJson.getBytes(StandardCharsets.UTF_8));
@@ -984,6 +1072,23 @@ public class CognitoService {
return Base64.getEncoder().encodeToString(raw.getBytes(StandardCharsets.UTF_8));
}
+ private String buildRefreshToken(String poolId, String username, String clientId) {
+ String raw = poolId + "|" + username + "|" + clientId + "|" + UUID.randomUUID();
+ return Base64.getEncoder().withoutPadding().encodeToString(raw.getBytes(StandardCharsets.UTF_8));
+ }
+
+ private String[] parseRefreshToken(String refreshToken) {
+ try {
+ byte[] decoded = Base64.getDecoder().decode(refreshToken);
+ String raw = new String(decoded, StandardCharsets.UTF_8);
+ String[] parts = raw.split("\\|", 4);
+ if (parts.length == 4) {
+ return parts; // [poolId, username, clientId, nonce]
+ }
+ } catch (Exception ignored) { }
+ return null;
+ }
+
private String extractUsernameFromToken(String token) {
try {
String[] parts = token.split("\\.");
diff --git a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoIntegrationTest.java
index c491f70d5d..b7bc724f1a 100644
--- a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoIntegrationTest.java
@@ -331,6 +331,173 @@ class CognitoIntegrationTest {
.statusCode(404);
}
+ // ── Issue #228: AccessToken contains client_id ─────────────────────
+
+ @Test
+ @Order(30)
+ void accessTokenContainsClientId() throws Exception {
+ String token = initiateAuthAndGetAccessToken();
+ JsonNode payload = decodeJwtPayload(token);
+ assertEquals(clientId, payload.path("client_id").asText(),
+ "AccessToken must contain client_id matching the requesting client");
+ }
+
+ @Test
+ @Order(31)
+ void idTokenDoesNotContainClientId() throws Exception {
+ JsonNode auth = cognitoJson("InitiateAuth", """
+ {
+ "ClientId": "%s",
+ "AuthFlow": "USER_PASSWORD_AUTH",
+ "AuthParameters": { "USERNAME": "%s", "PASSWORD": "%s" }
+ }
+ """.formatted(clientId, username, password));
+ String idToken = auth.path("AuthenticationResult").path("IdToken").asText();
+ JsonNode payload = decodeJwtPayload(idToken);
+ assertTrue(payload.path("client_id").isMissingNode(),
+ "IdToken should not contain client_id");
+ }
+
+ // ── Issue #229: Password verification ──────────────────────────────
+
+ @Test
+ @Order(40)
+ void initiateAuthRejectsWrongPassword() {
+ cognitoAction("InitiateAuth", """
+ {
+ "ClientId": "%s",
+ "AuthFlow": "USER_PASSWORD_AUTH",
+ "AuthParameters": { "USERNAME": "%s", "PASSWORD": "WrongPassword!" }
+ }
+ """.formatted(clientId, username))
+ .then()
+ .statusCode(400);
+ }
+
+ // ── Issue #220: Lookup by sub and email ─────────────────────────────
+
+ @Test
+ @Order(50)
+ void adminGetUserBySubUuid() throws Exception {
+ JsonNode user = cognitoJson("AdminGetUser", """
+ { "UserPoolId": "%s", "Username": "%s" }
+ """.formatted(poolId, username));
+ String sub = null;
+ for (JsonNode attr : user.path("UserAttributes")) {
+ if ("sub".equals(attr.path("Name").asText())) {
+ sub = attr.path("Value").asText();
+ break;
+ }
+ }
+ assertNotNull(sub, "User should have a sub attribute");
+
+ JsonNode bySubUser = cognitoJson("AdminGetUser", """
+ { "UserPoolId": "%s", "Username": "%s" }
+ """.formatted(poolId, sub));
+ assertEquals(username, bySubUser.path("Username").asText(),
+ "AdminGetUser with sub UUID should return the same user");
+ }
+
+ @Test
+ @Order(51)
+ void adminGetUserByEmailAlias() throws Exception {
+ JsonNode byEmail = cognitoJson("AdminGetUser", """
+ { "UserPoolId": "%s", "Username": "%s" }
+ """.formatted(poolId, username));
+ assertEquals(username, byEmail.path("Username").asText());
+ }
+
+ // ── Issue #233: ListUsers Filter ─────────────────────────────────────
+
+ @Test
+ @Order(60)
+ void listUsersFilterByEmailExactMatch() throws Exception {
+ JsonNode resp = cognitoJson("ListUsers", """
+ {
+ "UserPoolId": "%s",
+ "Filter": "email = \\"%s\\""
+ }
+ """.formatted(poolId, username));
+ assertEquals(1, resp.path("Users").size(),
+ "Filter by email should return exactly one matching user");
+ assertEquals(username, resp.path("Users").get(0).path("Username").asText());
+ }
+
+ @Test
+ @Order(61)
+ void listUsersFilterByEmailPrefixStartsWith() throws Exception {
+ String prefix = username.substring(0, 5);
+ JsonNode resp = cognitoJson("ListUsers", """
+ {
+ "UserPoolId": "%s",
+ "Filter": "email ^= \\"%s\\""
+ }
+ """.formatted(poolId, prefix));
+ assertTrue(resp.path("Users").size() >= 1,
+ "Prefix filter should return at least the test user");
+ }
+
+ @Test
+ @Order(62)
+ void listUsersNoFilterReturnsAll() throws Exception {
+ JsonNode resp = cognitoJson("ListUsers", """
+ { "UserPoolId": "%s" }
+ """.formatted(poolId));
+ assertTrue(resp.path("Users").size() >= 1);
+ }
+
+ // ── Issue #234: GetTokensFromRefreshToken ────────────────────────────
+
+ @Test
+ @Order(70)
+ void getTokensFromRefreshTokenReturnsAccessAndIdToken() throws Exception {
+ JsonNode authResp = cognitoJson("InitiateAuth", """
+ {
+ "ClientId": "%s",
+ "AuthFlow": "USER_PASSWORD_AUTH",
+ "AuthParameters": { "USERNAME": "%s", "PASSWORD": "%s" }
+ }
+ """.formatted(clientId, username, password));
+ String refreshToken = authResp.path("AuthenticationResult").path("RefreshToken").asText();
+ assertNotNull(refreshToken);
+
+ JsonNode refreshResp = cognitoJson("GetTokensFromRefreshToken", """
+ {
+ "ClientId": "%s",
+ "RefreshToken": "%s"
+ }
+ """.formatted(clientId, refreshToken));
+
+ assertNotNull(refreshResp.path("AuthenticationResult").path("AccessToken").asText(null));
+ assertNotNull(refreshResp.path("AuthenticationResult").path("IdToken").asText(null));
+ assertTrue(refreshResp.path("AuthenticationResult").path("RefreshToken").isMissingNode(),
+ "GetTokensFromRefreshToken should not return a new RefreshToken");
+ }
+
+ @Test
+ @Order(71)
+ void refreshTokenAuthFlowReturnsNewTokens() throws Exception {
+ JsonNode authResp = cognitoJson("InitiateAuth", """
+ {
+ "ClientId": "%s",
+ "AuthFlow": "USER_PASSWORD_AUTH",
+ "AuthParameters": { "USERNAME": "%s", "PASSWORD": "%s" }
+ }
+ """.formatted(clientId, username, password));
+ String refreshToken = authResp.path("AuthenticationResult").path("RefreshToken").asText();
+
+ JsonNode refreshed = cognitoJson("InitiateAuth", """
+ {
+ "ClientId": "%s",
+ "AuthFlow": "REFRESH_TOKEN_AUTH",
+ "AuthParameters": { "REFRESH_TOKEN": "%s" }
+ }
+ """.formatted(clientId, refreshToken));
+
+ assertNotNull(refreshed.path("AuthenticationResult").path("AccessToken").asText(null));
+ assertNotNull(refreshed.path("AuthenticationResult").path("IdToken").asText(null));
+ }
+
// ── Helpers ───────────────────────────────────────────────────────
private static Response cognitoAction(String action, String body) {
@@ -380,6 +547,17 @@ class CognitoIntegrationTest {
return signature.verify(Base64.getUrlDecoder().decode(padBase64(parts[2])));
}
+ private static String initiateAuthAndGetAccessToken() throws Exception {
+ JsonNode auth = cognitoJson("InitiateAuth", """
+ {
+ "ClientId": "%s",
+ "AuthFlow": "USER_PASSWORD_AUTH",
+ "AuthParameters": { "USERNAME": "%s", "PASSWORD": "%s" }
+ }
+ """.formatted(clientId, username, password));
+ return auth.path("AuthenticationResult").path("AccessToken").asText();
+ }
+
private static String padBase64(String value) {
int remainder = value.length() % 4;
if (remainder == 0) {
diff --git a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoServiceTest.java
index 5e8ec01975..da4a6c9d6c 100644
--- a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoServiceTest.java
@@ -397,6 +397,254 @@ class CognitoServiceTest {
() -> service.adminUserGlobalSignOut(pool.getId(), "ghost"));
}
+ // =========================================================================
+ // Issue #229 — password verification
+ // =========================================================================
+
+ @Test
+ void initiateAuthRejectsAnyPasswordWhenNoHashSet() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "bob", Map.of("email", "[email protected]"), null);
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ AwsException ex = assertThrows(AwsException.class, () ->
+ service.initiateAuth(client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "bob", "PASSWORD", "anything")));
+ assertEquals("NotAuthorizedException", ex.getErrorCode());
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void initiateAuthWorksAfterPasswordIsSet() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "bob", Map.of("email", "[email protected]"), null);
+ service.adminSetUserPassword(pool.getId(), "bob", "Perm1!", true);
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ Map<String, Object> result = service.initiateAuth(client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "bob", "PASSWORD", "Perm1!"));
+ assertNotNull(((Map<String, Object>) result.get("AuthenticationResult")).get("AccessToken"));
+ }
+
+ // =========================================================================
+ // Issue #235 — AdminSetUserPassword(Permanent=false) changes the password
+ // =========================================================================
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void adminSetUserPasswordPermanentFalseChangesPassword() {
+ UserPool pool = createPoolAndUser(); // alice has permanent "Perm1234!"
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ service.adminSetUserPassword(pool.getId(), "alice", "NewTemp1!", false);
+
+ // Old password now rejected
+ assertThrows(AwsException.class, () ->
+ service.initiateAuth(client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!")));
+
+ // New temp password triggers NEW_PASSWORD_REQUIRED challenge
+ Map<String, Object> result = service.initiateAuth(client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "NewTemp1!"));
+ assertEquals("NEW_PASSWORD_REQUIRED", result.get("ChallengeName"));
+ }
+
+ // =========================================================================
+ // Issue #228 — AccessToken contains client_id claim
+ // =========================================================================
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void accessTokenContainsClientId() {
+ UserPool pool = createPoolAndUser();
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ Map<String, Object> authResult = service.initiateAuth(
+ client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!"));
+ Map<String, Object> auth = (Map<String, Object>) authResult.get("AuthenticationResult");
+ String accessToken = (String) auth.get("AccessToken");
+
+ String payloadJson = new String(Base64.getUrlDecoder().decode(accessToken.split("\\.")[1]),
+ StandardCharsets.UTF_8);
+ assertTrue(payloadJson.contains("\"client_id\":\"" + client.getClientId() + "\""),
+ "AccessToken should contain client_id claim matching the requesting client");
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void idTokenDoesNotContainClientId() {
+ UserPool pool = createPoolAndUser();
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ Map<String, Object> authResult = service.initiateAuth(
+ client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!"));
+ Map<String, Object> auth = (Map<String, Object>) authResult.get("AuthenticationResult");
+ String idToken = (String) auth.get("IdToken");
+
+ String payloadJson = new String(Base64.getUrlDecoder().decode(idToken.split("\\.")[1]),
+ StandardCharsets.UTF_8);
+ assertFalse(payloadJson.contains("\"client_id\""),
+ "IdToken should not contain client_id claim");
+ }
+
+ // =========================================================================
+ // Issue #220 — adminGetUser resolves sub UUID and email aliases
+ // =========================================================================
+
+ @Test
+ void adminGetUserBySubUuid() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "bob", Map.of("email", "[email protected]"), null);
+
+ String sub = service.adminGetUser(pool.getId(), "bob").getAttributes().get("sub");
+ assertNotNull(sub);
+
+ CognitoUser found = service.adminGetUser(pool.getId(), sub);
+ assertEquals("bob", found.getUsername());
+ }
+
+ @Test
+ void adminGetUserByEmailAlias() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "bob", Map.of("email", "[email protected]"), null);
+
+ CognitoUser found = service.adminGetUser(pool.getId(), "[email protected]");
+ assertEquals("bob", found.getUsername());
+ }
+
+ // =========================================================================
+ // Issue #233 — listUsers Filter
+ // =========================================================================
+
+ @Test
+ void listUsersNoFilterReturnsAll() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "user1", Map.of("email", "[email protected]"), null);
+ service.adminCreateUser(pool.getId(), "user2", Map.of("email", "[email protected]"), null);
+
+ assertEquals(2, service.listUsers(pool.getId(), null).size());
+ }
+
+ @Test
+ void listUsersFilterBySubExactMatch() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "user1", Map.of("email", "[email protected]"), null);
+ service.adminCreateUser(pool.getId(), "user2", Map.of("email", "[email protected]"), null);
+
+ String sub2 = service.adminGetUser(pool.getId(), "user2").getAttributes().get("sub");
+ List<CognitoUser> result = service.listUsers(pool.getId(), "sub = \"" + sub2 + "\"");
+
+ assertEquals(1, result.size());
+ assertEquals("user2", result.get(0).getUsername());
+ }
+
+ @Test
+ void listUsersFilterByEmailExactMatch() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "user1", Map.of("email", "[email protected]"), null);
+ service.adminCreateUser(pool.getId(), "user2", Map.of("email", "[email protected]"), null);
+
+ List<CognitoUser> result = service.listUsers(pool.getId(), "email = \"[email protected]\"");
+ assertEquals(1, result.size());
+ assertEquals("user1", result.get(0).getUsername());
+ }
+
+ @Test
+ void listUsersFilterByEmailPrefix() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "user1", Map.of("email", "[email protected]"), null);
+ service.adminCreateUser(pool.getId(), "user2", Map.of("email", "[email protected]"), null);
+ service.adminCreateUser(pool.getId(), "user3", Map.of("email", "[email protected]"), null);
+
+ List<CognitoUser> result = service.listUsers(pool.getId(), "email ^= \"alice\"");
+ assertEquals(2, result.size());
+ }
+
+ @Test
+ void listUsersFilterNoMatchReturnsEmpty() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ service.adminCreateUser(pool.getId(), "user1", Map.of("email", "[email protected]"), null);
+
+ List<CognitoUser> result = service.listUsers(pool.getId(), "email = \"[email protected]\"");
+ assertTrue(result.isEmpty());
+ }
+
+ // =========================================================================
+ // Issue #234 — GetTokensFromRefreshToken
+ // =========================================================================
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void refreshTokenIsStructuredAndDecodable() {
+ UserPool pool = createPoolAndUser();
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ Map<String, Object> authResult = service.initiateAuth(
+ client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!"));
+ Map<String, Object> auth = (Map<String, Object>) authResult.get("AuthenticationResult");
+ String refreshToken = (String) auth.get("RefreshToken");
+
+ assertNotNull(refreshToken);
+ // Should be parseable as base64 structured token
+ String decoded = new String(Base64.getDecoder().decode(refreshToken), StandardCharsets.UTF_8);
+ String[] parts = decoded.split("\\|", 4);
+ assertEquals(4, parts.length, "Refresh token should encode 4 pipe-separated fields");
+ assertEquals(pool.getId(), parts[0]);
+ assertEquals("alice", parts[1]);
+ assertEquals(client.getClientId(), parts[2]);
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void getTokensFromRefreshTokenReturnsNewAccessAndIdTokens() {
+ UserPool pool = createPoolAndUser();
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ Map<String, Object> authResult = service.initiateAuth(
+ client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!"));
+ String refreshToken = (String) ((Map<String, Object>) authResult.get("AuthenticationResult")).get("RefreshToken");
+
+ Map<String, Object> refreshResult = service.getTokensFromRefreshToken(client.getClientId(), refreshToken);
+ Map<String, Object> refreshAuth = (Map<String, Object>) refreshResult.get("AuthenticationResult");
+
+ assertNotNull(refreshAuth.get("AccessToken"), "Should return a new AccessToken");
+ assertNotNull(refreshAuth.get("IdToken"), "Should return a new IdToken");
+ assertNull(refreshAuth.get("RefreshToken"), "GetTokensFromRefreshToken should not return a new RefreshToken");
+ }
+
+ @Test
+ void getTokensFromRefreshTokenInvalidTokenThrows() {
+ UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ assertThrows(AwsException.class, () ->
+ service.getTokensFromRefreshToken(client.getClientId(), "not-a-valid-refresh-token"));
+ }
+
+ @Test
+ void refreshTokenAuthFlowReturnsNewTokens() {
+ UserPool pool = createPoolAndUser();
+ UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> firstAuth = (Map<String, Object>) service.initiateAuth(
+ client.getClientId(), "USER_PASSWORD_AUTH",
+ Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!")).get("AuthenticationResult");
+ String refreshToken = (String) firstAuth.get("RefreshToken");
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> refreshed = (Map<String, Object>) service.initiateAuth(
+ client.getClientId(), "REFRESH_TOKEN_AUTH",
+ Map.of("REFRESH_TOKEN", refreshToken)).get("AuthenticationResult");
+
+ assertNotNull(refreshed.get("AccessToken"));
+ assertNotNull(refreshed.get("IdToken"));
+ }
+
// =========================================================================
// deleteUserPool cascades groups
// =========================================================================