fix(cognito): return sub UUID as UserSub in SignUp response (#351)

The SignUp handler was returning the username (email) as UserSub instead
of the generated UUID. Real AWS Cognito returns the user's immutable sub
attribute, and SDKs/terraform rely on this to get a stable identifier.

CognitoService.signUp already generates and stores the sub UUID on the
user, so the fix is a one-line handler change plus a handler-level test
that asserts UserSub is a UUID, not the username.

Fixes #346
This commit is contained in:
TiM authored and GitHub committed 2026-04-11 11:34:57 -05:00
1 parent 3d3f12d912
commit a067db0117
2 files changed
+34 -1

No files matched your search

@@ -352,7 +352,7 @@ public class CognitoJsonHandler {
);
ObjectNode response = objectMapper.createObjectNode();
response.put("UserConfirmed", "CONFIRMED".equals(user.getUserStatus()));
response.put("UserSub", user.getUsername());
response.put("UserSub", user.getAttributes().get("sub"));
ObjectNode delivery = response.putObject("CodeDeliveryDetails");
delivery.put("AttributeName", "email");
delivery.put("DeliveryMedium", "EMAIL");