100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Bug fixes for keycloak proxy initialisation
Rich Turner7eb9f550cb93
diff --git a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.javaindex 2b61522d4..c0bd0da11 100644--- a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java+++ b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java@@ -79,7 +79,6 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {ADMIN_CLI_CLIENT_ID,"broker","master-realm",- MANAGER_CLIENT_ID,"security-admin-console");public static final String KEYCLOAK_HOST = "KEYCLOAK_HOST";@@ -135,7 +134,7 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {protected KeycloakIdentityProvider() {}- public OAuthGrant getDefaultKeycloakGrant(Container container) {+ public OAuthPasswordGrant getDefaultKeycloakGrant(Container container) {return new OAuthPasswordGrant(getTokenUri(MASTER_REALM).toString(),ADMIN_CLI_CLIENT_ID,diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayService.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayService.javaindex 37c304ab5..4ed8a91f0 100644--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayService.java+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayService.java@@ -590,7 +590,7 @@ public class GatewayService extends RouteBuilder implements ContainerService, AsString secret = gateway.getClientSecret().orElseGet(() -> UUID.randomUUID().toString());try {- identityProvider.createUpdateUser(gateway.getRealm(), new User().setServiceAccount(true).setUsername(clientId), secret);+ identityProvider.createUpdateUser(gateway.getRealm(), new User().setServiceAccount(true).setUsername(clientId).setEnabled(true), secret);if (!clientId.equals(gateway.getClientId().orElse(null)) || !secret.equals(gateway.getClientSecret().orElse(null))) {gateway.setClientId(clientId);diff --git a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.javaindex c03ca1e36..bb12a9a72 100644--- a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java+++ b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java@@ -33,7 +33,6 @@ import org.openremote.container.security.AuthContext;import org.openremote.container.security.keycloak.KeycloakIdentityProvider;import org.openremote.container.timer.TimerService;import org.openremote.container.web.WebService;-import org.openremote.container.web.WebTargetBuilder;import org.openremote.manager.apps.ConsoleAppService;import org.openremote.manager.event.ClientEventService;import org.openremote.model.Constants;@@ -61,6 +60,8 @@ import java.nio.file.Path;import java.nio.file.Paths;import java.nio.file.StandardOpenOption;import java.util.*;+import java.util.function.BiFunction;+import java.util.function.Supplier;import java.util.logging.Level;import java.util.logging.Logger;import java.util.stream.Collectors;@@ -131,39 +132,81 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider im@Overridepublic User[] getUsers(String realm) {- return getUsers(new UserQuery().tenant(new TenantPredicate(realm)));+ User[] users = getUsers(new UserQuery().tenant(new TenantPredicate(realm)));++ return getRealms(realmsResource -> {+ // Need to load secrets from client resource+ return Arrays.stream(users).filter(user -> {+ RealmResource realmResource = realmsResource.realm(realm);++ // Filter out users with service account attribute+ UserRepresentation userRepresentation = realmResource.users().get(user.getId()).toRepresentation();+ if (userRepresentation.getAttributes() != null && userRepresentation.getAttributes().containsKey(User.SYSTEM_ACCOUNT_ATTRIBUTE)) {+ return false;+ }++ return true;+ }).toArray(User[]::new);+ });}@Overridepublic User[] getServiceUsers(String realm) {User[] users = ManagerIdentityProvider.getUsersFromDb(persistenceService, new UserQuery().usernames(new StringPredicate(AssetQuery.Match.BEGIN, User.SERVICE_ACCOUNT_PREFIX)).tenant(new TenantPredicate(realm)));+return getRealms(realmsResource -> {// Need to load secrets from client resourcereturn Arrays.stream(users).filter(user -> {RealmResource realmResource = realmsResource.realm(realm);- ClientsResource clientsResource = realmResource.clients();- List<ClientRepresentation> clients = clientsResource.findByClientId(user.getUsername());- // Filter out system service accounts+ // Filter out users with service account attributeUserRepresentation userRepresentation = realmResource.users().get(user.getId()).toRepresentation();if (userRepresentation.getAttributes() != null && userRepresentation.getAttributes().containsKey(User.SYSTEM_ACCOUNT_ATTRIBUTE)) {return false;}- if (clients != null && !clients.isEmpty()) {- ClientRepresentation client = clients.get(0);- CredentialRepresentation credentialRepresentation = realmResource.clients()- .get(client.getId()).getSecret();- if (credentialRepresentation != null) {- user.setSecret(credentialRepresentation.getValue());- return true;- }- }- return false;+ withClientResource(realm, user.getUsername(), realmsResource, (clientRep, clientResource) ->+ user.setSecret(getClientSecret(clientResource)),+ null);++ return user.getSecret() != null;}).toArray(User[]::new);});}+ protected String getClientSecret(ClientResource clientResource) {+ CredentialRepresentation credentialRepresentation = clientResource.getSecret();+ return credentialRepresentation != null ? credentialRepresentation.getValue() : null;+ }++ protected <T> T withClientResource(String realm, String client, RealmsResource realmsResource, BiFunction<ClientRepresentation, ClientResource, T> clientResourceConsumer, Supplier<T> notFoundProvider) {+ ClientRepresentation clientRepresentation = null;+ ClientResource clientResource = null;++ try {+ ClientsResource clientsResource = realmsResource.realm(realm).clients();+ List<ClientRepresentation> clientRepresentations = clientsResource.findByClientId(client);+ if (clientRepresentations != null && !clientRepresentations.isEmpty()) {+ if (clientRepresentations.size() > 1) {+ throw new IllegalStateException("More than one matching client found realm=" + realm + ", client=" + client);+ }+ clientRepresentation = clientRepresentations.get(0);+ clientResource = clientsResource.get(clientRepresentation.getId());+ if (clientRepresentation.isServiceAccountsEnabled()) {+ clientRepresentation.setSecret(getClientSecret(clientResource));+ }+ }+ } catch (Exception e) {+ LOG.log(Level.INFO, "withClientResource failed", e);+ }+ if (clientResource != null) {+ return clientResourceConsumer.apply(clientRepresentation, clientResource);+ } else if (notFoundProvider != null) {+ return notFoundProvider.get();+ }+ return null;+ }+@Overridepublic User[] getUsers(List<String> userIds) {return getUsers(new UserQuery().ids(userIds.toArray(new String[0])));@@ -184,7 +227,16 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider im@Overridepublic User getUser(String realm, String userId) {- return ManagerIdentityProvider.getUserByIdFromDb(persistenceService, realm, userId);+ User user = ManagerIdentityProvider.getUserByIdFromDb(persistenceService, realm, userId);+ if (user != null && user.isServiceAccount()) {+ getRealms(realmsResource -> {+ withClientResource(realm, user.getUsername(), realmsResource, (clientRep, clientResource) ->+ user.setSecret(getClientSecret(clientResource)), null);+ return null;+ });+ }++ return user;}@Override@@ -207,20 +259,18 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imif (existingUser == null && user.isServiceAccount()) {// Could be a service user- clientRepresentation = realmsResource.realm(realm)- .clients()- .findByClientId(user.getUsername()).stream().findFirst().orElse(null);-- userRepresentation = clientRepresentation != null ? realmsResource.realm(realm)- .clients()- .get(clientRepresentation.getId()).getServiceAccountUser() : null;+ userRepresentation = withClientResource(realm, user.getUsername(), realmsResource, (clientRep, clientResource) -> {+ UserRepresentation userRep = clientResource.getServiceAccountUser();+ if (userRep == null) {+ String msg = "Attempt to update/creat service user but a regular client with same client ID as this username already exists: User=" + user;+ LOG.info(msg);+ throw new NotAllowedException(msg);+ }+ return userRep;+ }, null);if (userRepresentation != null) {existingUser = convert(userRepresentation, User.class);- } else if (clientRepresentation != null) {- String msg = "Attempt to update/creat service user but a regular client with same client ID as this username already exists: User=" + user;- LOG.info(msg);- throw new NotAllowedException(msg);}}@@ -275,6 +325,9 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imuserRepresentation = realmsResource.realm(realm).clients().get(clientRepresentation.getId()).getServiceAccountUser();+ userRepresentation.setEnabled(user.getEnabled());+ realmsResource.realm(realm).users().get(userRepresentation.getId()).update(userRepresentation);+} else {userRepresentation = convert(user, UserRepresentation.class);@@ -307,6 +360,9 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imUser updatedUser = convert(userRepresentation, User.class);if (updatedUser != null) {updatedUser.setRealm(realm);+ if (updatedUser.isServiceAccount()) {+ updatedUser.setSecret(passwordSecret);+ }}return updatedUser;});@@ -350,29 +406,31 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider im@Overridepublic String resetSecret(String realm, String userId, String secret) {return getRealms(realmsResource -> {- UserRepresentation userRepresentation = realmsResource.realm(realm).users().get(userId).toRepresentation();+ UserRepresentation userRepresentation = null;+ try {+ userRepresentation = realmsResource.realm(realm).users().get(userId).toRepresentation();+ } catch (Exception ignored) {+ }if (userRepresentation == null) {return null;}- ClientsResource clientsResource = realmsResource.realm(realm).clients();- List<ClientRepresentation> clients = clientsResource.findByClientId(userRepresentation.getUsername().substring(User.SERVICE_ACCOUNT_PREFIX.length()));-- if (!clients.isEmpty()) {- ClientRepresentation client = clients.get(0);- ClientResource clientResource = realmsResource.realm(realm).clients().get(client.getId());-- if (TextUtil.isNullOrEmpty(secret)) {- CredentialRepresentation credentialRepresentation = clientResource.generateNewSecret();- return credentialRepresentation.getValue();- } else {- client.setSecret(secret);- clientResource.update(client);- return secret;- }- }-- return null;+ return withClientResource(+ realm,+ userRepresentation.getUsername().substring(User.SERVICE_ACCOUNT_PREFIX.length()),+ realmsResource,+ (clientRep, clientResource) -> {+ if (TextUtil.isNullOrEmpty(secret)) {+ CredentialRepresentation credentialRepresentation = clientResource.generateNewSecret();+ return credentialRepresentation.getValue();+ } else {+ clientRep.setSecret(secret);+ clientResource.update(clientRep);+ return secret;+ }+ },+ null+ );});}@@ -519,37 +577,32 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imreturn getRealms(realmsResource -> {RealmResource realmResource = realmsResource.realm(realm);RoleMappingResource roleMappingResource = realmResource.users().get(userId).roles();- ClientsResource clientsResource = realmResource.clients();- List<ClientRepresentation> clientRepresentations = clientsResource.findByClientId(client);- if (clientRepresentations == null || clientRepresentations.isEmpty()) {- return null;- }+ return withClientResource(realm, client, realmsResource, (clientRepresentation, clientResource) -> {+ RolesResource rolesResource = clientResource.roles();+ List<RoleRepresentation> allRoles = rolesResource.list();+ List<RoleRepresentation> effectiveRoles = roleMappingResource.clientLevel(clientRepresentation.getId()).listEffective();- String clientId = clientRepresentations.get(0).getId();- RolesResource rolesResource = clientsResource.get(clientId).roles();- List<RoleRepresentation> allRoles = rolesResource.list();- List<RoleRepresentation> effectiveRoles = roleMappingResource.clientLevel(clientId).listEffective();+ List<Role> roles = new ArrayList<>();+ for (RoleRepresentation roleRepresentation : allRoles) {+ boolean isAssigned = false;- List<Role> roles = new ArrayList<>();- for (RoleRepresentation roleRepresentation : allRoles) {- boolean isAssigned = false;+ for (RoleRepresentation effectiveRole : effectiveRoles) {+ if (effectiveRole.getId().equals(roleRepresentation.getId()))+ isAssigned = true;+ }- for (RoleRepresentation effectiveRole : effectiveRoles) {- if (effectiveRole.getId().equals(roleRepresentation.getId()))- isAssigned = true;+ roles.add(new Role(+ roleRepresentation.getId(),+ roleRepresentation.getName(),+ roleRepresentation.isComposite(),+ isAssigned,+ null)+ .setDescription(roleRepresentation.getDescription()));}- roles.add(new Role(- roleRepresentation.getId(),- roleRepresentation.getName(),- roleRepresentation.isComposite(),- isAssigned,- null)- .setDescription(roleRepresentation.getDescription()));- }-- return roles.toArray(new Role[0]);+ return roles.toArray(new Role[0]);+ }, null);});}@@ -679,19 +732,27 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imLOG.fine("Create tenant: " + tenant);return getRealms(realmsResource -> {RealmRepresentation realmRepresentation = convert(tenant, RealmRepresentation.class);- realmsResource.create(realmRepresentation);- RealmResource realmResource = realmsResource.realm(tenant.getRealm());-- realmRepresentation = realmResource.toRepresentation();- // Need a committed realmRepresentation to update the security- configureRealm(realmRepresentation);- realmResource.update(realmRepresentation);-- // Auto create the standard openremote client- ClientRepresentation clientRepresentation = generateOpenRemoteClientRepresentation();- createUpdateClient(tenant.getRealm(), clientRepresentation);- publishModification(PersistenceEvent.Cause.CREATE, tenant);- return convert(realmRepresentation, Tenant.class);++ try {+ realmsResource.create(realmRepresentation);+ RealmResource realmResource = realmsResource.realm(tenant.getRealm());+ realmRepresentation = realmResource.toRepresentation();++ // Need a committed realmRepresentation to update the security+ configureRealm(realmRepresentation);+ realmResource.update(realmRepresentation);++ // Auto create the standard openremote client+ ClientRepresentation clientRepresentation = generateOpenRemoteClientRepresentation();+ createUpdateClient(tenant.getRealm(), clientRepresentation);++ Tenant createdTenant = convert(realmRepresentation, Tenant.class);+ publishModification(PersistenceEvent.Cause.CREATE, createdTenant);+ return createdTenant;+ } catch (Exception e) {+ LOG.log(Level.INFO, "Failed to create tenant: " + tenant, e);+ throw e;+ }});}@@ -791,16 +852,9 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider im// TODO: Provide an implementation agnostic clientpublic ClientRepresentation getClient(String realm, String clientId) {- return getRealms(realmsResource -> {- ClientsResource clientsResource = realmsResource.realm(realm).clients();- List<ClientRepresentation> clients = clientsResource.findByClientId(clientId);-- if (clients.isEmpty()) {- return null;- }-- return clients.get(0);- });+ return getRealms(realmsResource ->+ withClientResource(realm, clientId, realmsResource, (clientRepresentation, clientResource) ->+ clientRepresentation, null));}// TODO: Provide an implementation agnostic client@@ -815,37 +869,25 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imthrow new IllegalArgumentException("Client is null or clientId is missing");}- boolean isUpdate = !TextUtil.isNullOrEmpty(client.getId());-- if (!isUpdate) {- // Check if client exists- ClientRepresentation clientRepresentation = getClient(realm, client.getClientId());- if (clientRepresentation != null) {- client.setId(clientRepresentation.getId());- isUpdate = true;- }- }-- boolean finalIsUpdate = isUpdate;-- return getRealms(realmsResource -> {+ return getRealms(realmsResource ->+ withClientResource(realm, client.getClientId(), realmsResource, (clientRepresentation, clientResource) -> {+ clientResource.update(client);+ return client;+ },+ () -> {ClientsResource clientsResource = realmsResource.realm(realm).clients();- if (finalIsUpdate) {- clientsResource.get(client.getId()).update(client);- } else {- Response response = clientsResource.create(client);- response.close();- if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {- return null;- }-- ClientRepresentation newClient = clientsResource.findByClientId(client.getClientId()).get(0);- ClientResource clientResource = clientsResource.get(newClient.getId());- addDefaultRoles(clientResource.roles());- return newClient;+ Response response = clientsResource.create(client);+ response.close();+ if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {+ LOG.info("Failed to create client response=" + response.getStatusInfo().getStatusCode() + ": " + client);+ return null;}- return null;- });++ ClientRepresentation newClient = clientsResource.findByClientId(client.getClientId()).get(0);+ ClientResource clientResource = clientsResource.get(newClient.getId());+ addDefaultRoles(clientResource.roles());+ return newClient;+ }));}public void deleteClient(String realm, String clientId) {@@ -864,18 +906,12 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider im}LOG.info("Deleting client: realm=" + realm + ", client ID=" + clientId);- ClientsResource clientsResource = realmResource.clients();- List<ClientRepresentation> clientRepresentations = clientsResource.findByClientId(clientId);-- if (clientRepresentations.isEmpty()) {+ return withClientResource(realm, clientId, realmsResource, (clientRepresentation, clientResource) -> {+ clientResource.remove();+ return null;+ }, () -> {throw new NotFoundException("Delete client failed as client not found: " + clientId);- }- if (clientRepresentations.size() > 1) {- throw new BadRequestException("Delete client failed as more than one client found matching the specified client ID: " + clientId);- }-- clientsResource.get(clientRepresentations.get(0).getId()).remove();- return null;+ });});}diff --git a/manager/src/main/java/org/openremote/manager/setup/KeycloakCleanSetup.java b/manager/src/main/java/org/openremote/manager/setup/KeycloakCleanSetup.javaindex 1b66f108b..b5ae88327 100644--- a/manager/src/main/java/org/openremote/manager/setup/KeycloakCleanSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/KeycloakCleanSetup.java@@ -40,14 +40,9 @@ public class KeycloakCleanSetup extends AbstractKeycloakSetup {public void onStart() throws Exception {super.onStart();- // Try clean with stored credentials first- try {- doClean();- } catch (Exception e) {- // Clear out keycloak auth- keycloakProvider.setActiveCredentials(keycloakProvider.getDefaultKeycloakGrant(container));- doClean();- }+ // Switch keycloak proxy back to admin cli+ keycloakProvider.setActiveCredentials(keycloakProvider.getDefaultKeycloakGrant(container));+ doClean();}protected void doClean() throws Exception {@@ -60,6 +55,7 @@ public class KeycloakCleanSetup extends AbstractKeycloakSetup {}});+ LOG.info("Deleting all non-master admin users");Arrays.stream(keycloakProvider.getUsers(MASTER_REALM)).forEach(user -> {if (!user.getUsername().equals(MASTER_REALM_ADMIN_USER)) {LOG.info("Deleting user: " + user);@@ -68,6 +64,7 @@ public class KeycloakCleanSetup extends AbstractKeycloakSetup {});// Delete all non built in clients+ LOG.info("Deleting all non default clients");Arrays.stream(keycloakProvider.getClients(MASTER_REALM)).forEach(client -> {if (!DEFAULT_CLIENTS.contains(client.getClientId())) {LOG.info("Deleting client: " + client.getClientId());diff --git a/manager/src/main/java/org/openremote/manager/setup/KeycloakInitSetup.java b/manager/src/main/java/org/openremote/manager/setup/KeycloakInitSetup.javaindex e3559580e..f250685d9 100644--- a/manager/src/main/java/org/openremote/manager/setup/KeycloakInitSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/KeycloakInitSetup.java@@ -23,10 +23,13 @@ import org.openremote.container.util.UniqueIdentifierGenerator;import org.openremote.model.Container;import org.openremote.model.auth.OAuthClientCredentialsGrant;import org.openremote.model.auth.OAuthGrant;+import org.openremote.model.auth.OAuthPasswordGrant;import org.openremote.model.security.ClientRole;+import org.openremote.model.security.Role;import org.openremote.model.security.Tenant;import org.openremote.model.security.User;+import java.util.logging.Level;import java.util.logging.Logger;import static org.openremote.container.security.keycloak.KeycloakIdentityProvider.MANAGER_CLIENT_ID;@@ -63,23 +66,20 @@ public class KeycloakInitSetup extends AbstractKeycloakSetup {// Give admin all roles on application client levelkeycloakProvider.updateUserRoles(MASTER_REALM, adminUser.getId(), KEYCLOAK_CLIENT_ID, ClientRole.READ.getValue(), ClientRole.WRITE.getValue());- // Create a service client for this manager to communicate with keycloak so it doesn't use the admin user credentials- User keycloakProxyUser = new User().setUsername(MANAGER_CLIENT_ID).setServiceAccount(true).setSystemAccount(true);- String secret = UniqueIdentifierGenerator.generateId();+ // Create a new super user for the keycloak proxy so admin user can be modified if desired+ User keycloakProxyUser = new User()+ .setUsername(MANAGER_CLIENT_ID)+ .setEnabled(true)+ .setSystemAccount(true);+ String password = UniqueIdentifierGenerator.generateId();+ keycloakProxyUser = keycloakProvider.createUpdateUser(MASTER_REALM, keycloakProxyUser, password);- // Use credentials from file system if they are available- OAuthGrant storedGrant = keycloakProvider.loadCredentials();- if (storedGrant != null) {- keycloakProxyUser.setUsername(storedGrant.getClientId());- secret = storedGrant.getClientSecret() != null ? storedGrant.getClientSecret() : secret;- }-- keycloakProxyUser = keycloakProvider.createUpdateUser(MASTER_REALM, keycloakProxyUser, secret);-- // Give this user admin realm role (so they can do realm CRUD)+ // Make this proxy user a super user by giving them admin realm rolekeycloakProvider.updateUserRoles(MASTER_REALM, keycloakProxyUser.getId(), null, "admin");- OAuthClientCredentialsGrant grant = new OAuthClientCredentialsGrant(keycloakProvider.getTokenUri(MASTER_REALM).toString(), keycloakProxyUser.getUsername(), secret, null);+ // Update the grant to match the proxy user and make this grant active+ OAuthPasswordGrant grant = keycloakProvider.getDefaultKeycloakGrant(container);+ grant.setUsername(keycloakProxyUser.getUsername()).setPassword(password);keycloakProvider.setActiveCredentials(grant);keycloakProvider.saveCredentials(grant);}diff --git a/model/src/main/java/org/openremote/model/auth/OAuthPasswordGrant.java b/model/src/main/java/org/openremote/model/auth/OAuthPasswordGrant.javaindex 979b7451e..6c47d2e98 100644--- a/model/src/main/java/org/openremote/model/auth/OAuthPasswordGrant.java+++ b/model/src/main/java/org/openremote/model/auth/OAuthPasswordGrant.java@@ -67,6 +67,16 @@ public class OAuthPasswordGrant extends OAuthClientCredentialsGrant {return password;}+ public OAuthPasswordGrant setUsername(String username) {+ this.username = username;+ return this;+ }++ public OAuthPasswordGrant setPassword(String password) {+ this.password = password;+ return this;+ }+public OAuthPasswordGrant setBasicAuthHeader(boolean basicAuthHeader) {return (OAuthPasswordGrant)super.setBasicAuthHeader(basicAuthHeader);}diff --git a/test/src/main/java/org/openremote/test/setup/KeycloakTestSetup.java b/test/src/main/java/org/openremote/test/setup/KeycloakTestSetup.javaindex b42dd9696..99e0ce083 100644--- a/test/src/main/java/org/openremote/test/setup/KeycloakTestSetup.java+++ b/test/src/main/java/org/openremote/test/setup/KeycloakTestSetup.java@@ -108,6 +108,7 @@ public class KeycloakTestSetup extends AbstractKeycloakSetup {*/serviceUser = new User().setServiceAccount(true)+ .setEnabled(true).setUsername(serviceUserId);serviceUser = keycloakProvider.createUpdateUser(tenantBuilding.getRealm(), serviceUser, serviceUserSecret);keycloakProvider.updateUserRoles(diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovyindex e084adfd1..84f3562de 100644--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy@@ -560,7 +560,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {expect: "the demo users to be created"conditions.eventually {def users = identityService.getIdentityProvider().getUsers(keycloakTestSetup.tenantBuilding.realm)- assert users.size() == 4+ assert users.size() == 3assert users.count { !TextUtil.isNullOrEmpty(it.email)} == 3}