diff --git a/horreum-backend/src/main/resources/application.properties b/horreum-backend/src/main/resources/application.properties index b0fb8c7f3..08d187aad 100644 --- a/horreum-backend/src/main/resources/application.properties +++ b/horreum-backend/src/main/resources/application.properties @@ -100,8 +100,8 @@ quarkus.keycloak.admin-client.grant-type=CLIENT_CREDENTIALS %dev.quarkus.keycloak.admin-client.client-id=admin-cli %dev.quarkus.keycloak.admin-client.realm=master %dev.quarkus.keycloak.admin-client.grant-type=PASSWORD -%dev.quarkus.keycloak.admin-client.username=admin -%dev.quarkus.keycloak.admin-client.password=secret +%dev.quarkus.keycloak.admin-client.username=${horreum.dev-services.keycloak.admin-username} +%dev.quarkus.keycloak.admin-client.password=${horreum.dev-services.keycloak.admin-password} # Secret used to sign database rows horreum.db.secret=secret diff --git a/infra/horreum-dev-services/deployment/src/main/java/io/hyperfoil/tools/horreum/dev/services/deployment/HorreumDevServicesProcessor.java b/infra/horreum-dev-services/deployment/src/main/java/io/hyperfoil/tools/horreum/dev/services/deployment/HorreumDevServicesProcessor.java index e98e7107a..dc670b849 100644 --- a/infra/horreum-dev-services/deployment/src/main/java/io/hyperfoil/tools/horreum/dev/services/deployment/HorreumDevServicesProcessor.java +++ b/infra/horreum-dev-services/deployment/src/main/java/io/hyperfoil/tools/horreum/dev/services/deployment/HorreumDevServicesProcessor.java @@ -126,6 +126,8 @@ public void startHorreumContainers( keycloakConfig.put("horreum.keycloak.url", keycloakURL); keycloakConfig.put("quarkus.oidc.auth-server-url", keycloakURL + "/realms/horreum"); keycloakConfig.put("quarkus.oidc.credentials.secret", envvars.get("quarkus.oidc.credentials.secret")); + keycloakConfig.put(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME, horreumBuildTimeConfig.keycloak.adminUsername); + keycloakConfig.put(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD, horreumBuildTimeConfig.keycloak.adminPassword); if (envvars.containsKey("quarkus.oidc.tls.trust-store-file")) { keycloakConfig.put("quarkus.oidc.tls.trust-store-file", envvars.get("quarkus.oidc.tls.trust-store-file")); keycloakConfig.put("quarkus.oidc.tls.verification", "required"); // "certificate-validation" validates the certificate chain, but not the hostname. could also be "none" and disable TLS verification altogether diff --git a/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/HorreumResources.java b/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/HorreumResources.java index ac99bad1d..16252cc92 100644 --- a/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/HorreumResources.java +++ b/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/HorreumResources.java @@ -163,14 +163,11 @@ public static Map startContainers(Map initArgs) envVariables.put("quarkus.oidc.auth-server-url", keycloakEnv.get("keycloak.host").concat("/realms/").concat(HORREUM_REALM)); envVariables.putAll(oidcTruststoreProperties(initArgs)); - String keycloakAdminUser = initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME); - String keycloakAdminPassword = initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD); - keycloak = KeycloakBuilder.builder() .serverUrl(keycloakEnv.get("keycloak.host")) .realm(KEYCLOAK_REALM) - .username(keycloakAdminUser) - .password(keycloakAdminPassword) + .username(initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME)) + .password(initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD)) .clientId("admin-cli") .resteasyClient(((ResteasyClientBuilder) ClientBuilder.newBuilder()).disableTrustManager().build()) .build(); diff --git a/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/resources/KeycloakResource.java b/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/resources/KeycloakResource.java index 692312da3..52f3e0974 100644 --- a/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/resources/KeycloakResource.java +++ b/infra/horreum-infra-common/src/main/java/io/hyperfoil/tools/horreum/infra/common/resources/KeycloakResource.java @@ -39,9 +39,6 @@ public void init(Map initArgs) { throw new RuntimeException("Arguments did not contain Keycloak image"); } - final String JDBC_URL = initArgs.get("quarkus.datasource.jdbc.url.internal"); - final String DB_PORT = initArgs.get("postgres.container.port"); - final String KEYCLOAK_IMAGE = initArgs.get(HORREUM_DEV_KEYCLOAK_IMAGE); networkAlias = initArgs.get(HORREUM_DEV_KEYCLOAK_NETWORK_ALIAS); @@ -73,7 +70,7 @@ public void init(Map initArgs) { .env("KC_HTTP_ENABLED", "true") .env("KC_HOSTNAME_STRICT", "false") .env("DB_DATABASE", "keycloak") - .env("KC_DB_URL", JDBC_URL) + .env("KC_DB_URL", initArgs.get("quarkus.datasource.jdbc.url.internal")) .run("/opt/keycloak/bin/kc.sh build") .entryPoint("/opt/keycloak/bin/kc.sh ${KEYCLOAK_COMMAND:-start-dev} --import-realm $EXTRA_OPTIONS") .build()).withFileFromFile("/tmp/keycloak-horreum.json", tempKeycloakRealmFile); @@ -100,7 +97,7 @@ public void init(Map initArgs) { .withEnv("KC_DB_URL_HOST", "") .withEnv("KC_HOSTNAME_STRICT", "false") .withEnv("KC_HOSTNAME", "localhost") - .withEnv("KC_DB_URL", "jdbc:postgresql://172.17.0.1:" + DB_PORT + "/keycloak") + .withEnv("KC_DB_URL", "jdbc:postgresql://" + initArgs.get(HORREUM_DEV_POSTGRES_NETWORK_ALIAS) + ":5432/keycloak") .withCommand("-Dquarkus.http.http2=false", "start-dev"); }