[keycloak-dev] Improve search by a specific user in the admin console

Alexis Almeida alexis.almeida at gmail.com
Thu Jan 31 07:21:09 EST 2019


Considering an instalation of Keycloak where there are 2mi (or more) of
users on user_entity table, search for a specific user on the console is a
stressing task if you do it several times a day. I think it should be
possible to do "direct" search by username.

Today it is possible to search for a specific user by ID, by typing
id:xxxxxx in the search field in the console. IMO this feature could be
expanded, so someone could search for a specific user by username or by
email, like this: username:xxxxx or email:xxxxxx.

I made this change on my local machine and the result was ok.

private static final String SEARCH_USERNAME_PARAMETER = "username:";
private static final String SEARCH_EMAIL_PARAMETER = "email:";
.
.
.
} else if (search.startsWith(SEARCH_USERNAME_PARAMETER)) {
    UserModel userModel =
session.users().getUserByUsername(search.substring(SEARCH_USERNAME_PARAMETER.length()).trim(),
realm);
    if (userModel != null) {
        userModels = Arrays.asList(userModel);
    }
} else if (search.startsWith(SEARCH_EMAIL_PARAMETER)) {
    UserModel userModel =
session.users().getUserByEmail(search.substring(SEARCH_EMAIL_PARAMETER.length()).trim(),
realm);
    if (userModel != null) {
       userModels = Arrays.asList(userModel);
    }
} else {


More information about the keycloak-dev mailing list