mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cognito): report EXTERNAL_PROVIDER status for federated users (#7553)
Federated users provisioned via the hosted UI were reported with UserStatus CONFIRMED. AWS reports EXTERNAL_PROVIDER for users that sign in with a third-party identity provider. - Set user status to EXTERNAL_PROVIDER in provisionFederatedUser - Update test assertion accordingly Closes #7545 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> fix(cognito): preserve status of linked and permanent-password federated users Addresses qodo review: provisionFederatedUser no longer overwrites EXTERNAL_PROVIDER on linked local profiles or federated profiles that had a permanent password assigned. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> fix(cognito): track auto-provisioned status to preserve linked users on re-sign-in Use a persisted federatedAutoProvisioned flag instead of overwriting federatedProviderName, so linked profiles and permanent-password users keep their status across repeated federated sign-ins. Addresses pgermosen review. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> test(cognito): add re-sign-in status preservation tests Covers linked profile re-sign-in and permanent-password profile re-sign-in. Addresses pgermosen review. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
cb07f9f773
commit
ad8c35888f
3 files changed
+58
-2
No files matched your search
@@ -333,7 +333,7 @@ class CognitoFederationServiceTest {
|
||||
CognitoUser user = cognitoService.adminGetUser(pool.getId(), storedCode.userId());
|
||||
|
||||
assertEquals(pool.getId(), user.getUserPoolId());
|
||||
assertEquals("CONFIRMED", user.getUserStatus());
|
||||
assertEquals("EXTERNAL_PROVIDER", user.getUserStatus());
|
||||
assertTrue(user.isEnabled());
|
||||
assertFalse(user.getUsername().isBlank());
|
||||
assertNotNull(user.getAttributes().get("sub"));
|
||||
@@ -543,6 +543,44 @@ class CognitoFederationServiceTest {
|
||||
.noneMatch(u -> "Google_google-subject".equals(u.getUsername())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void googleProvisioningPreservesLinkedUserProfileStatusOnResignIn() throws Exception {
|
||||
IdentityProvider provider = createProvider("Google", "Google", Map.of("client_id", "google-client"), Map.of());
|
||||
cognitoService.adminCreateUser(pool.getId(), "alice", Map.of("email", "alice@example.test"), "Password123!");
|
||||
cognitoService.adminLinkProviderForUser(pool.getId(), "alice", "Google", "google-subject");
|
||||
|
||||
// First federated sign-in.
|
||||
CognitoUser first = cognitoService.provisionFederatedUser(pool.getId(), provider, "google-subject", null,
|
||||
Map.of("email", "updated@example.test"));
|
||||
String statusAfterFirst = first.getUserStatus();
|
||||
|
||||
// Second federated sign-in.
|
||||
CognitoUser second = cognitoService.provisionFederatedUser(pool.getId(), provider, "google-subject", null,
|
||||
Map.of("email", "updated2@example.test"));
|
||||
|
||||
assertEquals("alice", second.getUsername());
|
||||
assertEquals(statusAfterFirst, second.getUserStatus(),
|
||||
"Linked profile status must be preserved across repeated federated sign-ins");
|
||||
}
|
||||
|
||||
@Test
|
||||
void googleProvisioningPreservesPermanentPasswordStatusOnResignIn() throws Exception {
|
||||
IdentityProvider provider = createProvider("Google", "Google", Map.of("client_id", "google-client"), Map.of());
|
||||
CognitoUser first = cognitoService.provisionFederatedUser(pool.getId(), provider, "google-subject", null,
|
||||
Map.of("email", "user@example.test"));
|
||||
cognitoService.adminSetUserPassword(pool.getId(), first.getUsername(), "PermanentPass1!", true);
|
||||
|
||||
CognitoUser afterPassword = cognitoService.adminGetUser(pool.getId(), first.getUsername());
|
||||
assertEquals("CONFIRMED", afterPassword.getUserStatus());
|
||||
|
||||
// Re-sign-in via federation must not revert to EXTERNAL_PROVIDER.
|
||||
CognitoUser second = cognitoService.provisionFederatedUser(pool.getId(), provider, "google-subject", null,
|
||||
Map.of("email", "user2@example.test"));
|
||||
|
||||
assertEquals("CONFIRMED", second.getUserStatus(),
|
||||
"Permanent-password profile must keep CONFIRMED across federated re-sign-in");
|
||||
}
|
||||
|
||||
@Test
|
||||
void googleProvisioningReconcilesUserLinkedWithGeneratedUsername() throws Exception {
|
||||
IdentityProvider provider = createProvider("Google", "Google", Map.of("client_id", "google-client"), Map.of());
|
||||
|
||||
Reference in new issue
Block a user