mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(cognito): delete a pool's users and resource servers on DeleteUserPool (#3419)
Fixes #2864. DeleteUserPool cascaded to groups and (since #2858) identity providers, but left userStore and resourceServerStore untouched. A pool id can be pinned with the floci:override-id tag, so unlike real AWS (where a pool id is never reused) a pool recreated on the same id inherited the deleted pool's users, password hashes included, and resource servers. Adds the same prefix-scan cascade already used for groups/identity providers to users and resource servers, and adds regression tests for both cases mirroring the identity-provider orphan-reuse test from #2858. Verified by disabling the new cascade and confirming both new tests fail with the exact expected count mismatch before restoring it. Full cognito package regression (368 tests) passes clean.
This commit is contained in:
1 parent
70176d6287
commit
c48e81d956
2 files changed
+132
No files matched your search
@@ -543,6 +543,15 @@ public class CognitoService implements ResourceProvider {
|
||||
String prefix = id + "::";
|
||||
groupStore.scan(k -> k.startsWith(prefix))
|
||||
.forEach(g -> groupStore.delete(groupKey(id, g.getGroupName())));
|
||||
// github.com/floci-io/floci/issues/2864: a pool id can be pinned with the
|
||||
// floci:override-id tag, so it can be reused after delete - unlike real AWS, where a
|
||||
// pool id is never reused and this situation can't arise. Without this, a pool
|
||||
// recreated on the same id inherited the deleted pool's users (password hashes and
|
||||
// all) and resource servers.
|
||||
userStore.scan(k -> k.startsWith(prefix))
|
||||
.forEach(u -> userStore.delete(userKey(id, u.getUsername())));
|
||||
resourceServerStore.scan(k -> k.startsWith(prefix))
|
||||
.forEach(r -> resourceServerStore.delete(resourceServerKey(id, r.getIdentifier())));
|
||||
// Same lock as the provider mutations: a create or update that interleaves with
|
||||
// this cascade would otherwise reinstate a provider for a pool that is going away.
|
||||
synchronized (identityProviderLock) {
|
||||
|
||||
Reference in new issue
Block a user