fix(cognito): hide unknown users in password authentication (#8005) (#8103)

This commit is contained in:
jwoa95 authored and GitHub committed 2026-11-12 09:48:13 -04:00
1 parent c888c636b3
commit 13ab84ed9f
5 files changed
+164 -6

No files matched your search

@@ -732,7 +732,12 @@ final class CognitoAuthFlowHandler {
if (!"UserNotFoundException".equals(ae.getErrorCode())) throw ae;
user = tryUserMigration(pool, client, username, password, null, clientMetadata,
"UserMigration_Authentication");
if (user == null) throw ae;
if (user == null) {
if ("ENABLED".equals(client.getPreventUserExistenceErrors())) {
throw new AwsException("NotAuthorizedException", INCORRECT_CREDENTIALS, 400);
}
throw ae;
}
}
firePreAuthentication(pool, client, user, null, clientMetadata, false);