mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-19 05:20:21 -06:00
Search user by id and fallback to username when needed
- prevents performance issues when reading policies as users are always stored by id. Closes #35796 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
committed by
Pedro Igor
parent
16a42d5a64
commit
a43b65281d
@@ -166,10 +166,11 @@ public class UserPolicyProviderFactory implements PolicyProviderFactory<UserPoli
|
||||
KeycloakSession session = authorization.getKeycloakSession();
|
||||
RealmModel realm = authorization.getRealm();
|
||||
UserProvider userProvider = session.users();
|
||||
UserModel user = userProvider.getUserByUsername(realm, userId);
|
||||
UserModel user = userProvider.getUserById(realm, userId);
|
||||
|
||||
if (user == null) {
|
||||
user = userProvider.getUserById(realm, userId);
|
||||
// fallback - userId is possibly a username
|
||||
user = userProvider.getUserByUsername(realm, userId);
|
||||
}
|
||||
|
||||
return user;
|
||||
|
||||
Reference in New Issue
Block a user