fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awa...@apache.org
Subject [fineract] branch develop updated: Allow customizing Tenants DB JDBC uid/pwd/driver (FINERACT-806) (#713)
Date Sun, 09 Feb 2020 18:37:07 GMT
This is an automated email from the ASF dual-hosted git repository.

awasum pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 228ec22  Allow customizing Tenants DB JDBC uid/pwd/driver (FINERACT-806) (#713)
228ec22 is described below

commit 228ec22a60558a02b4e7b8862632c60485847224
Author: Michael Vorburger ⛑️ <vorburger@apache.org>
AuthorDate: Sun Feb 9 19:36:58 2020 +0100

    Allow customizing Tenants DB JDBC uid/pwd/driver (FINERACT-806) (#713)
    
    * Allow customizing Tenants DB JDBC uid/pwd/driver (FINERACT-806)
    
    Added Java system properties for username and password to docker-compose
    
    Modified sever.xml to get username and password
    
    * Fixes for customizing Tenants DB JDBC uid/pwd/driver (FINERACT-806)
    
    * Use random MYSQL_ROOT_PASSWORD in docker-compose.yml (FINERACT-806)
    
    This provides future non-regression testing that the the customized
    MySQL password is actually really used, and it doesn't just work because
    "mysql" is still hard-coded anywhere.
    
    Co-authored-by: Yemdjih Kaze Nasser <kaze.nasser@outlook.com>
---
 docker-compose.yml                                 |  6 +++--
 docker/server.xml                                  |  6 ++---
 .../core/service/TenantDatabaseUpgradeService.java | 30 ++++++++++++----------
 .../list_db/V1__mifos-platform-shared-tenants.sql  |  2 +-
 4 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/docker-compose.yml b/docker-compose.yml
index 88515c0..0e7ef23 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -26,7 +26,7 @@ services:
       - ./fineract-db/docker:/docker-entrypoint-initdb.d:Z,ro
     restart: always
     environment:
-      MYSQL_ROOT_PASSWORD: mysql
+      MYSQL_ROOT_PASSWORD: skdcnwauicn2ucnaecasdsajdnizucawencascdca
     healthcheck:
       test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
       timeout: 10s
@@ -43,6 +43,8 @@ services:
     depends_on:
       - fineractmysql
     environment:
-      - JAVA_OPTS=-Dfineract_tenants_url=jdbc:mysql:thin://fineractmysql:3306/mifosplatform-tenants
-Djava.awt.headless=true -XX:+UseG1GC -Dfile.encoding=UTF-8
+      - JAVA_OPTS=-Dfineract_tenants_url=jdbc:mysql:thin://fineractmysql:3306/mifosplatform-tenants
-Dfineract_tenants_driver=org.drizzle.jdbc.DrizzleDriver -Dfineract_tenants_uid=root -Dfineract_tenants_pwd=skdcnwauicn2ucnaecasdsajdnizucawencascdca
-Djava.awt.headless=true -XX:+UseG1GC -Dfile.encoding=UTF-8
       - FINERACT_DEFAULT_TENANTDB_HOSTNAME=fineractmysql
       - FINERACT_DEFAULT_TENANTDB_PORT=3306
+      - FINERACT_DEFAULT_TENANTDB_UID=root
+      - FINERACT_DEFAULT_TENANTDB_PWD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
diff --git a/docker/server.xml b/docker/server.xml
index 9c8e23a..954609c 100644
--- a/docker/server.xml
+++ b/docker/server.xml
@@ -41,10 +41,10 @@
      <Resource type="javax.sql.DataSource"
         name="jdbc/mifosplatform-tenants"
         factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
-        driverClassName="org.drizzle.jdbc.DrizzleDriver"
+        driverClassName="${fineract_tenants_driver}"
         url="${fineract_tenants_url}"
-        username="root"
-        password="mysql"
+        username="${fineract_tenants_uid}"
+        password="${fineract_tenants_pwd}"
         initialSize="3"
         maxActive="10"
         maxIdle="6"
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
index 2f0ec8e..b3fca71 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
@@ -43,7 +43,7 @@ import org.springframework.stereotype.Service;
 @Service
 public class TenantDatabaseUpgradeService {
 
- private final static Logger LOG = LoggerFactory.getLogger(TenantDatabaseUpgradeService.class);
+    private final static Logger LOG = LoggerFactory.getLogger(TenantDatabaseUpgradeService.class);
 
     private final TenantDetailsService tenantDetailsService;
     protected final DataSource tenantDataSource;
@@ -88,27 +88,31 @@ public class TenantDatabaseUpgradeService {
      * itself.
      */
     private void upgradeTenantDB() {
-     String dbHostname = getEnvVar("FINERACT_DEFAULT_TENANTDB_HOSTNAME", "localhost");
-     String dbPort = getEnvVar("FINERACT_DEFAULT_TENANTDB_PORT", "3306");
-     LOG.info("upgradeTenantDB: FINERACT_DEFAULT_TENANTDB_HOSTNAME = {}, FINERACT_DEFAULT_TENANTDB_PORT
= {}", dbHostname, dbPort);
+        String dbHostname = getEnvVar("FINERACT_DEFAULT_TENANTDB_HOSTNAME", "localhost");
+        String dbPort = getEnvVar("FINERACT_DEFAULT_TENANTDB_PORT", "3306");
+        String dbUid = getEnvVar("FINERACT_DEFAULT_TENANTDB_UID", "root");
+        String dbPwd = getEnvVar("FINERACT_DEFAULT_TENANTDB_PWD", "mysql");
+        LOG.info("upgradeTenantDB: FINERACT_DEFAULT_TENANTDB_HOSTNAME = {}, FINERACT_DEFAULT_TENANTDB_PORT
= {}", dbHostname, dbPort);
 
         final Flyway flyway = new Flyway();
         flyway.setDataSource(tenantDataSource);
         flyway.setLocations("sql/migrations/list_db");
         flyway.setOutOfOrder(true);
         flyway.setPlaceholders(ImmutableMap.of( // FINERACT-773
-            "fineract_default_tenantdb_hostname", dbHostname,
-            "fineract_default_tenantdb_port",     dbPort));
+                "fineract_default_tenantdb_hostname", dbHostname,
+                "fineract_default_tenantdb_port",     dbPort,
+                "fineract_default_tenantdb_uid",      dbUid,
+                "fineract_default_tenantdb_pwd",      dbPwd));
         flyway.migrate();
 
         tenantDataSourcePortFixService.fixUpTenantsSchemaServerPort();
     }
 
- private String getEnvVar(String name, String defaultValue) {
-  String value = System.getenv(name);
-  if (value == null) {
-   return defaultValue;
-  }
-  return value;
- }
+    private String getEnvVar(String name, String defaultValue) {
+        String value = System.getenv(name);
+        if (value == null) {
+            return defaultValue;
+        }
+        return value;
+    }
 }
diff --git a/fineract-provider/src/main/resources/sql/migrations/list_db/V1__mifos-platform-shared-tenants.sql
b/fineract-provider/src/main/resources/sql/migrations/list_db/V1__mifos-platform-shared-tenants.sql
index 4cc1f95..9c6adc4 100644
--- a/fineract-provider/src/main/resources/sql/migrations/list_db/V1__mifos-platform-shared-tenants.sql
+++ b/fineract-provider/src/main/resources/sql/migrations/list_db/V1__mifos-platform-shared-tenants.sql
@@ -66,7 +66,7 @@ CREATE TABLE `tenants` (
 
 LOCK TABLES `tenants` WRITE;
 /*!40000 ALTER TABLE `tenants` DISABLE KEYS */;
-INSERT INTO `tenants` VALUES (1,'default','Default Demo Tenant','mifostenant-default','Asia/Kolkata',NULL,NULL,NULL,NULL,'${fineract_default_tenantdb_hostname}','${fineract_default_tenantdb_port}','root','mysql',1);
+INSERT INTO `tenants` VALUES (1,'default','Default Demo Tenant','mifostenant-default','Asia/Kolkata',NULL,NULL,NULL,NULL,'${fineract_default_tenantdb_hostname}','${fineract_default_tenantdb_port}','${fineract_default_tenantdb_uid}','${fineract_default_tenantdb_pwd}',1);
 -- Add tenants to support interoperation multi-tenancy
 -- INSERT INTO `tenants` VALUES (2,'tn01','Buffalo','tn01','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
 -- INSERT INTO `tenants` VALUES (3,'tn02','Lion','tn02','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);


Mime
View raw message