Skip to content

Commit

Permalink
Encrypt passwords in config file
Browse files Browse the repository at this point in the history
Passwords for configured mirth systems are now encrypted. Any plain text passwords found in the configuration file should automatically be encrypted when configuration changes.
  • Loading branch information
odoodo authored Oct 18, 2024
1 parent 793988d commit d60ca33
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions web/MirthMigrator/js/MirthMigratorConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ function saveSettings(){
var configuration = generateConfiguration();

// check if the configuration has changed
var configurationHasChanged = (loadedConfigChecksum != calculateChecksum(configuration));
var configurationHasChanged = (loadedConfigChecksum != configuration.checksum);
// reset the marker
loadedConfigChecksum = null;

// remove the checksum from the configuration
delete configuration.checksum;

// only if the configuration has changed
if(configurationHasChanged){
// save the changes and force the active users to restart their session
Expand Down Expand Up @@ -174,9 +176,10 @@ function getEnvironmentConfiguration(){

/**
* Creates a JSON array from the configuration table for the Mirth instances
* @param {boolean} encryptPasswords If this flag is set, the passwords will be encrypted
* @return {Object[]} a JSON array containing Mirth instance definitions
*/
function getSystemConfiguration(){
function getSystemConfiguration(encryptPasswords){
var systems = [];

// read all environment configurations from the table
Expand All @@ -192,6 +195,9 @@ function getSystemConfiguration(){
var port = +$(this).find('td').eq(3).find('input').val();
var user = $(this).find('td').eq(4).find('input').val().trim();
var password = $(this).find('td').eq(5).find('input').val().trim();
if(encryptPasswords){
password = encrypt(password);
}
var environment = $(this).find('td').eq(6).find('#environment').val();

// add the Mirth instance to the list
Expand Down Expand Up @@ -233,14 +239,19 @@ function getMiscConfiguration(){
return {"sessionLifeSpanInMinutes": $('#sessionLifespann').val().trim()};
}

/**
* Generates the configuration
* @return The configuration as JSON object
*/
function generateConfiguration(){
var configuration ={};

configuration.environment = getEnvironmentConfiguration();
configuration.sessionLifeSpanInMinutes = +getMiscConfiguration().sessionLifeSpanInMinutes;
configuration.system = getSystemConfiguration();
configuration.excludeFromFunctionDetection = getFunctionFilterConfiguration();

configuration.checksum = calculateChecksum(configuration);
configuration.system = getSystemConfiguration(true);
return configuration;
}

Expand Down

0 comments on commit d60ca33

Please sign in to comment.