From a62e98f966d269baa14ba361e77d52b72134319b Mon Sep 17 00:00:00 2001 From: vramik Date: Thu, 6 Oct 2022 09:03:14 +0200 Subject: [PATCH] MapUserProvider should throw an exception for more than one user Closes #14672 --- .../java/org/keycloak/models/map/user/MapUserProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java b/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java index 50f4cafc6d..3e2f3bc88e 100644 --- a/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java +++ b/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java @@ -505,8 +505,8 @@ public class MapUserProvider implements UserProvider.Streams { List users = s.collect(Collectors.toList()); if (users.isEmpty()) return null; if (users.size() != 1) { - LOG.warnf("There are colliding usernames for users with usernames and ids: %s", - users.stream().collect(Collectors.toMap(MapUserEntity::getUsername, MapUserEntity::getId))); + throw new ModelDuplicateException(String.format("There are colliding usernames for users with usernames and ids: %s", + users.stream().collect(Collectors.toMap(MapUserEntity::getUsername, MapUserEntity::getId)))); } return entityToAdapterFunc(realm).apply(users.get(0)); }