User membership synchronization could skip updating groups the user is already part of
@@ -549,7 +549,11 @@ public class DefaultSyncContext implements SyncContext {
}
log.debug("- idp returned '{}'", extGroup.getId());
- Group grp;
+ // mark group as processed
+ Group grp = declaredExternalGroups.remove(extGroup.getId());
+ boolean exists = grp != null;
+
+ if (!exists) {
Authorizable a = userManager.getAuthorizable(extGroup.getId());
if (a == null) {
grp = createGroup(extGroup);
@@ -561,15 +565,15 @@ public class DefaultSyncContext implements SyncContext {
continue;
}
log.debug("- user manager returned '{}'", grp);
+ }
syncGroup(extGroup, grp);
+ if (!exists) {
// ensure membership
grp.addMember(auth);
log.debug("- added '{}' as member to '{}'", auth, grp);
-
- // remember the declared group
- declaredExternalGroups.remove(grp.getID());
+ }
// recursively apply further membership
if (depth > 1) {
