Commit f9cc118b authored by Diego Molteni's avatar Diego Molteni
Browse files

added multi des host support

parent 862e7e49
......@@ -30,7 +30,10 @@ export interface ConfigModel {
DES_REDIS_INSTANCE_ADDRESS: string;
DES_REDIS_INSTANCE_PORT: number;
DES_REDIS_INSTANCE_KEY?: string;
DES_SERVICE_HOST: string;
DES_SERVICE_HOST_ENTITLEMENT: string;
DES_SERVICE_HOST_COMPLIANCE: string;
DES_SERVICE_HOST_STORAGE: string;
DES_SERVICE_HOST_PARTITION: string;
DES_SERVICE_APPKEY: string;
DES_GROUP_CHAR_LIMIT: number;
JWKS_URL: string;
......@@ -94,14 +97,13 @@ export abstract class Config implements IConfig {
public static DES_REDIS_INSTANCE_KEY: string;
// DataEcosystem Configuration
public static DES_SERVICE_HOST: string;
public static DES_SERVICE_HOST_ENTITLEMENT: string;
public static DES_SERVICE_HOST_COMPLIANCE: string;
public static DES_SERVICE_HOST_STORAGE: string;
public static DES_SERVICE_HOST_PARTITION: string;
public static DES_SERVICE_APPKEY: string;
public static DES_GROUP_CHAR_LIMIT: number;
public static DE_FORWARD_APPKEY = Symbol('seismic-dms-fw-caller-appkey');
//IBM
public static DES_SERVICE_HOST_ENTITLEMENT: string;//IBM
public static DES_SERVICE_HOST_COMPLIANCE: string;//IBM
public static DES_SERVICE_HOST_STORAGE: string;//IBM
// JWT Validation
public static JWKS_URL: string;
......@@ -157,7 +159,10 @@ export abstract class Config implements IConfig {
Config.FEATURE_FLAG_LOGGING = model.FEATURE_FLAG_LOGGING;
Config.FEATURE_FLAG_STACKDRIVER_EXPORTER = model.FEATURE_FLAG_STACKDRIVER_EXPORTER;
Config.DES_SERVICE_HOST = model.DES_SERVICE_HOST;
Config.DES_SERVICE_HOST_ENTITLEMENT = model.DES_SERVICE_HOST_ENTITLEMENT;
Config.DES_SERVICE_HOST_COMPLIANCE = model.DES_SERVICE_HOST_COMPLIANCE;
Config.DES_SERVICE_HOST_STORAGE = model.DES_SERVICE_HOST_STORAGE;
Config.DES_SERVICE_HOST_PARTITION = model.DES_SERVICE_HOST_PARTITION;
Config.DES_SERVICE_APPKEY = model.DES_SERVICE_APPKEY;
Config.DES_GROUP_CHAR_LIMIT = model.DES_GROUP_CHAR_LIMIT;
......@@ -173,7 +178,10 @@ export abstract class Config implements IConfig {
Config.checkRequiredConfig(Config.CLOUDPROVIDER, 'CLOUDPROVIDER');
Config.checkRequiredConfig(Config.SERVICE_ENV, 'SERVICE_ENV');
Config.checkRequiredConfig(Config.IMP_SERVICE_ACCOUNT_SIGNER, 'IMP_SERVICE_ACCOUNT_SIGNER');
Config.checkRequiredConfig(Config.DES_SERVICE_HOST, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(Config.DES_SERVICE_HOST_ENTITLEMENT, 'DES_SERVICE_HOST_ENTITLEMENT');
Config.checkRequiredConfig(Config.DES_SERVICE_HOST_COMPLIANCE, 'DES_SERVICE_HOST_COMPLIANCE');
Config.checkRequiredConfig(Config.DES_SERVICE_HOST_STORAGE, 'DES_SERVICE_HOST_STORAGE');
Config.checkRequiredConfig(Config.DES_SERVICE_HOST_PARTITION, 'DES_SERVICE_HOST_PARTITION');
Config.checkRequiredConfig(Config.DES_SERVICE_APPKEY, 'DES_SERVICE_APPKEY');
// JWT validation
......@@ -208,8 +216,3 @@ export class ConfigFactory extends CloudFactory {
// Set the Utest flag correctly as sooon as the config class get loaded
Config.UTEST = process.env.UTEST;
//IBM DES base urls
Config.DES_SERVICE_HOST_ENTITLEMENT = process.env.DES_SERVICE_HOST_ENTITLEMENT;
Config.DES_SERVICE_HOST_COMPLIANCE = process.env.DES_SERVICE_HOST_COMPLIANCE;
Config.DES_SERVICE_HOST_STORAGE = process.env.DES_SERVICE_HOST_STORAGE;
\ No newline at end of file
......@@ -48,9 +48,15 @@ export class AzureConfig extends Config {
await Keyvault.loadSecrets(Keyvault.CreateSecretClient());
// data ecosystem host url and appkey
AzureConfig.DES_SERVICE_HOST = process.env.DES_SERVICE_HOST
AzureConfig.DES_SERVICE_HOST_COMPLIANCE = process.env.DES_SERVICE_HOST
AzureConfig.DES_SERVICE_HOST_ENTITLEMENT = process.env.DES_SERVICE_HOST
AzureConfig.DES_SERVICE_HOST_STORAGE = process.env.DES_SERVICE_HOST
AzureConfig.DES_SERVICE_HOST_PARTITION = process.env.DES_SERVICE_HOST
AzureConfig.DES_SERVICE_APPKEY = 'undefined'
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_COMPLIANCE, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_ENTITLEMENT, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_STORAGE, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_PARTITION, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_APPKEY, 'DES_SERVICE_APPKEY');
// the email of the service identity used to sign an impersonation token
......@@ -74,7 +80,10 @@ export class AzureConfig extends Config {
DES_REDIS_INSTANCE_ADDRESS: AzureConfig.DES_REDIS_INSTANCE_ADDRESS,
DES_REDIS_INSTANCE_PORT: AzureConfig.DES_REDIS_INSTANCE_PORT,
DES_REDIS_INSTANCE_KEY: AzureConfig.DES_REDIS_INSTANCE_KEY,
DES_SERVICE_HOST: AzureConfig.DES_SERVICE_HOST,
DES_SERVICE_HOST_COMPLIANCE: AzureConfig.DES_SERVICE_HOST_COMPLIANCE,
DES_SERVICE_HOST_ENTITLEMENT: AzureConfig.DES_SERVICE_HOST_ENTITLEMENT,
DES_SERVICE_HOST_STORAGE: AzureConfig.DES_SERVICE_HOST_STORAGE,
DES_SERVICE_HOST_PARTITION: AzureConfig.DES_SERVICE_HOST_PARTITION,
DES_SERVICE_APPKEY: AzureConfig.DES_SERVICE_APPKEY,
DES_GROUP_CHAR_LIMIT: AzureConfig.DES_GROUP_CHAR_LIMIT,
JWKS_URL: process.env.JWKS_URL,
......
......@@ -97,7 +97,7 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
AzureConfig.SP_TENANT_ID, AzureConfig.SP_APP_RESOURCE_ID)).access_token,
'Content-Type': 'application/json'
},
url: AzureConfig.DES_SERVICE_HOST + '/api/partition/v1/partitions/' + dataPartitionID
url: AzureConfig.DES_SERVICE_HOST_PARTITION + '/api/partition/v1/partitions/' + dataPartitionID
};
try {
return JSON.parse(await request.get(options));
......
......@@ -83,7 +83,10 @@ export class ConfigGoogle extends Config {
DES_REDIS_INSTANCE_ADDRESS: process.env.DES_REDIS_INSTANCE_ADDRESS,
DES_REDIS_INSTANCE_PORT: +process.env.DES_REDIS_INSTANCE_PORT,
DES_REDIS_INSTANCE_KEY: process.env.DES_REDIS_INSTANCE_KEY,
DES_SERVICE_HOST: process.env.SEISTORE_DES_HOST,
DES_SERVICE_HOST_COMPLIANCE: process.env.SEISTORE_DES_HOST,
DES_SERVICE_HOST_ENTITLEMENT: process.env.SEISTORE_DES_HOST,
DES_SERVICE_HOST_STORAGE: process.env.SEISTORE_DES_HOST,
DES_SERVICE_HOST_PARTITION: process.env.SEISTORE_DES_HOST,
DES_SERVICE_APPKEY: process.env.SEISTORE_DES_APPKEY,
DES_GROUP_CHAR_LIMIT: ConfigGoogle.DES_GROUP_CHAR_LIMIT,
JWKS_URL: process.env.JWKS_URL,
......
......@@ -45,7 +45,9 @@ export class IbmConfig extends Config {
public async init(): Promise<void> {
// data ecosystem host url and appkey
IbmConfig.DES_SERVICE_HOST = process.env.DES_SERVICE_HOST;
IbmConfig.DES_SERVICE_HOST_COMPLIANCE = process.env.DES_SERVICE_HOST_COMPLIANCE;
IbmConfig.DES_SERVICE_HOST_ENTITLEMENT = process.env.DES_SERVICE_HOST_ENTITLEMENT;
IbmConfig.DES_SERVICE_HOST_STORAGE = process.env.DES_SERVICE_HOST_STORAGE;
IbmConfig.IMP_SERVICE_ACCOUNT_SIGNER = process.env.IMP_SERVICE_ACCOUNT_SIGNER;
IbmConfig.ENTITLEMENT_HOST = process.env.ENTITLEMENT_HOST;//DES_SERVICE_HOST replaced by new variable ENTITLEMENT_HOST
......@@ -77,7 +79,9 @@ export class IbmConfig extends Config {
IbmConfig.DOC_DB_QUERY_RESULT_LIMIT_VALUE = parseInt(process.env.DOC_DB_QUERY_RESULT_LIMIT_VALUE, 10);
///////////////////////////////////////
IbmConfig.DES_SERVICE_APPKEY = 'na'
Config.checkRequiredConfig(IbmConfig.DES_SERVICE_HOST, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(IbmConfig.DES_SERVICE_HOST_COMPLIANCE, 'DES_SERVICE_HOST_COMPLIANCE');
Config.checkRequiredConfig(IbmConfig.DES_SERVICE_HOST_ENTITLEMENT, 'DES_SERVICE_HOST_ENTITLEMENT');
Config.checkRequiredConfig(IbmConfig.DES_SERVICE_HOST_STORAGE, 'DES_SERVICE_HOST_STORAGE');
Config.checkRequiredConfig(IbmConfig.DES_SERVICE_APPKEY, 'DES_SERVICE_APPKEY');
// redis cache port for locks (the port as env variable)
......@@ -102,7 +106,10 @@ export class IbmConfig extends Config {
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_SERVICE_HOST: IbmConfig.DES_SERVICE_HOST,
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,
DES_SERVICE_HOST_PARTITION: 'TO DEFINE',
DES_SERVICE_APPKEY: IbmConfig.DES_SERVICE_APPKEY,
DES_GROUP_CHAR_LIMIT: IbmConfig.DES_GROUP_CHAR_LIMIT,
JWKS_URL: process.env.JWKS_URL,
......
......@@ -39,16 +39,6 @@ export class DESCompliance {
if (res !== undefined && res) { return res };
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_COMPLIANCE)
{
urlValue = Config.DES_SERVICE_HOST_COMPLIANCE + dataecosystem.getComplianceBaseUrlPath() + '/legaltags:validate';
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getComplianceBaseUrlPath() + '/legaltags:validate';
}
const options = {
headers: {
......@@ -57,7 +47,7 @@ export class DESCompliance {
'Content-Type': 'application/json'
},
json: { names: [ltag] },
url: urlValue,
url: Config.DES_SERVICE_HOST_COMPLIANCE,
};
// tslint:disable-next-line: no-string-literal
......
......@@ -28,16 +28,6 @@ export class DESEntitlement {
prevCursor?: string): Promise<{ members: IDESEntitlementMemberModel[], nextCursor: string }> {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_ENTITLEMENT)
{
urlValue= Config.DES_SERVICE_HOST_ENTITLEMENT + dataecosystem.getEntitlementBaseUrlPath() + '/groups/' + group + '/members';
}
else
{
urlValue= Config.DES_SERVICE_HOST + dataecosystem.getEntitlementBaseUrlPath() + '/groups/' + group + '/members';
}
const options = {
headers: {
......@@ -46,7 +36,7 @@ export class DESEntitlement {
'Authorization': userToken.startsWith('Bearer') ? userToken : 'Bearer ' + userToken,
'Content-Type': 'application/json',
},
url: urlValue,
url: Config.DES_SERVICE_HOST_ENTITLEMENT,
};
if (prevCursor !== undefined) { options.url += ('?cursor=' + prevCursor); }
......@@ -77,16 +67,6 @@ export class DESEntitlement {
userToken: string, dataPartitionID: string, appkey: string): Promise<IDESEntitlementGroupModel[]> {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_ENTITLEMENT)
{
urlValue = Config.DES_SERVICE_HOST_ENTITLEMENT + dataecosystem.getEntitlementBaseUrlPath() + '/groups';
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getEntitlementBaseUrlPath() + '/groups';
}
const options = {
headers: {
......@@ -95,7 +75,7 @@ export class DESEntitlement {
'Authorization': userToken.startsWith('Bearer') ? userToken : 'Bearer ' + userToken,
'Content-Type': 'application/json'
},
url: urlValue,
url: Config.DES_SERVICE_HOST_ENTITLEMENT,
};
options.headers[dataecosystem.getDataPartitionIDRestHeaderName()] = dataPartitionID;
......@@ -126,16 +106,6 @@ export class DESEntitlement {
role: string, appkey: string) {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_ENTITLEMENT)
{
urlValue = Config.DES_SERVICE_HOST_ENTITLEMENT + dataecosystem.getEntitlementBaseUrlPath() + '/groups/' + groupName + '/members';
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getEntitlementBaseUrlPath() + '/groups/' + groupName + '/members';
}
const options = {
headers: {
......@@ -145,7 +115,7 @@ export class DESEntitlement {
'Content-Type': 'application/json'
},
json: undefined,
url: urlValue,
url: Config.DES_SERVICE_HOST_ENTITLEMENT,
};
options.json = dataecosystem.getUserAddBodyRequest(userEmail, role);
......@@ -173,16 +143,6 @@ export class DESEntitlement {
userToken: string, groupName: string, dataPartitionID: string, userEmail: string, appkey: string) {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_ENTITLEMENT)
{
urlValue = Config.DES_SERVICE_HOST_ENTITLEMENT + dataecosystem.getEntitlementBaseUrlPath() + '/groups/' + groupName + '/members/' + userEmail;
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getEntitlementBaseUrlPath() + '/groups/' + groupName + '/members/' + userEmail;
}
const options = {
headers: {
......@@ -191,7 +151,7 @@ export class DESEntitlement {
'Authorization': userToken.startsWith('Bearer') ? userToken : 'Bearer ' + userToken,
'Content-Type': 'application/json'
},
url: urlValue,
url: Config.DES_SERVICE_HOST_ENTITLEMENT,
};
options.headers[dataecosystem.getDataPartitionIDRestHeaderName()] = dataPartitionID;
......@@ -218,16 +178,6 @@ export class DESEntitlement {
userToken: string, groupName: string, groupDesc: string, dataPartitionID: string, appkey: string) {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_ENTITLEMENT)
{
urlValue = Config.DES_SERVICE_HOST_ENTITLEMENT + dataecosystem.getEntitlementBaseUrlPath() + '/groups';
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getEntitlementBaseUrlPath() + '/groups';
}
const options = {
headers: {
......@@ -240,7 +190,7 @@ export class DESEntitlement {
description: groupDesc,
name: groupName,
},
url: urlValue,
url: Config.DES_SERVICE_HOST_ENTITLEMENT,
};
options.headers[dataecosystem.getDataPartitionIDRestHeaderName()] = dataPartitionID;
......
......@@ -27,16 +27,6 @@ export class DESStorage {
userToken: string, seismicMeta: any, esd: string, appkey: string): Promise<void> {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_STORAGE)
{
urlValue = Config.DES_SERVICE_HOST_STORAGE + dataecosystem.getStorageBaseUrlPath() + '/records';
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getStorageBaseUrlPath() + '/records'
}
const options = {
headers: {
......@@ -45,7 +35,7 @@ export class DESStorage {
'Content-Type': 'application/json'
},
json: seismicMeta,
url: urlValue,
url: Config.DES_SERVICE_HOST_STORAGE,
};
// tslint:disable-next-line: no-string-literal
......@@ -73,16 +63,6 @@ export class DESStorage {
userToken: string, seismicUid: string, esd: string, appkey: string): Promise<void> {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_STORAGE)
{
urlValue = Config.DES_SERVICE_HOST_STORAGE + dataecosystem.getStorageBaseUrlPath() + '/records/' + seismicUid + ':delete';
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getStorageBaseUrlPath() + '/records/' + seismicUid + ':delete';
}
const options = {
headers: {
......@@ -90,7 +70,7 @@ export class DESStorage {
'AppKey': appkey || Config.DES_SERVICE_APPKEY,
'Content-Type': 'application/json',
},
url: urlValue,
url: Config.DES_SERVICE_HOST_STORAGE,
};
// tslint:disable-next-line: no-string-literal
......@@ -118,23 +98,13 @@ export class DESStorage {
userToken: string, seismicUid: string, esd: string, appkey: string): Promise<any> {
const dataecosystem = DataEcosystemCoreFactory.build(Config.CLOUDPROVIDER);
let urlValue;
if(Config.DES_SERVICE_HOST_STORAGE)
{
urlValue = Config.DES_SERVICE_HOST_STORAGE + dataecosystem.getStorageBaseUrlPath() + '/records/' + seismicUid;
}
else
{
urlValue = Config.DES_SERVICE_HOST + dataecosystem.getStorageBaseUrlPath() + '/records/' + seismicUid;
}
const options = {
headers: {
'Accept': 'application/json',
'AppKey': appkey || Config.DES_SERVICE_APPKEY,
},
url: urlValue,
url: Config.DES_SERVICE_HOST_STORAGE,
};
// tslint:disable-next-line: no-string-literal
......
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