Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Support customization of default password for demo data import

Christian Bauer07c46a5a973f
diff --git a/manager/server/src/main/java/org/openremote/manager/server/DemoDataService.java b/manager/server/src/main/java/org/openremote/manager/server/DemoDataService.java
index 12988c05a..edaa4e3ab 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/DemoDataService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/DemoDataService.java
@@ -59,22 +59,12 @@ public class DemoDataService implements ContainerService {
private static final Logger LOG = Logger.getLogger(DemoDataService.class.getName());
- public static final String IMPORT_DEMO_DATA = "IMPORT_DEMO_DATA";
- public static final boolean IMPORT_DEMO_DATA_DEFAULT = false;
-
- public static final String DEMO_CONTROLLER_HOST = "DEMO_CONTROLLER_HOST";
- public static final String DEMO_CONTROLLER_HOST_DEFAULT = "192.168.99.100";
- public static final String DEMO_CONTROLLER_PORT = "DEMO_CONTROLLER_PORT";
- public static final int DEMO_CONTROLLER_PORT_DEFAULT = 8083;
- public static final String DEMO_CONTROLLER_USERNAME = "DEMO_CONTROLLER_USERNAME";
- public static final String DEMO_CONTROLLER_USERNAME_DEFAULT = "";
- public static final String DEMO_CONTROLLER_PASSWORD = "DEMO_CONTROLLER_PASSWORD";
- public static final String DEMO_CONTROLLER_PASSWORD_DEFAULT = "";
- public static final String DEMO_CONTROLLER_SECURE = "DEMO_CONTROLLER_SECURE";
- public static final boolean DEMO_CONTROLLER_SECURE_DEFAULT = false;
-
public static final String ADMIN_CLI_CLIENT_ID = "admin-cli";
- public static final String ADMIN_PASSWORD = "CHANGE_ME_ADMIN_PASSWORD";
+
+ public static final String DEMO_IMPORT_DATA = "DEMO_IMPORT_DATA";
+ public static final boolean DEMO_IMPORT_DATA_DEFAULT = false;
+ public static final String DEMO_ADMIN_PASSWORD = "DEMO_ADMIN_PASSWORD";
+ public static final String DEMO_ADMIN_PASSWORD_DEFAULT = "CHANGE_ME_ADMIN_PASSWORD";
public static String DEMO_AGENT_ID = null;
public static String DEMO_THING_ID = null;
@@ -101,15 +91,16 @@ public class DemoDataService implements ContainerService {
@Override
public void start(Container container) {
- if (!container.isDevMode() && !getBoolean(container.getConfig(), IMPORT_DEMO_DATA, IMPORT_DEMO_DATA_DEFAULT)) {
+ if (!container.isDevMode() && !getBoolean(container.getConfig(), DEMO_IMPORT_DATA, DEMO_IMPORT_DATA_DEFAULT)) {
return;
}
LOG.info("--- IMPORTING DEMO DATA ---");
// Use a non-proxy client to get the access token
+ String demoAdminPassword = container.getConfig().getOrDefault(DEMO_ADMIN_PASSWORD, DEMO_ADMIN_PASSWORD_DEFAULT);
String accessToken = identityService.getKeycloak().getAccessToken(
- MASTER_REALM, new AuthForm(ADMIN_CLI_CLIENT_ID, MASTER_REALM_ADMIN_USER, ADMIN_PASSWORD)
+ MASTER_REALM, new AuthForm(ADMIN_CLI_CLIENT_ID, MASTER_REALM_ADMIN_USER, demoAdminPassword)
).getToken();
try {
@@ -347,7 +338,7 @@ public class DemoDataService implements ContainerService {
SimulatorProtocol.META_NAME_ELEMENT, Json.create("color")
))
),
- new Attribute("light1PowerConsumption", DECIMAL, Json.create(12.345))
+ new Attribute("light1PowerConsumption", DECIMAL, Json.create(12.333))
.setMetadata(new Metadata()
.add(new MetadataItem(
AssetAttributeMeta.DESCRIPTION.getName(),
diff --git a/profile/dependencies/keycloak.yml b/profile/dependencies/keycloak.yml
index 268f669e2..36ff801cd 100644
--- a/profile/dependencies/keycloak.yml
+++ b/profile/dependencies/keycloak.yml
@@ -16,7 +16,8 @@ services:
KEYCLOAK_USER: admin
# Change the admin root password if you make this application publicly accessible! Note
# that imported demo data uses the admin account and also creates a 'test' user with
- # password 'test'. This should not be imported in production.
+ # password 'test'. Importing will be broken if you change the password only here.
+ # Demo data should not be imported in production.
KEYCLOAK_PASSWORD: CHANGE_ME_ADMIN_PASSWORD
# Configure how Keycloak connects to the database
diff --git a/profile/manager.yml b/profile/manager.yml
index ea0770661..b5e9b51ed 100644
--- a/profile/manager.yml
+++ b/profile/manager.yml
@@ -38,8 +38,9 @@ services:
# If this is the first time you are starting this stack, and/or with non-durable
# database (the default), you might want to work with some automatically imported
- # demo data.
- IMPORT_DEMO_DATA: 'true'
+ # demo data. The importer uses the Keycloak admin-cli user and the given password.
+ DEMO_IMPORT_DATA: 'true'
+ DEMO_ADMIN_PASSWORD: CHANGE_ME_ADMIN_PASSWORD
# The service-internal interface and port to listen on. This should not be changed.
WEBSERVER_LISTEN_HOST: 0.0.0.0