Skip to content

Commit

Permalink
KeycloakAdminClient: Use search param instead of username
Browse files Browse the repository at this point in the history
  • Loading branch information
ato committed Apr 19, 2024
1 parent b21508e commit 7e3e30e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/src/pandas/agency/KeycloakAdminClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ private record User(
}

private User getUserByUsername(String username) {
var users = restClient.get().uri("/users?username={username}&exact=true&max=2", username)
// The username= query param seems to be broken in our current version of Keycloak (or with federated accounts)
// so we have to do a general search= instead and then filter the results for username matches.
var users = restClient.get().uri("/users?search={username}&exact=true&briefRepresentation=true", username)
.retrieve()
.body(new ParameterizedTypeReference<List<User>>() {
});
users.removeIf(user -> !user.username().equals(username));
if (users == null) throw new RuntimeException("Missing response body");
if (users.isEmpty()) return null;
if (users.size() > 1) throw new RuntimeException("Duplicate users for username: " + username);
Expand Down

0 comments on commit 7e3e30e

Please sign in to comment.