feat(cognito): add GetUserAuthFactors (#4764)

* feat(cognito): add GetUserAuthFactors

* fix(cognito): refuse access tokens with no scope claim where a scope is required

* fix(cognito): use AWS's message for a missing access-token scope
This commit is contained in:
jwoa95 authored and GitHub committed 2026-09-30 21:45:10 -05:00
1 parent a0be062f9f
commit 31038ee2a4
9 files changed
+666 -22

No files matched your search

@@ -322,6 +322,27 @@ class CognitoFeaturesTest {
.isTrue();
}
// ── Issue #4760: GetUserAuthFactors ──────────────────────────────────────
@Test
@Order(34)
void getUserAuthFactorsListsPasswordAndVerifiedEmail() {
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();
GetUserAuthFactorsResponse factors = cognito.getUserAuthFactors(b -> b.accessToken(accessToken));
assertThat(factors.username())
.isEqualTo(cognito.getUser(b -> b.accessToken(accessToken)).username());
assertThat(factors.configuredUserAuthFactors())
.containsExactly(AuthFactorType.PASSWORD, AuthFactorType.EMAIL_OTP);
assertThat(factors.preferredMfaSetting()).isNull();
assertThat(factors.hasUserMFASettingList()).isFalse();
}
// ── Issue #220 — AdminGetUser accepts sub UUID and email as Username ───────
@Test