Commit 15ab43dd authored by Diego Molteni's avatar Diego Molteni
Browse files

generalized the imposed TLS mode

parent 09529809
Pipeline #25877 failed with stages
in 2 minutes and 35 seconds
......@@ -27,9 +27,11 @@ export interface ConfigModel {
LOCKSMAP_REDIS_INSTANCE_ADDRESS: string;
LOCKSMAP_REDIS_INSTANCE_PORT: number;
LOCKSMAP_REDIS_INSTANCE_KEY?: string;
LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE?: boolean;
DES_REDIS_INSTANCE_ADDRESS: string;
DES_REDIS_INSTANCE_PORT: number;
DES_REDIS_INSTANCE_KEY?: string;
DES_REDIS_INSTANCE_TLS_DISABLE?: boolean;
DES_SERVICE_HOST_ENTITLEMENT: string;
DES_SERVICE_HOST_COMPLIANCE: string;
DES_SERVICE_HOST_STORAGE: string;
......@@ -57,9 +59,6 @@ export abstract class Config implements IConfig {
// Unit Test activation flag
public static UTEST: string;
// Cache TLS DISABLE flag
public static CACHE_TLS_DISABLE: string;
// Service base configurations
public static SERVICE_ENV: string;
public static SERVICE_PORT: number;
......@@ -93,11 +92,13 @@ export abstract class Config implements IConfig {
public static LOCKSMAP_REDIS_INSTANCE_ADDRESS: string;
public static LOCKSMAP_REDIS_INSTANCE_PORT: number;
public static LOCKSMAP_REDIS_INSTANCE_KEY: string;
public static LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE: boolean;
// Redis cache for DataEcosystem results
public static DES_REDIS_INSTANCE_ADDRESS: string;
public static DES_REDIS_INSTANCE_PORT: number;
public static DES_REDIS_INSTANCE_KEY: string;
public static DES_REDIS_INSTANCE_KEY_TLS_DISABLE: boolean;
// DataEcosystem Configuration
public static DES_SERVICE_HOST_ENTITLEMENT: string;
......@@ -145,6 +146,7 @@ export abstract class Config implements IConfig {
Config.LOCKSMAP_REDIS_INSTANCE_ADDRESS = model.LOCKSMAP_REDIS_INSTANCE_ADDRESS;
Config.LOCKSMAP_REDIS_INSTANCE_PORT = model.LOCKSMAP_REDIS_INSTANCE_PORT;
Config.LOCKSMAP_REDIS_INSTANCE_KEY = model.LOCKSMAP_REDIS_INSTANCE_KEY;
Config.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE = model.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE || false;
Config.DES_REDIS_INSTANCE_ADDRESS =
model.DES_REDIS_INSTANCE_ADDRESS || model.LOCKSMAP_REDIS_INSTANCE_ADDRESS;
......@@ -152,6 +154,8 @@ export abstract class Config implements IConfig {
model.DES_REDIS_INSTANCE_PORT || model.LOCKSMAP_REDIS_INSTANCE_PORT;
Config.DES_REDIS_INSTANCE_KEY =
model.DES_REDIS_INSTANCE_KEY || model.LOCKSMAP_REDIS_INSTANCE_KEY;
Config.DES_REDIS_INSTANCE_KEY_TLS_DISABLE =
model.DES_REDIS_INSTANCE_TLS_DISABLE || model.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE;
Config.FEATURE_FLAG_AUTHORIZATION = model.FEATURE_FLAG_AUTHORIZATION;
Config.FEATURE_FLAG_LEGALTAG = model.FEATURE_FLAG_LEGALTAG;
......@@ -219,6 +223,3 @@ export class ConfigFactory extends CloudFactory {
// Set the Utest flag correctly as sooon as the config class get loaded
Config.UTEST = process.env.UTEST;
// Set the CACHE(REDIS) TLS DISABLE flag correctly. If not SET TLS is assume enabled so that change is non breaking
Config.CACHE_TLS_DISABLE = process.env.CACHE_TLS_DISABLE;
......@@ -112,7 +112,8 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
this._storageConfigs = new Cache<string>({
ADDRESS: AzureConfig.DES_REDIS_INSTANCE_ADDRESS,
PORT: AzureConfig.DES_REDIS_INSTANCE_PORT,
KEY: AzureConfig.DES_REDIS_INSTANCE_KEY
KEY: AzureConfig.DES_REDIS_INSTANCE_KEY,
DISABLE_TLS: AzureConfig.DES_REDIS_INSTANCE_KEY_TLS_DISABLE,
}, 'storage')
}
......@@ -137,7 +138,8 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
this._cosmosConfigs = new Cache<string>({
ADDRESS: AzureConfig.DES_REDIS_INSTANCE_ADDRESS,
PORT: AzureConfig.DES_REDIS_INSTANCE_PORT,
KEY: AzureConfig.DES_REDIS_INSTANCE_KEY
KEY: AzureConfig.DES_REDIS_INSTANCE_KEY,
DISABLE_TLS: AzureConfig.DES_REDIS_INSTANCE_KEY_TLS_DISABLE,
}, 'cosmos')
}
......
......@@ -92,9 +92,14 @@ export class IbmConfig extends Config {
IbmConfig.LOCKSMAP_REDIS_INSTANCE_PORT = +process.env.REDIS_INSTANCE_PORT
IbmConfig.LOCKSMAP_REDIS_INSTANCE_ADDRESS = process.env.LOCKSMAP_REDIS_INSTANCE_ADDRESS
IbmConfig.LOCKSMAP_REDIS_INSTANCE_KEY = process.env.LOCKSMAP_REDIS_INSTANCE_KEY
IbmConfig.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE =
process.env.CACHE_TLS_DISABLE ? process.env.CACHE_TLS_DISABLE === 'true' : false;
IbmConfig.DES_REDIS_INSTANCE_ADDRESS = process.env.DES_REDIS_INSTANCE_ADDRESS
IbmConfig.DES_REDIS_INSTANCE_PORT = +process.env.DES_REDIS_INSTANCE_PORT
IbmConfig.DES_REDIS_INSTANCE_KEY = process.env.DES_REDIS_INSTANCE_KEY
IbmConfig.DES_REDIS_INSTANCE_KEY_TLS_DISABLE =
process.env.CACHE_TLS_DISABLE ? process.env.CACHE_TLS_DISABLE === 'true' : false;
//Logger
IbmConfig.LOGGER_LEVEL = process.env.LOGGER_LEVEL || 'debug';
......@@ -110,9 +115,11 @@ export class IbmConfig extends Config {
LOCKSMAP_REDIS_INSTANCE_ADDRESS: IbmConfig.LOCKSMAP_REDIS_INSTANCE_ADDRESS,
LOCKSMAP_REDIS_INSTANCE_PORT: IbmConfig.LOCKSMAP_REDIS_INSTANCE_PORT,
LOCKSMAP_REDIS_INSTANCE_KEY: IbmConfig.LOCKSMAP_REDIS_INSTANCE_KEY,
LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE: IbmConfig.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE,
DES_REDIS_INSTANCE_ADDRESS: IbmConfig.DES_REDIS_INSTANCE_ADDRESS,
DES_REDIS_INSTANCE_PORT: IbmConfig.DES_REDIS_INSTANCE_PORT,
DES_REDIS_INSTANCE_KEY: IbmConfig.DES_REDIS_INSTANCE_KEY,
DES_REDIS_INSTANCE_TLS_DISABLE: IbmConfig.DES_REDIS_INSTANCE_KEY_TLS_DISABLE,
DES_SERVICE_HOST_COMPLIANCE: IbmConfig.DES_SERVICE_HOST_COMPLIANCE,
DES_SERVICE_HOST_ENTITLEMENT: IbmConfig.DES_SERVICE_HOST_ENTITLEMENT,
DES_SERVICE_HOST_STORAGE: IbmConfig.DES_SERVICE_HOST_STORAGE,
......
......@@ -31,7 +31,8 @@ export class DESCompliance {
this._cache = new Cache<boolean>({
ADDRESS: Config.DES_REDIS_INSTANCE_ADDRESS,
PORT: Config.DES_REDIS_INSTANCE_PORT,
KEY: Config.DES_REDIS_INSTANCE_KEY
KEY: Config.DES_REDIS_INSTANCE_KEY,
DISABLE_TLS: Config.DES_REDIS_INSTANCE_KEY_TLS_DISABLE,
}, 'ltag')
}
......
......@@ -48,12 +48,11 @@ export class Locker {
} else {
const redis = require('redis');
if(Config.LOCKSMAP_REDIS_INSTANCE_KEY) {
Config.CACHE_TLS_DISABLE ?
Config.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE ?
this.redisClient = redis.createClient({
host: Config.LOCKSMAP_REDIS_INSTANCE_ADDRESS,
port: Config.LOCKSMAP_REDIS_INSTANCE_PORT,
auth_pass: Config.LOCKSMAP_REDIS_INSTANCE_KEY,
///tls: {servername: Config.LOCKSMAP_REDIS_INSTANCE_ADDRESS}
}):
this.redisClient = redis.createClient({
host: Config.LOCKSMAP_REDIS_INSTANCE_ADDRESS,
......
......@@ -21,7 +21,8 @@ import { Config } from '../cloud';
export interface ICacheParameters {
ADDRESS: string;
PORT: number;
KEY?: string
KEY?: string;
DISABLE_TLS?: boolean;
}
export class Cache<T=string> {
......@@ -37,7 +38,7 @@ export class Cache<T=string> {
this._redisClient =
Config.UTEST ?
require('redis-mock').createClient() :
connection.KEY ? Config.CACHE_TLS_DISABLE ?
connection.KEY ? connection.DISABLE_TLS ?
redis.createClient({
host: connection.ADDRESS,
port: connection.PORT,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment