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
Added support for multiple domain names via OR_ADDITIONAL_HOSTNAMES OR_HOST renamed OR_HOSTNAME
Rich Turneraf26f2866c38
diff --git a/.ci_cd/README.md b/.ci_cd/README.mdindex 683ed2801..c0daa85e9 100644--- a/.ci_cd/README.md+++ b/.ci_cd/README.md@@ -111,7 +111,7 @@ profile can be specified in any of the places variables are loaded from (github* `MANAGER_TAG` - The docker tag to pull for the manager image (if not specified)* `CLEAN_INSTALL` - Indicates if the or_postgresql-data volume should be removed before starting the stack* `COMMIT` - Which commit or branch to checkout and use on this repo (default: branch/SHA on which workflow is executed)-* `OR_HOST` - FQDN for the host (default: env/secrets.OR_HOST)+* `OR_HOSTNAME` - FQDN for the host (default: env/secrets.OR_HOSTNAME)* `SSH_USER` - SSH username (default: root)* `SSH_KEY` - SSH private key (this is written to `ssh.key` file and loaded by `deploy.sh` for SSH/SCP commands)* `SSH_PASSWORD` - SSH password (alternative to private key authentication)@@ -123,7 +123,7 @@ profile can be specified in any of the places variables are loaded from (github* `ENV_COMPOSE_FILE` - The full path to the docker compose file to use for the deployment* `SKIP_HOST_PING` - Will skip host ping check before deploying (default: false)* `SKIP_SSH_WHITELIST` - Will skip whitelisting the runner in AWS ssh-access security group-* `SKIP_AWS_EC2_START` - Will skip attempt to start EC2 instance named $OR_HOST when PING fails+* `SKIP_AWS_EC2_START` - Will skip attempt to start EC2 instance named $OR_HOSTNAME when PING fails* `SKIP_AWS_S3_FILECOPY` - Will skip attempt to copy host deployment files from AWS S3 bucket to `/deployment.local/s3`* `AWS_EFS_MAP` - Name of EFS map volume to mount at `/deployment.local/map`diff --git a/.ci_cd/deploy.sh b/.ci_cd/deploy.shindex c4817d20a..2d71cb273 100644--- a/.ci_cd/deploy.sh+++ b/.ci_cd/deploy.sh@@ -35,11 +35,11 @@ if [ -f "temp/env" ]; thenfi# Check host is defined-if [ -z "$OR_HOST" ]; then+if [ -z "$OR_HOSTNAME" ]; thenecho "Host is not set"exit 1fi-HOST="$OR_HOST"+HOST="$OR_HOSTNAME"# Load SSH environment variables into this sessionif [ -f "ssh.env" ]; then@@ -95,7 +95,7 @@ if [ -f "ssh.key" ]; thensshCommandPrefix="$sshCommandPrefix -i ssh.key"scpCommandPrefix="$scpCommandPrefix -i ssh.key"fi-hostStr="$OR_HOST"+hostStr="$OR_HOSTNAME"if [ -n "$SSH_USER" ]; thenhostStr="${SSH_USER}@$hostStr"fi@@ -104,11 +104,11 @@ fi# Check host is reachable (ping must be enabled)#if [ "$SKIP_HOST_PING" != 'true' ]; then# echo "Attempting to ping host"-# ping -c1 -W1 -q $OR_HOST &>/dev/null+# ping -c1 -W1 -q $OR_HOSTNAME &>/dev/null# if [ $? -ne 0 ]; then# echo "Host is not reachable by PING"# if [ "$SKIP_AWS_EC2_START" != 'true' ] && [ "$AWS_ENABLED" == 'true' ]; then-# "temp/aws/start_stop_host.sh" "START" "$OR_HOST"+# "temp/aws/start_stop_host.sh" "START" "$OR_HOSTNAME"# if [ $? -ne 0 ]; then# # Don't exit as it might just not be reachable by PING we'll fail later on# echo "EC2 instance start failed"@@ -341,8 +341,8 @@ fidocker image inspect \$(docker image ls -aq) > temp/image-info.txtdocker inspect \$(docker ps -aq) > temp/container-info.txt-aws s3 cp temp/image-info.txt s3://${OR_HOST}/image-info.txt &>/dev/null-aws s3 cp temp/container-info.txt s3://${OR_HOST}/container-info.txt &>/dev/null+aws s3 cp temp/image-info.txt s3://${OR_HOSTNAME}/image-info.txt &>/dev/null+aws s3 cp temp/container-info.txt s3://${OR_HOSTNAME}/container-info.txt &>/dev/nullexit 0EOF@@ -475,8 +475,8 @@ fiEOFfi-echo "Testing manager web server https://$OR_HOST..."-response=$(curl --output /dev/null --silent --head --write-out "%{http_code}" https://$OR_HOST/manager/)+echo "Testing manager web server https://$OR_HOSTNAME..."+response=$(curl --output /dev/null --silent --head --write-out "%{http_code}" https://$OR_HOSTNAME/manager/)if [ $response -ne 200 ]; thenecho "Response code = $response"revoke_sshdiff --git a/.ci_cd/env/demo.env b/.ci_cd/env/demo.envindex fe9f58067..badc232c4 100644--- a/.ci_cd/env/demo.env+++ b/.ci_cd/env/demo.env@@ -1 +1,2 @@-OR_HOST=demo.openremote.app+OR_HOSTNAME=demo.openremote.app+OR_ADDITIONAL_HOSTNAMES=demo.openremote.iodiff --git a/.ci_cd/env/staging.env b/.ci_cd/env/staging.envindex ee37f0067..ae6171c49 100644--- a/.ci_cd/env/staging.env+++ b/.ci_cd/env/staging.env@@ -1 +1,2 @@-OR_HOST=staging.demo.openremote.app+OR_HOSTNAME=staging.demo.openremote.app+OR_ADDITIONAL_HOSTNAMES=staging.demo.openremote.iodiff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlindex 13a152a0d..dd5f4a854 100644--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@ -45,7 +45,7 @@# - CLEAN_INSTALL - Should the .ci_cd/host_init/clean.sh script be run during deployment (warning this will delete# assets, rules, etc.)# - COMMIT - Which branch/SHA should be checked out for the deployment (defaults to trigger commit)-# - OR_HOST - FQDN of host to deploy to (e.g. demo.openremote.app)+# - OR_HOSTNAME - FQDN of host to deploy to (e.g. demo.openremote.app)# - SSH_USER - Set/override the SSH user to use for SSH/SCP commands# - SSH_PASSWORD - Set/override the SSH password to use for SSH/SCP commands (SSH key should be preferred)# - SSH_PORT - Set/override the SSH port to use for SSH/SCP commands@@ -82,7 +82,7 @@ on:type: booleanCOMMIT:description: 'Repo branch or commit SHA to checkout'- OR_HOST:+ OR_HOSTNAME:description: 'Host to deploy to (e.g. demo.openremote.app)'SSH_PORT:description: 'SSH port'diff --git a/README.md b/README.mdindex a249f46c6..3cc16eb95 100644--- a/README.md+++ b/README.md@@ -36,17 +36,17 @@ Username: adminPassword: secret### Changing host and/or port-The URL you use to access the system is important, the default is configured as `https://localhost` if you are using a VM or want to run on a different port then you will need to set the `OR_HOST` amd `OR_SSL_PORT` environment variables, so if for example you will be accessing using `https://192.168.1.1:8443` then use the following startup command:+The URL you use to access the system is important, the default is configured as `https://localhost` if you are using a VM or want to run on a different port then you will need to set the `OR_HOSTNAME` amd `OR_SSL_PORT` environment variables, so if for example you will be accessing using `https://192.168.1.1:8443` then use the following startup command:BASH:```-OR_HOST=192.168.1.1 OR_SSL_PORT=8443 docker-compose -p openremote up -d+OR_HOSTNAME=192.168.1.1 OR_SSL_PORT=8443 docker-compose -p openremote up -d```orCMD:```-cmd /C "set OR_HOST=192.168.1.1 && set OR_SSL_PORT=8443 && docker-compose -p openremote up -d"+cmd /C "set OR_HOSTNAME=192.168.1.1 && set OR_SSL_PORT=8443 && docker-compose -p openremote up -d"```diff --git a/container/src/main/java/org/openremote/container/security/CORSFilter.java b/container/src/main/java/org/openremote/container/security/CORSFilter.javaindex 65dea1272..247e3654d 100644--- a/container/src/main/java/org/openremote/container/security/CORSFilter.java+++ b/container/src/main/java/org/openremote/container/security/CORSFilter.java@@ -18,13 +18,12 @@ import java.util.Set;import java.util.logging.Logger;public class CORSFilter extends HttpFilter {- private static final Logger LOG = Logger.getLogger(CORSFilter.class.getName());protected boolean allowCredentials = true;protected String allowedMethods;protected String allowedHeaders;protected String exposedHeaders;protected int corsMaxAge = -1;- protected Set<String> allowedOrigins = new HashSet<String>();+ protected Set<String> allowedOrigins = new HashSet<>();public boolean isAllowCredentials() {return allowCredentials;@@ -144,7 +143,8 @@ public class CORSFilter extends HttpFilter {}protected boolean originOk(String origin) {- return allowedOrigins.contains("*") || allowedOrigins.contains(origin);+ // startsWith test allows for host matching without explicit port mapping+ return allowedOrigins.contains("*") || allowedOrigins.contains(origin) || allowedOrigins.stream().anyMatch(origin::startsWith);}-}\ No newline at end of file+}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 25a843fff..6ba35383f 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@@ -98,7 +98,7 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {public static final String KEYCLOAK_AUTH_PATH = "auth";private static final Logger LOG = Logger.getLogger(KeycloakIdentityProvider.class.getName());- // The (internal) URI where Keycloak can be found+ // The URI where Keycloak can be foundprotected UriBuilder keycloakServiceUri;// Configuration options for new realmsprotected int sessionTimeoutSeconds;diff --git a/container/src/main/java/org/openremote/container/web/WebService.java b/container/src/main/java/org/openremote/container/web/WebService.javaindex 5c6795e47..42f4abbb8 100644--- a/container/src/main/java/org/openremote/container/web/WebService.java+++ b/container/src/main/java/org/openremote/container/web/WebService.java@@ -34,22 +34,22 @@ import org.openremote.container.security.CORSFilter;import org.openremote.container.security.IdentityService;import org.openremote.model.Container;import org.openremote.model.ContainerService;+import org.openremote.model.util.TextUtil;import org.xnio.Options;import javax.servlet.DispatcherType;import javax.ws.rs.core.UriBuilder;import java.net.Inet4Address;import java.net.URI;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.Collection;-import java.util.List;+import java.util.*;import java.util.concurrent.atomic.AtomicReference;import java.util.function.Predicate;import java.util.logging.Logger;import java.util.stream.Collectors;import static org.openremote.container.util.MapAccess.*;+import static org.openremote.model.Constants.OR_ADDITIONAL_HOSTNAMES;+import static org.openremote.model.Constants.OR_HOSTNAME;public abstract class WebService implements ContainerService {@@ -80,16 +80,15 @@ public abstract class WebService implements ContainerService {// Change this to 0.0.0.0 to bind on all interfaces, enabling// access of the manager service from other devices in your LANpublic static final String OR_WEBSERVER_LISTEN_HOST = "OR_WEBSERVER_LISTEN_HOST";- public static final String OR_WEBSERVER_LISTEN_HOST_DEFAULT = "127.0.0.1";- public static final String WEBSERVER_LISTEN_PORT = "WEBSERVER_LISTEN_PORT";- public static final int WEBSERVER_LISTEN_PORT_DEFAULT = 8080;- public static final String WEBSERVER_DUMP_REQUESTS = "WEBSERVER_DUMP_REQUESTS";- public static final boolean WEBSERVER_DUMP_REQUESTS_DEFAULT = false;- public static final String WEBSERVER_ALLOWED_ORIGINS = "WEBSERVER_ALLOWED_ORIGINS";- public static final String WEBSERVER_ALLOWED_ORIGINS_DEFAULT = null;- public static final String WEBSERVER_IO_THREADS_MAX = "WEBSERVER_IO_THREADS_MAX";- public static final int WEBSERVER_IO_THREADS_MAX_DEFAULT = Math.max(Runtime.getRuntime().availableProcessors(), 2);- public static final String WEBSERVER_WORKER_THREADS_MAX = "WEBSERVER_WORKER_THREADS_MAX";+ public static final String OR_WEBSERVER_LISTEN_HOST_DEFAULT = "0.0.0.0";+ public static final String OR_WEBSERVER_LISTEN_PORT = "OR_WEBSERVER_LISTEN_PORT";+ public static final int OR_WEBSERVER_LISTEN_PORT_DEFAULT = 8080;+ public static final String OR_WEBSERVER_DUMP_REQUESTS = "OR_WEBSERVER_DUMP_REQUESTS";+ public static final boolean OR_WEBSERVER_DUMP_REQUESTS_DEFAULT = false;+ public static final String OR_WEBSERVER_ALLOWED_ORIGINS = "OR_WEBSERVER_ALLOWED_ORIGINS";+ public static final String OR_WEBSERVER_IO_THREADS_MAX = "OR_WEBSERVER_IO_THREADS_MAX";+ public static final int OR_WEBSERVER_IO_THREADS_MAX_DEFAULT = Math.max(Runtime.getRuntime().availableProcessors(), 2);+ public static final String OR_WEBSERVER_WORKER_THREADS_MAX = "OR_WEBSERVER_WORKER_THREADS_MAX";public static final int WEBSERVER_WORKER_THREADS_MAX_DEFAULT = Math.max(Runtime.getRuntime().availableProcessors(), 10);private static final Logger LOG = Logger.getLogger(WebService.class.getName());protected static AtomicReference<CORSFilter> corsFilterRef;@@ -112,7 +111,7 @@ public abstract class WebService implements ContainerService {public void init(Container container) throws Exception {devMode = container.isDevMode();host = getString(container.getConfig(), OR_WEBSERVER_LISTEN_HOST, OR_WEBSERVER_LISTEN_HOST_DEFAULT);- port = getInteger(container.getConfig(), WEBSERVER_LISTEN_PORT, WEBSERVER_LISTEN_PORT_DEFAULT);+ port = getInteger(container.getConfig(), OR_WEBSERVER_LISTEN_PORT, OR_WEBSERVER_LISTEN_PORT_DEFAULT);String containerHost = host.equalsIgnoreCase("localhost") || host.indexOf("127") == 0 || host.indexOf("0.0.0.0") == 0? getLocalIpAddress(): host;@@ -127,8 +126,8 @@ public abstract class WebService implements ContainerService {container,Undertow.builder().addHttpListener(port, host)- .setIoThreads(getInteger(container.getConfig(), WEBSERVER_IO_THREADS_MAX, WEBSERVER_IO_THREADS_MAX_DEFAULT))- .setWorkerThreads(getInteger(container.getConfig(), WEBSERVER_WORKER_THREADS_MAX, WEBSERVER_WORKER_THREADS_MAX_DEFAULT))+ .setIoThreads(getInteger(container.getConfig(), OR_WEBSERVER_IO_THREADS_MAX, OR_WEBSERVER_IO_THREADS_MAX_DEFAULT))+ .setWorkerThreads(getInteger(container.getConfig(), OR_WEBSERVER_WORKER_THREADS_MAX, WEBSERVER_WORKER_THREADS_MAX_DEFAULT)).setWorkerOption(Options.WORKER_NAME, "WebService").setWorkerOption(Options.THREAD_DAEMON, true)).build();@@ -242,7 +241,7 @@ public abstract class WebService implements ContainerService {handler = new WebServiceExceptions.RootUndertowExceptionHandler(devMode, handler);- if (getBoolean(container.getConfig(), WEBSERVER_DUMP_REQUESTS, WEBSERVER_DUMP_REQUESTS_DEFAULT)) {+ if (getBoolean(container.getConfig(), OR_WEBSERVER_DUMP_REQUESTS, OR_WEBSERVER_DUMP_REQUESTS_DEFAULT)) {handler = new RequestDumpingHandler(handler);}@@ -278,15 +277,15 @@ public abstract class WebService implements ContainerService {CORSFilter corsFilter = null;if (!container.isDevMode()) {- String allowedOriginsStr = getString(container.getConfig(), WEBSERVER_ALLOWED_ORIGINS, WEBSERVER_ALLOWED_ORIGINS_DEFAULT);- if (allowedOriginsStr != null) {+ Set<String> allowedOrigins = getAllowedOrigins(container);++ if (!allowedOrigins.isEmpty()) {corsFilter = new CORSFilter();corsFilter.setAllowCredentials(true);corsFilter.setAllowedMethods("GET, POST, PUT, DELETE, OPTIONS, HEAD");corsFilter.setExposedHeaders("*");corsFilter.setCorsMaxAge(1209600);- String[] allowedOrigins = allowedOriginsStr.split(";");- corsFilter.getAllowedOrigins().addAll(Arrays.asList(allowedOrigins));+ corsFilter.getAllowedOrigins().addAll(allowedOrigins);}} else {corsFilter = new CORSFilter();@@ -308,4 +307,39 @@ public abstract class WebService implements ContainerService {return null;}++ public static List<String> getExternalHostnames(Container container) {++ // Get list of external hostnames+ String defaultHostname = getString(container.getConfig(), OR_HOSTNAME, null);+ String additionalHostnamesStr = getString(container.getConfig(), OR_ADDITIONAL_HOSTNAMES, null);++ List<String> externalHostnames = new ArrayList<>();++ if (!TextUtil.isNullOrEmpty(additionalHostnamesStr)) {+ externalHostnames.addAll(Arrays.stream(additionalHostnamesStr.split(","))+ .toList());+ }++ if (!TextUtil.isNullOrEmpty(defaultHostname) && !externalHostnames.contains(defaultHostname)) {+ externalHostnames.add(defaultHostname);+ }++ return externalHostnames;+ }++ public static Set<String> getAllowedOrigins(Container container) {+ // Set allowed origins using external hostnames and WEBSERVER_ALLOWED_ORIGINS+ HashSet<String> allowedOrigins = new HashSet<>(+ getExternalHostnames(container)+ .stream().map(hostname -> "https://" + hostname).toList()+ );+ String allowedOriginsStr = getString(container.getConfig(), OR_WEBSERVER_ALLOWED_ORIGINS, null);++ if (!TextUtil.isNullOrEmpty(allowedOriginsStr)) {+ allowedOrigins.addAll(Arrays.stream(allowedOriginsStr.split(",")).toList());+ }++ return allowedOrigins;+ }}diff --git a/docker-compose.yml b/docker-compose.ymlindex 0c2d19233..79fa97461 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -1,7 +1,7 @@# OpenRemote v3## Profile that runs the stack by default on https://localhost using a self-signed SSL certificate,-# but optionally on https://$OR_HOST with an auto generated SSL certificate from Letsencrypt.+# but optionally on https://$OR_HOSTNAME with an auto generated SSL certificate from Letsencrypt.## It is possible to specify OR_SETUP_TYPE=demo to pre-populate the system with a set of demo assets, rules, etc. (as# is shown at https://demo.openremote.io)@@ -23,7 +23,7 @@ volumes:services:proxy:- image: openremote/proxy:${PROXY_VERSION:-2.5.0.3}+ image: openremote/proxy:${PROXY_VERSION:-latest}restart: alwaysdepends_on:manager:@@ -36,20 +36,21 @@ services:- proxy-data:/deploymentenvironment:LE_EMAIL: ${OR_EMAIL_ADMIN:-}- DOMAINNAME: ${OR_HOST:-localhost}+ DOMAINNAME: ${OR_HOSTNAME:-localhost}+ DOMAINNAMES: ${OR_ADDTIONAL_HOSTNAMES:-}# USE A CUSTOM PROXY CONFIG - COPY FROM https://github.com/openremote/proxy/blob/main/haproxy.cfg#HAPROXY_CONFIG: '/data/proxy/haproxy.cfg'postgresql:restart: always- image: openremote/postgresql:${POSTGRESQL_VERSION:-14.1.0.1}+ image: openremote/postgresql:${POSTGRESQL_VERSION:-latest}volumes:- postgresql-data:/var/lib/postgresql/data- temp-data:/tmpkeycloak:restart: always- image: openremote/keycloak:${KEYCLOAK_VERSION:-16.0.0.0}+ image: openremote/keycloak:${KEYCLOAK_VERSION:-latest}depends_on:postgresql:condition: service_healthy@@ -57,9 +58,9 @@ services:- ./deployment:/deploymentenvironment:KEYCLOAK_PASSWORD: ${OR_ADMIN_PASSWORD:-secret}- KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}/auth+ KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}/auth# Use the following if OR_SSL_PORT is not the default 443- #KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}:${OR_SSL_PORT:-443}/auth+ #KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}:${OR_SSL_PORT:-443}/authmanager:# privileged: true@@ -78,9 +79,14 @@ services:OR_EMAIL_PASSWORD:OR_EMAIL_FROM:OR_EMAIL_ADMIN:- OR_HOST: ${OR_HOST:-localhost}+ OR_HOSTNAME: ${OR_HOSTNAME:-localhost}+ OR_ADDITIONAL_HOSTNAMES: ${OR_ADDITIONAL_HOSTNAMES:-}OR_SSL_PORT: ${OR_SSL_PORT:-443}OR_DEV_MODE: ${OR_DEV_MODE:-false}+ KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}/auth+ # Use the following if OR_SSL_PORT is not the default 443+ #KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}:${OR_SSL_PORT:-443}/auth+# The following variables will configure the demoOR_FORECAST_SOLAR_API_KEY:OR_OPEN_WEATHER_API_APP_ID:diff --git a/manager/Dockerfile b/manager/Dockerfileindex 00527d63e..4dbfbbfe2 100644--- a/manager/Dockerfile+++ b/manager/Dockerfile@@ -12,7 +12,7 @@ ENV TZ ${TZ:-Europe/Amsterdam}ENV OR_ADMIN_PASSWORD ${OR_ADMIN_PASSWORD:-secret}ENV OR_SETUP_TYPE ${OR_SETUP_TYPE}ENV OR_SSL_PORT ${OR_SSL_PORT:-443}-ENV OR_HOST ${OR_HOST:-localhost}+ENV OR_HOSTNAME ${OR_HOSTNAME:-localhost}ENV OR_EMAIL_HOST ${OR_EMAIL_HOST}ENV OR_EMAIL_USER ${OR_EMAIL_USER}ENV OR_EMAIL_PASSWORD ${OR_EMAIL_PASSWORD}diff --git a/manager/src/main/java/org/openremote/manager/security/ManagerBasicIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerBasicIdentityProvider.javaindex b844fcb0c..43344af36 100644--- a/manager/src/main/java/org/openremote/manager/security/ManagerBasicIdentityProvider.java+++ b/manager/src/main/java/org/openremote/manager/security/ManagerBasicIdentityProvider.java@@ -257,6 +257,11 @@ public class ManagerBasicIdentityProvider extends BasicIdentityProvider implemenreturn auth.isSuperUser();}+ @Override+ public String getFrontendUrl() {+ return null;+ }+@Overridepublic String toString() {return getClass().getSimpleName() + "{}";diff --git a/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.javaindex 4b07217f7..a563219e0 100644--- a/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.java+++ b/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.java@@ -104,6 +104,10 @@ public interface ManagerIdentityProvider extends IdentityProvider {*/boolean canSubscribeWith(AuthContext auth, TenantFilter<?> filter, ClientRole... requiredRoles);+ /**+ * Returns the frontend URL to be used for frontend apps to authenticate+ */+ String getFrontendUrl();/** BELOW ARE STATIC HELPER METHODSdiff --git a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.javaindex 577b9755b..6bd2971ad 100644--- a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java+++ b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java@@ -67,8 +67,6 @@ import java.util.stream.Collectors;import static org.openremote.container.util.MapAccess.getBoolean;import static org.openremote.container.util.MapAccess.getString;-import static org.openremote.container.web.WebService.WEBSERVER_ALLOWED_ORIGINS;-import static org.openremote.container.web.WebService.WEBSERVER_ALLOWED_ORIGINS_DEFAULT;import static org.openremote.model.Constants.*;import static org.openremote.model.util.ValueUtil.convert;@@ -87,6 +85,7 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider impublic static final String KEYCLOAK_DEFAULT_ROLES_PREFIX = "default-roles-";public static final String KEYCLOAK_USER_ATTRIBUTE_EMAIL_NOTIFICATIONS_DISABLED = "emailNotificationsDisabled";public static final String KEYCLOAK_USER_ATTRIBUTE_PUSH_NOTIFICATIONS_DISABLED = "pushNotificationsDisabled";+ public static final String KEYCLOAK_FRONTEND_URL = "KEYCLOAK_FRONTEND_URL";protected PersistenceService persistenceService;protected TimerService timerService;@@ -95,6 +94,8 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider improtected ConsoleAppService consoleAppService;protected String keycloakAdminPassword;protected Container container;+ protected String frontendUrl;+ protected List<String> validRedirectUris;@Overridepublic void init(Container container) {@@ -107,12 +108,18 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imsetActiveCredentials(grant);}- this.keycloakAdminPassword = container.getConfig().getOrDefault(OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT);- this.timerService = container.getService(TimerService.class);- this.persistenceService = container.getService(PersistenceService.class);- this.messageBrokerService = container.getService(MessageBrokerService.class);- this.clientEventService = container.getService(ClientEventService.class);- this.consoleAppService = container.getService(ConsoleAppService.class);+ frontendUrl = getString(container.getConfig(), KEYCLOAK_FRONTEND_URL, null);+ keycloakAdminPassword = container.getConfig().getOrDefault(OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT);+ timerService = container.getService(TimerService.class);+ persistenceService = container.getService(PersistenceService.class);+ messageBrokerService = container.getService(MessageBrokerService.class);+ clientEventService = container.getService(ClientEventService.class);+ consoleAppService = container.getService(ConsoleAppService.class);++ // Allow all external hostnames with wildcard and same host with wildcard+ validRedirectUris = new ArrayList<>();+ validRedirectUris.add("/*");+ validRedirectUris.addAll(WebService.getExternalHostnames(container).stream().map(hostname -> "https://" + hostname + "/*").toList());}@Override@@ -931,20 +938,8 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imclient.setWebOrigins(Collections.singletonList("*"));client.setRedirectUris(Collections.singletonList("*"));} else {- // TODO: Decide how clients should be handledclient.setWebOrigins(Collections.singletonList("+"));- client.setRedirectUris(Collections.singletonList("/*"));-// List<String> redirectUris = new ArrayList<>();-// try {-// for (String consoleName : consoleAppService.getInstalled()) {-// addClientRedirectUris(consoleName, redirectUris, devMode);-// }-// } catch (Exception exception) {-// LOG.log(Level.WARNING, exception.getMessage(), exception);-// addClientRedirectUris(realm, redirectUris, devMode);-// }-//-// client.setRedirectUris(redirectUris);+ client.setRedirectUris(validRedirectUris);}return client;@@ -1087,6 +1082,11 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imreturn false;}+ @Override+ public String getFrontendUrl() {+ return frontendUrl;+ }+protected void configureRealm(RealmRepresentation realmRepresentation) {realmRepresentation.setAccessTokenLifespan(Constants.ACCESS_TOKEN_LIFESPAN_SECONDS);@@ -1138,7 +1138,7 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imif (container.isDevMode()) {headers.computeIfPresent("contentSecurityPolicy", (hdrName, hdrValue) -> "frame-src *; frame-ancestors *; object-src 'none'");} else {- String allowedOriginsStr = getString(container.getConfig(), WEBSERVER_ALLOWED_ORIGINS, WEBSERVER_ALLOWED_ORIGINS_DEFAULT);+ String allowedOriginsStr = String.join(" ", WebService.getAllowedOrigins(container));if (!TextUtil.isNullOrEmpty(allowedOriginsStr)) {headers.compute("contentSecurityPolicy", (hdrName, hdrValue) ->"frame-src 'self' " +diff --git a/manager/src/main/java/org/openremote/manager/system/HealthStatusService.java b/manager/src/main/java/org/openremote/manager/system/HealthStatusService.javaindex c46073596..acefb4446 100644--- a/manager/src/main/java/org/openremote/manager/system/HealthStatusService.java+++ b/manager/src/main/java/org/openremote/manager/system/HealthStatusService.java@@ -53,7 +53,7 @@ public class HealthStatusService implements ContainerService {}container.getService(ManagerWebService.class).addApiSingleton(- new StatusResourceImpl(healthStatusProviderList)+ new StatusResourceImpl(container, healthStatusProviderList));}diff --git a/manager/src/main/java/org/openremote/manager/system/SslHealthStatusProvider.java b/manager/src/main/java/org/openremote/manager/system/SslHealthStatusProvider.javaindex b26eb4a07..30ebd7c1c 100644--- a/manager/src/main/java/org/openremote/manager/system/SslHealthStatusProvider.java+++ b/manager/src/main/java/org/openremote/manager/system/SslHealthStatusProvider.java@@ -20,6 +20,7 @@package org.openremote.manager.system;import com.fasterxml.jackson.databind.node.ObjectNode;+import org.openremote.model.Constants;import org.openremote.model.Container;import org.openremote.model.ContainerService;import org.openremote.model.system.HealthStatusProvider;@@ -40,9 +41,6 @@ import static org.openremote.container.util.MapAccess.getString;public class SslHealthStatusProvider implements X509TrustManager, HealthStatusProvider, ContainerService {- public static final String OR_HOST = "OR_HOST";- public static final String OR_SSL_PORT = "OR_SSL_PORT";-public static final String NAME = "ssl";public static final String VERSION = "1.0";protected static final Logger LOG = Logger.getLogger(SslHealthStatusProvider.class.getName());@@ -58,11 +56,11 @@ public class SslHealthStatusProvider implements X509TrustManager, HealthStatusPr@Overridepublic void init(Container container) throws Exception {- int SSLPort = getInteger(container.getConfig(), OR_SSL_PORT, -1);+ int SSLPort = getInteger(container.getConfig(), Constants.OR_SSL_PORT, -1);if (SSLPort > 0 && SSLPort <= 65536) {this.SSLPort = SSLPort;- host = getString(container.getConfig(), OR_HOST, null);+ host = getString(container.getConfig(), Constants.OR_HOSTNAME, null);SSLContext = SSLContext.getInstance("TLS");SSLContext.init(null, new TrustManager[]{this}, null);}diff --git a/manager/src/main/java/org/openremote/manager/system/StatusResourceImpl.java b/manager/src/main/java/org/openremote/manager/system/StatusResourceImpl.javaindex 490cb3e18..d151074b7 100644--- a/manager/src/main/java/org/openremote/manager/system/StatusResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/system/StatusResourceImpl.java@@ -20,6 +20,9 @@package org.openremote.manager.system;import com.fasterxml.jackson.databind.node.ObjectNode;+import org.openremote.container.security.IdentityService;+import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.model.Container;import org.openremote.model.system.HealthStatusProvider;import org.openremote.model.system.StatusResource;import org.openremote.model.util.ValueUtil;@@ -35,10 +38,17 @@ public class StatusResourceImpl implements StatusResource {private static final Logger LOG = Logger.getLogger(StatusResourceImpl.class.getName());protected List<HealthStatusProvider> healthStatusProviderList;- protected Properties versionProps = new Properties();+ protected ObjectNode serverInfo;- public StatusResourceImpl(List<HealthStatusProvider> healthStatusProviderList) {+ public StatusResourceImpl(Container container, List<HealthStatusProvider> healthStatusProviderList) {this.healthStatusProviderList = healthStatusProviderList;+ Properties versionProps = new Properties();+ String authServerUrl = null;++ ManagerIdentityService identityService = container.getService(ManagerIdentityService.class);+ if (identityService != null) {+ authServerUrl = identityService.getIdentityProvider().getFrontendUrl();+ }try(InputStream resourceStream = StatusResourceImpl.class.getClassLoader().getResourceAsStream("system.properties")) {versionProps.load(resourceStream);@@ -46,6 +56,11 @@ public class StatusResourceImpl implements StatusResource {LOG.log(Level.SEVERE, "Failed to load manager version properties file: system.properties");throw new IllegalStateException("Missing manager system.properties file");}++ String version = versionProps.getProperty("version");+ serverInfo = ValueUtil.JSON.createObjectNode();+ serverInfo.put("version", version);+ serverInfo.put("authServerUrl", authServerUrl);}@Override@@ -65,9 +80,6 @@ public class StatusResourceImpl implements StatusResource {@Overridepublic ObjectNode getInfo() {- String version = versionProps.getProperty("version");- ObjectNode objectValue = ValueUtil.JSON.createObjectNode();- objectValue.put("version", version);- return objectValue;+ return serverInfo;}}diff --git a/model/src/main/java/org/openremote/model/Constants.java b/model/src/main/java/org/openremote/model/Constants.javaindex 686367949..4e501425f 100644--- a/model/src/main/java/org/openremote/model/Constants.java+++ b/model/src/main/java/org/openremote/model/Constants.java@@ -49,6 +49,9 @@ public interface Constants {String PERSISTENCE_STRING_ARRAY_TYPE = "string-array";String PERSISTENCE_LTREE_TYPE = "ltree";+ String OR_HOSTNAME = "OR_HOSTNAME";+ String OR_ADDITIONAL_HOSTNAMES = "OR_ADDITIONAL_HOSTNAMES";+ String OR_SSL_PORT = "OR_SSL_PORT";String OR_EMAIL_USER = "OR_EMAIL_USER";String OR_EMAIL_HOST = "OR_EMAIL_HOST";String OR_EMAIL_PASSWORD = "OR_EMAIL_PASSWORD";diff --git a/profile/demo.yml b/profile/demo.ymlindex 6774bbf19..52c6d0012 100644--- a/profile/demo.yml+++ b/profile/demo.yml@@ -28,7 +28,7 @@ services:- deployment-data:/deploymentproxy:- image: openremote/proxy:${PROXY_VERSION:-2.5.0.3}+ image: openremote/proxy:${PROXY_VERSION:-latest}restart: alwaysdepends_on:manager:@@ -41,28 +41,29 @@ services:- proxy-data:/deploymentenvironment:LE_EMAIL: ${OR_EMAIL_FROM:-}- DOMAINNAME: ${OR_HOST:-localhost}+ DOMAINNAME: ${OR_HOSTNAME:-localhost}+ DOMAINNAMES: ${OR_ADDTIONAL_HOSTNAMES:-}# USE A CUSTOM PROXY CONFIG - COPY FROM https://github.com/openremote/proxy/blob/main/haproxy.cfg#HAPROXY_CONFIG: '/data/proxy/haproxy.cfg'postgresql:restart: always- image: openremote/postgresql:${POSTGRESQL_VERSION:-14.1.0.1}+ image: openremote/postgresql:${POSTGRESQL_VERSION:-latest}volumes:- postgresql-data:/var/lib/postgresql/data- temp-data:/tmpkeycloak:restart: always- image: openremote/keycloak:${KEYCLOAK_VERSION:-16.0.0.0}+ image: openremote/keycloak:${KEYCLOAK_VERSION:-latest}depends_on:postgresql:condition: service_healthyvolumes:- ./deployment:/deploymentenvironment:- KEYCLOAK_PASSWORD: ${OR_ADMIN_PASSWORD:-secret}- KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}/auth+ KEYCLOAK_PASSWORD: ${OR_ADMIN_PASSWORD?OR_ADMIN_PASSWORD must be set}+ KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}/authmanager:restart: always@@ -73,7 +74,7 @@ services:environment:# Set this variable `demo` to auto provision demo assets etc.OR_SETUP_TYPE: ${OR_SETUP_TYPE:-demo}- OR_ADMIN_PASSWORD:+ OR_ADMIN_PASSWORD: ${OR_ADMIN_PASSWORD?OR_ADMIN_PASSWORD must be set}OR_SETUP_RUN_ON_RESTART:OR_EMAIL_HOST:OR_EMAIL_USER:@@ -81,7 +82,8 @@ services:OR_EMAIL_FROM:OR_EMAIL_ADMIN:OR_SSL_PORT: ${OR_SSL_PORT:-443}- OR_HOST: ${OR_HOST:-localhost}+ OR_HOSTNAME: ${OR_HOSTNAME:-localhost}+ OR_ADDITIONAL_HOSTNAMES: ${OR_ADDITIONAL_HOSTNAMES:-}OR_DEV_MODE: ${OR_DEV_MODE:-false}# The following variables will configure the demoOR_FORECAST_SOLAR_API_KEY:diff --git a/profile/deploy.yml b/profile/deploy.ymlindex c7486c983..1a9de012a 100644--- a/profile/deploy.yml+++ b/profile/deploy.yml@@ -11,7 +11,7 @@# Here's a list of commonly customised environment variables:## OR_ADMIN_PASSWORD-# OR_HOST+# OR_HOSTNAME# OR_EMAIL_HOST# OR_EMAIL_USER# OR_EMAIL_PASSWORD@@ -29,41 +29,47 @@ volumes:services:- # Reverse proxy which uses self signed certificate when DOMAINNAME=localhost. You can- # map a Docker volume or host directory to access/store proxy configuration files- # and SSL certificates.+ # Reverse proxy which auto-generates any Internet Assigned Numbers Authority TLD subdomain SSL certificates using+ # Lets Encrypt the domain name to generate a certificate for should be specified using DOMAINNAME (single domain name)+ # or DOMAINNAMES (multiple comma separated list of domain names). The proxy will fallback to self-signed certificate+ # for any requests for which a certificate doesn't exist. Custom certificates can be volume mapped into+ # /etc/haproxy/certs (note custom certificates must include the full chain including the private key). Can also volume+ # map a custom proxy config file.proxy:- image: openremote/proxy:${PROXY_VERSION:-2.5.0.3}+ image: openremote/proxy:${PROXY_VERSION:-latest}restart: always- volumes:- - proxy-data:/deployment+# volumes:+# - proxy-data:/deploymentenvironment:# It is important that all services have the same timezone and are time synchronized.# Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.TZ: ${TZ:-Europe/Amsterdam}- # File to which std out will be logged+ # File to which entrypoint logs are written in addition to std outLOGFILE: ${PROXY_LOGFILE:-/var/log/proxy.log}# Customize proxy log, defaults to 'notice', requests are logged at 'info'.# Available levels are: emerg, alert, crit, err, warning, notice, info, debugPROXY_LOGLEVEL: ${PROXY_LOGLEVEL:-notice}- # The public host name of this OpenRemote installation. Set this to request/manage an SSL- # certificate with the free https://letsencrypt.org/ provider. The default 'localhost' will- # rely on a baked-in self-signed certificate.- DOMAINNAME: ${OR_HOST:-localhost}+ # IANA TLD subdomain for which an SSL certificate should be requested (leave blank for private/externally+ # generated certificates).+ DOMAINNAME: ${OR_HOSTNAME:-localhost}++ # IANA TLD comma separated subdomains for which an SSL certificates should be requested (leave blank for+ # private/externally generated certificates); this is an alternative to DOMAINNAME for multiple domains.+ DOMAINNAMES: ${OR_ADDTIONAL_HOSTNAMES:-}# USE A CUSTOM PROXY CONFIG - COPY FROM https://github.com/openremote/proxy/blob/main/haproxy.cfg- HAPROXY_CONFIG: ${HAPROXY_CONFIG}+ HAPROXY_CONFIG: ${HAPROXY_CONFIG:-/etc/haproxy/haproxy.cfg}# Email address for SSL certificate issuance and expiration notifications.- LE_EMAIL: ${OR_EMAIL_ADMIN}+ LE_EMAIL: ${OR_EMAIL_ADMIN:-}# Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt# when testing (this is important, you are limited to 5 duplicate certificates per week!)- # e.g. '--staging --logs-dir=/etc/letsencrypt'+ # e.g. '--staging'LE_EXTRA_ARGS: ${PROXY_EXTRA_ARGS:-}# The proxy supports up to 10 custom redirects from hostname to any path on the@@ -138,16 +144,17 @@ services:# the keycloak identity provider).OR_ADMIN_PASSWORD: ${OR_ADMIN_PASSWORD:-secret}- # Can be used by SetupTasks to determine what assets etc. should be setup for this deployment- # the available values and general use of this is dependent on the actual SetupTasks available- # in the instance being deployed some basic recommendations are 'production', 'staging'+ # This value is passed to SetupTasks can be used to determine what assets etc. should be setup for this deployment+ # the available values and general use of this is dependent on the actual SetupTasks available in the instance+ # being deployed some basic recommendations are 'production', 'staging'OR_SETUP_TYPE: ${OR_SETUP_TYPE}- # The public HOSTNAME and SSL PORT of the proxy in front of this manager; must match the proxy#OR_HOST (unfortunately- # docker compose doesn't support chaining environment variables at time of writing, hence the need for- # two environment variables)+ # The public HOSTNAME and SSL PORT of this managerOR_SSL_PORT: ${OR_SSL_PORT:-443}- OR_HOST: ${OR_HOST:-localhost}+ OR_HOSTNAME: ${OR_HOSTNAME:-localhost}++ # Additional hostnames that should be allowed to access the auth server+ OR_ADDITIONAL_HOSTNAMES: ${OR_ADDITIONAL_HOSTNAMES:-}# Configure Email, SMTP server to send password reset emails etc.OR_EMAIL_HOST:@@ -173,9 +180,25 @@ services:# Default behaviour is false unless OR_DEV_MODE = true or openremote database doesn't already existOR_SETUP_RUN_ON_RESTART: ${OR_SETUP_RUN_ON_RESTART:-false}- # Manager web server interface binding; default:+ # Manager web server interface binding; default: 0.0.0.0OR_WEBSERVER_LISTEN_HOST: ${OR_WEBSERVER_LISTEN_HOST:-0.0.0.0}+ # Manager web server port (default: 8080)+ OR_WEBSERVER_LISTEN_PORT: ${OR_WEBSERVER_LISTEN_PORT:-8080}++ # Comma separated list of manager web server CORS allowed origins (can be a prefix, exact match or wildcard *)+ # These are in addition to the OR_HOSTNAME and OR_ADDITIONAL_HOSTNAMES which are implicitly allowed+ OR_WEBSERVER_ALLOWED_ORIGINS: ${OR_WEBSERVER_ALLOWED_ORIGINS:-}++ # Dump web server requests to logs; default: false+ OR_WEBSERVER_DUMP_REQUESTS: ${OR_WEBSERVER_DUMP_REQUESTS:-}++ # Manager web server maximum worker thread count; default: Processor core count or 10+ OR_WEBSERVER_WORKER_THREADS_MAX: ${OR_WEBSERVER_WORKER_THREADS_MAX:-}++ # Manager web server maximum IO thread count; default: Processor core count or 2+ OR_WEBSERVER_IO_THREADS_MAX: ${OR_WEBSERVER_IO_THREADS_MAX:-}+# Database settingsOR_DB_VENDOR: ${OR_DB_VENDOR:-postgres}OR_DB_HOST: ${OR_DB_HOST:-postgresql}@@ -192,6 +215,11 @@ services:OR_KEYCLOAK_HOST: ${OR_KEYCLOAK_HOST:-keycloak}OR_KEYCLOAK_PORT: ${OR_KEYCLOAK_PORT:-8080}+ # The frontend URL of the Keycloak identity provider used by this instance (defaults to http:// https://OR_HOSTNAME:OR_SSL_PORT/auth)+ # This is used in server info endpoint to inform frontend where the identity provider is for this instance (frontend apps should+ # assume identity provider is on the same host as this instance if it is not set)+ KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}/auth+# Location of built in web content.OR_APP_DOCROOT: ${OR_APP_DOCROOT:-/opt/web}@@ -278,7 +306,7 @@ services:# Keycloak identity providerkeycloak:- image: openremote/keycloak:${KEYCLOAK_VERSION:-16.0.0.0}+ image: openremote/keycloak:${KEYCLOAK_VERSION:-latest}restart: always# Map any custom themes into the /deployment/keycloak/themes dir:#volumes:@@ -307,9 +335,9 @@ services:KEYCLOAK_USER: ${KEYCLOAK_USER:-admin}KEYCLOAK_PASSWORD: ${OR_ADMIN_PASSWORD:-secret}PROXY_ADDRESS_FORWARDING: ${PROXY_ADDRESS_FORWARDING:-true}- KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}/auth+ KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}/auth# Use the following if OR_SSL_PORT is not the default 443- #KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}:${OR_SSL_PORT:-443}/auth+ #KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}:${OR_SSL_PORT:-443}/auth# Custom JVM options (increase heap size if required)JAVA_OPTS: ${KEYCLOAK_JAVA_OPTS:--XX:CompressedClassSpaceSize=50m -XX:MaxMetaspaceSize=250m@@ -323,7 +351,7 @@ services:# PostgreSQL DBMSpostgresql:- image: openremote/postgresql:${POSTGRESQL_VERSION:-14.1.0.1}+ image: openremote/postgresql:${POSTGRESQL_VERSION:-latest}restart: always# Docker volume for persistent storage of DB; can alternatively map to hostvolumes:diff --git a/profile/dev-proxy.yml b/profile/dev-proxy.ymlindex c1de04e75..e54f83ce9 100644--- a/profile/dev-proxy.yml+++ b/profile/dev-proxy.yml@@ -42,9 +42,9 @@ services:condition: service_healthyenvironment:# Use manager dev mode reverse proxy to access keycloak so manager and keycloak hosts match- KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}/auth+ KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}/auth# Use the following if OR_SSL_PORT is not the default 443- #KEYCLOAK_FRONTEND_URL: https://${OR_HOST:-localhost}:${OR_SSL_PORT:-443}/auth+ #KEYCLOAK_FRONTEND_URL: https://${OR_HOSTNAME:-localhost}:${OR_SSL_PORT:-443}/authpostgresql:extends:diff --git a/profile/dev-testing.yml b/profile/dev-testing.ymlindex fed661253..1c3e72078 100644--- a/profile/dev-testing.yml+++ b/profile/dev-testing.yml@@ -24,7 +24,7 @@ services:condition: service_healthyenvironment:# Use manager dev mode reverse proxy to access keycloak so manager and keycloak hosts match- KEYCLOAK_FRONTEND_URL: http://${OR_HOST:-localhost}:8080/auth+ KEYCLOAK_FRONTEND_URL: http://${OR_HOSTNAME:-localhost}:8080/authpostgresql:extends:diff --git a/profile/dev-ui.yml b/profile/dev-ui.ymlindex 9b6657e09..04588e45b 100644--- a/profile/dev-ui.yml+++ b/profile/dev-ui.yml@@ -27,7 +27,7 @@ services:condition: service_healthyenvironment:# Use manager dev mode reverse proxy to access keycloak so manager and keycloak hosts match- KEYCLOAK_FRONTEND_URL: http://${OR_HOST:-localhost}:8080/auth+ KEYCLOAK_FRONTEND_URL: http://${OR_HOSTNAME:-localhost}:8080/authpostgresql:extends:diff --git a/test/src/testFixtures/groovy/org/openremote/test/ContainerTrait.groovy b/test/src/testFixtures/groovy/org/openremote/test/ContainerTrait.groovyindex 9a0a3e784..2af23711d 100644--- a/test/src/testFixtures/groovy/org/openremote/test/ContainerTrait.groovy+++ b/test/src/testFixtures/groovy/org/openremote/test/ContainerTrait.groovy@@ -69,7 +69,7 @@ import java.util.stream.Collectorsimport java.util.stream.IntStreamimport static java.util.concurrent.TimeUnit.SECONDS-import static org.openremote.container.web.WebService.WEBSERVER_LISTEN_PORT+import static org.openremote.container.web.WebService.OR_WEBSERVER_LISTEN_PORTtrait ContainerTrait {@@ -90,7 +90,7 @@ trait ContainerTrait {if (currentConfig.size() == config.size()) {configsMatch = currentConfig.entrySet().stream().allMatch{entry ->// ignore webserver port config- if (entry.key == WEBSERVER_LISTEN_PORT) {+ if (entry.key == OR_WEBSERVER_LISTEN_PORT) {return true}entry.value == config.get(entry.key)@@ -422,7 +422,7 @@ trait ContainerTrait {int getServerPort() {if (container != null) {- return MapAccess.getInteger(container.getConfig(), WEBSERVER_LISTEN_PORT, 0)+ return MapAccess.getInteger(container.getConfig(), OR_WEBSERVER_LISTEN_PORT, 0)}return 0}diff --git a/test/src/testFixtures/groovy/org/openremote/test/ManagerContainerTrait.groovy b/test/src/testFixtures/groovy/org/openremote/test/ManagerContainerTrait.groovyindex a1d0fef85..af5604505 100644--- a/test/src/testFixtures/groovy/org/openremote/test/ManagerContainerTrait.groovy+++ b/test/src/testFixtures/groovy/org/openremote/test/ManagerContainerTrait.groovy@@ -15,7 +15,7 @@ import java.util.stream.Collectorsimport static org.openremote.container.timer.TimerService.Clock.PSEUDOimport static org.openremote.container.timer.TimerService.Clock.REALimport static org.openremote.container.timer.TimerService.TIMER_CLOCK_TYPE-import static org.openremote.container.web.WebService.WEBSERVER_LISTEN_PORT+import static org.openremote.container.web.WebService.OR_WEBSERVER_LISTEN_PORTimport static org.openremote.manager.mqtt.MqttBrokerService.MQTT_SERVER_LISTEN_HOSTtrait ManagerContainerTrait extends ContainerTrait {@@ -25,9 +25,9 @@ trait ManagerContainerTrait extends ContainerTrait {serverPort = findEphemeralPort()}[- (WEBSERVER_LISTEN_PORT) : Integer.toString(serverPort),- (MQTT_SERVER_LISTEN_HOST) : "127.0.0.1", // Works best for cross platform test running- (TIMER_CLOCK_TYPE) : PSEUDO.name()+ (OR_WEBSERVER_LISTEN_PORT): Integer.toString(serverPort),+ (MQTT_SERVER_LISTEN_HOST) : "127.0.0.1", // Works best for cross platform test running+ (TIMER_CLOCK_TYPE) : PSEUDO.name()]}diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.tsindex b8c003d73..a11f0badd 100644--- a/ui/component/core/src/index.ts+++ b/ui/component/core/src/index.ts@@ -137,10 +137,10 @@ export function normaliseConfig(config: ManagerConfig): ManagerConfig {if (!normalisedConfig.keycloakUrl || normalisedConfig.keycloakUrl === "") {// Assume keycloak is running on same host as the managernormalisedConfig.keycloakUrl = normalisedConfig.managerUrl + "/auth";- } else {- // Normalise by stripping any trailing slashes- normalisedConfig.keycloakUrl = normalisedConfig.keycloakUrl.replace(/\/+$/, "");}++ // Normalise by stripping any trailing slashes+ normalisedConfig.keycloakUrl = normalisedConfig.keycloakUrl.replace(/\/+$/, "");}if (normalisedConfig.consoleAutoEnable === undefined) {@@ -310,6 +310,7 @@ export class Manager implements EventProviderFactory {};private _keycloakUpdateTokenInterval?: number = undefined;private _managerVersion: string = "";+ public _authServerUrl: string = "";private _listeners: EventCallback[] = [];private _console!: Console;private _consoleAppConfig?: ConsoleAppConfig;@@ -347,14 +348,20 @@ export class Manager implements EventProviderFactory {console.log("Already initialised");}- let success = false;this._config = normaliseConfig(config);+ let success = await this.loadManagerInfo();+if (this._config.auth === Auth.BASIC) {- // BASIC auth will likely require UI so let's init translation at least+ // BASIC auth will likely require UI so lets init translation at leastsuccess = await this.doTranslateInit() && success;success = await this.doAuthInit();} else {++ if (this._authServerUrl) {+ this.config.keycloakUrl = this._authServerUrl;+ }+success = await this.doAuthInit();// If failed then we can assume keycloak auth requested but unavailable@@ -366,10 +373,6 @@ export class Manager implements EventProviderFactory {}}- if (success) {- success = await this.doInit();- }-if (success) {success = this.doRestApiInit();}@@ -383,6 +386,8 @@ export class Manager implements EventProviderFactory {success = await this.getConsoleAppConfig();}+ this.doIconInit();+// TODO: Reinstate this once websocket supports anonymous connections// if (success) {// success = await this.doEventsSubscriptionInit();@@ -403,7 +408,7 @@ export class Manager implements EventProviderFactory {return success;}- protected async doInit(): Promise<boolean> {+ protected async loadManagerInfo(): Promise<boolean> {// Check manager exists by calling the info endpointtry {const json = await new Promise<any>((resolve, reject) => {@@ -418,18 +423,7 @@ export class Manager implements EventProviderFactory {oReq.send();});this._managerVersion = json && json.version ? json.version : "";-- // Load material design and OR icon sets if requested- if (this._config.loadIcons) {- IconSets.addIconSet(- "mdi",- createMdiIconSet(manager.config.managerUrl!)- );- IconSets.addIconSet(- "or",- createSvgIconSet(OrIconSet.size, OrIconSet.icons)- );- }+ this._authServerUrl = json && json.authServerUrl ? json.authServerUrl : "";return true;} catch (e) {@@ -612,6 +606,20 @@ export class Manager implements EventProviderFactory {}}+ protected doIconInit() {+ // Load material design and OR icon sets if requested+ if (this._config.loadIcons) {+ IconSets.addIconSet(+ "mdi",+ createMdiIconSet(manager.config.managerUrl!)+ );+ IconSets.addIconSet(+ "or",+ createSvgIconSet(OrIconSet.size, OrIconSet.icons)+ );+ }+ }+protected async getConsoleAppConfig(): Promise<boolean> {try {const response = await fetch(manager.config.managerUrl + "/consoleappconfig/" + manager.displayRealm + ".json");