Commit a4cd7b2c authored by Sacha Brants's avatar Sacha Brants
Browse files

Merge branch 'slb/vm/convert-subid-to-email' into 'master'

feat: enable subid to email conversion

See merge request !214
parents 9918bdf7 19919ebe
Pipeline #67824 failed with stages
in 14 minutes and 47 seconds
...@@ -941,5 +941,3 @@ The following software have components provided under the terms of this license: ...@@ -941,5 +941,3 @@ The following software have components provided under the terms of this license:
- json-schema (from https://www.npmjs.com/package/json-schema) - json-schema (from https://www.npmjs.com/package/json-schema)
- querystring (from https://www.npmjs.com/package/querystring) - querystring (from https://www.npmjs.com/package/querystring)
- sax (from https://www.npmjs.com/package/sax) - sax (from https://www.npmjs.com/package/sax)
...@@ -179,6 +179,14 @@ paths: ...@@ -179,6 +179,14 @@ paths:
name: seismicmeta name: seismicmeta
required: false required: false
type: boolean type: boolean
- description: 'If the dataset creator value is a subid, then enable conversion of it to email'
name: subid-to-email
in: query
type: boolean
default: true
enum:
- true
- false
responses: responses:
200: 200:
description: "Metadata of the dataset." description: "Metadata of the dataset."
...@@ -1150,6 +1158,14 @@ paths: ...@@ -1150,6 +1158,14 @@ paths:
name: tenantid name: tenantid
required: true required: true
type: string type: string
- description: 'Convert subid value of subproject admin to email'
name: subid-to-email
in: query
type: boolean
default: true
enum:
- true
- false
responses: responses:
200: 200:
description: "Retrieved subproject metadata successfully." description: "Retrieved subproject metadata successfully."
......
...@@ -189,6 +189,14 @@ paths: ...@@ -189,6 +189,14 @@ paths:
name: seismicmeta name: seismicmeta
required: false required: false
type: boolean type: boolean
- description: 'If the dataset creator value is a subid, then enable conversion of it to email'
name: subid-to-email
default: true
in: query
type: boolean
enum:
- true
- false
responses: responses:
200: 200:
description: "Metadata of the dataset" description: "Metadata of the dataset"
...@@ -1154,6 +1162,14 @@ paths: ...@@ -1154,6 +1162,14 @@ paths:
required: true required: true
type: string type: string
default: common default: common
- description: 'Convert subid value of subproject admin to email'
name: subid-to-email
default: true
in: query
type: boolean
enum:
- true
- false
responses: responses:
200: 200:
description: "Retrieved subproject metadata successfully" description: "Retrieved subproject metadata successfully"
......
...@@ -146,4 +146,4 @@ ...@@ -146,4 +146,4 @@
"path": "./app/sdms/node_modules/cz-conventional-changelog" "path": "./app/sdms/node_modules/cz-conventional-changelog"
} }
} }
} }
\ No newline at end of file
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
// ============================================================================ // ============================================================================
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import { Config } from '../cloud'; import { Config } from '../cloud';
import { DESCompliance, DESUtils } from '../dataecosystem'; import { DESCompliance, DESUtils } from '../dataecosystem';
import { ImpersonationTokenContextModel, ImpersonationTokenModel } from '../services/impersonation_token/model'; import { ImpersonationTokenContextModel, ImpersonationTokenModel } from '../services/impersonation_token/model';
...@@ -42,7 +41,7 @@ export class AuthProviderFactoryBuilder { ...@@ -42,7 +41,7 @@ export class AuthProviderFactoryBuilder {
}; };
} }
public static build(providerLabel: string, referenceAbstraction: any, args: { [key: string]: any } = {}) { public static build(providerLabel: string, referenceAbstraction: any, args: { [key: string]: any; } = {}) {
if (providerLabel === undefined || providerLabel === 'unknown') { if (providerLabel === undefined || providerLabel === 'unknown') {
throw (Error.make(Error.Status.UNKNOWN, throw (Error.make(Error.Status.UNKNOWN,
`Unrecognized auth provider: ${providerLabel}`)); `Unrecognized auth provider: ${providerLabel}`));
...@@ -56,7 +55,7 @@ export class AuthProviderFactoryBuilder { ...@@ -56,7 +55,7 @@ export class AuthProviderFactoryBuilder {
`The auth provider builder that extend ${referenceAbstraction} has not been found`)); `The auth provider builder that extend ${referenceAbstraction} has not been found`));
} }
private static providers: { [key: string]: any[] } = {}; private static providers: { [key: string]: any[]; } = {};
} }
...@@ -104,7 +103,7 @@ export class Auth { ...@@ -104,7 +103,7 @@ export class Auth {
esd: string, appkey: string, mustThrow = true): Promise<boolean> { esd: string, appkey: string, mustThrow = true): Promise<boolean> {
if (!this._cache) { if (!this._cache) {
this._cache = new Cache<boolean>('auth') this._cache = new Cache<boolean>('auth');
} }
const cacheKey = ( const cacheKey = (
......
...@@ -20,7 +20,6 @@ import { AbstractAuthProvider, AuthProviderFactory } from '../../auth'; ...@@ -20,7 +20,6 @@ import { AbstractAuthProvider, AuthProviderFactory } from '../../auth';
@AuthProviderFactory.register('generic') @AuthProviderFactory.register('generic')
export class GenericAuthProvider extends AbstractAuthProvider { export class GenericAuthProvider extends AbstractAuthProvider {
public async generateAuthCredential(): Promise<any> { public async generateAuthCredential(): Promise<any> {
throw (Error.make(Error.Status.NOT_IMPLEMENTED, throw (Error.make(Error.Status.NOT_IMPLEMENTED,
'The required feature is not supported, the credential auth provider has not been found.')); 'The required feature is not supported, the credential auth provider has not been found.'));
......
...@@ -63,6 +63,9 @@ export interface ConfigModel { ...@@ -63,6 +63,9 @@ export interface ConfigModel {
FEATURE_FLAG_TRACE: boolean; FEATURE_FLAG_TRACE: boolean;
FEATURE_FLAG_LOGGING: boolean; FEATURE_FLAG_LOGGING: boolean;
FEATURE_FLAG_STACKDRIVER_EXPORTER: boolean; FEATURE_FLAG_STACKDRIVER_EXPORTER: boolean;
FEATURE_FLAG_CCM_INTERACTION: boolean;
CCM_SERVICE_URL: string;
CCM_TOKEN_SCOPE: string;
} }
export abstract class Config implements IConfig { export abstract class Config implements IConfig {
...@@ -89,7 +92,7 @@ export abstract class Config implements IConfig { ...@@ -89,7 +92,7 @@ export abstract class Config implements IConfig {
public static DATASETS_KIND = 'datasets'; public static DATASETS_KIND = 'datasets';
public static SEISMICMETA_KIND = 'seismicmeta'; public static SEISMICMETA_KIND = 'seismicmeta';
public static APPS_KIND = 'apps'; public static APPS_KIND = 'apps';
public static IMPERSONATION_TOKEN_SIGNATURE_KIND = 'imptoken_signatures' public static IMPERSONATION_TOKEN_SIGNATURE_KIND = 'imptoken_signatures';
// Listing modes // Listing modes
public static LS_MODE = { ALL: 'all', DATASETS: 'datasets', DIRS: 'dirs' }; public static LS_MODE = { ALL: 'all', DATASETS: 'datasets', DIRS: 'dirs' };
...@@ -137,6 +140,7 @@ export abstract class Config implements IConfig { ...@@ -137,6 +140,7 @@ export abstract class Config implements IConfig {
public static FEATURE_FLAG_TRACE = true; public static FEATURE_FLAG_TRACE = true;
public static FEATURE_FLAG_LOGGING = true; public static FEATURE_FLAG_LOGGING = true;
public static FEATURE_FLAG_STACKDRIVER_EXPORTER = true; public static FEATURE_FLAG_STACKDRIVER_EXPORTER = true;
public static FEATURE_FLAG_CCM_INTERACTION = undefined;
// DataGroups prefix // DataGroups prefix
public static DATAGROUPS_PREFIX = 'data.sdms'; public static DATAGROUPS_PREFIX = 'data.sdms';
...@@ -185,6 +189,10 @@ export abstract class Config implements IConfig { ...@@ -185,6 +189,10 @@ export abstract class Config implements IConfig {
public static ENABLE_DE_TOKEN_EXCHANGE = false; public static ENABLE_DE_TOKEN_EXCHANGE = false;
public static DES_TARGET_AUDIENCE = undefined; public static DES_TARGET_AUDIENCE = undefined;
// CCM service url and token scope
public static CCM_SERVICE_URL = undefined;
public static CCM_TOKEN_SCOPE = undefined;
public static setCloudProvider(cloudProvider: string) { public static setCloudProvider(cloudProvider: string) {
Config.CLOUDPROVIDER = cloudProvider; Config.CLOUDPROVIDER = cloudProvider;
if (Config.CLOUDPROVIDER === undefined) { if (Config.CLOUDPROVIDER === undefined) {
...@@ -222,6 +230,7 @@ export abstract class Config implements IConfig { ...@@ -222,6 +230,7 @@ export abstract class Config implements IConfig {
Config.FEATURE_FLAG_TRACE = model.FEATURE_FLAG_TRACE; Config.FEATURE_FLAG_TRACE = model.FEATURE_FLAG_TRACE;
Config.FEATURE_FLAG_LOGGING = model.FEATURE_FLAG_LOGGING; Config.FEATURE_FLAG_LOGGING = model.FEATURE_FLAG_LOGGING;
Config.FEATURE_FLAG_STACKDRIVER_EXPORTER = model.FEATURE_FLAG_STACKDRIVER_EXPORTER; Config.FEATURE_FLAG_STACKDRIVER_EXPORTER = model.FEATURE_FLAG_STACKDRIVER_EXPORTER;
Config.FEATURE_FLAG_CCM_INTERACTION = model.FEATURE_FLAG_CCM_INTERACTION;
Config.DES_SERVICE_HOST_ENTITLEMENT = model.DES_SERVICE_HOST_ENTITLEMENT; Config.DES_SERVICE_HOST_ENTITLEMENT = model.DES_SERVICE_HOST_ENTITLEMENT;
Config.DES_SERVICE_HOST_COMPLIANCE = model.DES_SERVICE_HOST_COMPLIANCE; Config.DES_SERVICE_HOST_COMPLIANCE = model.DES_SERVICE_HOST_COMPLIANCE;
...@@ -265,6 +274,14 @@ export abstract class Config implements IConfig { ...@@ -265,6 +274,14 @@ export abstract class Config implements IConfig {
Config.checkRequiredConfig(Config.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH, 'DES_ENTITLEMENT_DELETE_ENDPOINT_PATH'); Config.checkRequiredConfig(Config.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH, 'DES_ENTITLEMENT_DELETE_ENDPOINT_PATH');
Config.checkRequiredConfig(Config.DES_SERVICE_APPKEY, 'DES_SERVICE_APPKEY'); Config.checkRequiredConfig(Config.DES_SERVICE_APPKEY, 'DES_SERVICE_APPKEY');
// CCM interaction
if (Config.FEATURE_FLAG_CCM_INTERACTION) {
Config.CCM_SERVICE_URL = model.CCM_SERVICE_URL;
Config.CCM_TOKEN_SCOPE = model.CCM_TOKEN_SCOPE;
Config.checkRequiredConfig(Config.CCM_SERVICE_URL, 'CCM_SERVICE_URL');
Config.checkRequiredConfig(Config.CCM_TOKEN_SCOPE, 'CCM_TOKEN_SCOPE');
}
// JWT validation // JWT validation
if (Config.JWT_ENABLE_FEATURE) { if (Config.JWT_ENABLE_FEATURE) {
Config.checkRequiredConfig(Config.JWKS_URL, 'JWKS_URL'); Config.checkRequiredConfig(Config.JWKS_URL, 'JWKS_URL');
...@@ -296,4 +313,4 @@ export class ConfigFactory extends CloudFactory { ...@@ -296,4 +313,4 @@ export class ConfigFactory extends CloudFactory {
} }
// Set the Utest flag correctly as soon as the config class get loaded // Set the Utest flag correctly as soon as the config class get loaded
Config.UTEST = process.env.UTEST; Config.UTEST = process.env.UTEST;
\ No newline at end of file
...@@ -38,8 +38,9 @@ export interface IDataEcosystemCore { ...@@ -38,8 +38,9 @@ export interface IDataEcosystemCore {
getEntitlementBaseUrlPath(): string; getEntitlementBaseUrlPath(): string;
getComplianceBaseUrlPath(): string; getComplianceBaseUrlPath(): string;
getStorageBaseUrlPath(): string; getStorageBaseUrlPath(): string;
getUserAssociationSvcBaseUrlPath(): string;
fixGroupMembersResponse(groupMembers: any): IDESEntitlementGroupMembersModel; fixGroupMembersResponse(groupMembers: any): IDESEntitlementGroupMembersModel;
getUserAddBodyRequest(userEmail: string, role: string): {email: string, role: string} | string[]; getUserAddBodyRequest(userEmail: string, role: string): { email: string, role: string; } | string[];
tenantNameAndDataPartitionIDShouldMatch(): boolean; tenantNameAndDataPartitionIDShouldMatch(): boolean;
} }
...@@ -49,13 +50,14 @@ export abstract class AbstractDataEcosystemCore implements IDataEcosystemCore { ...@@ -49,13 +50,14 @@ export abstract class AbstractDataEcosystemCore implements IDataEcosystemCore {
public abstract getEntitlementBaseUrlPath(): string; public abstract getEntitlementBaseUrlPath(): string;
public abstract getComplianceBaseUrlPath(): string; public abstract getComplianceBaseUrlPath(): string;
public abstract getStorageBaseUrlPath(): string; public abstract getStorageBaseUrlPath(): string;
public abstract getUserAssociationSvcBaseUrlPath(): string;
public abstract fixGroupMembersResponse(groupMembers: any): IDESEntitlementGroupMembersModel; public abstract fixGroupMembersResponse(groupMembers: any): IDESEntitlementGroupMembersModel;
public abstract getUserAddBodyRequest(userEmail: string, role: string): {email: string, role: string} | string[]; public abstract getUserAddBodyRequest(userEmail: string, role: string): { email: string, role: string; } | string[];
public abstract tenantNameAndDataPartitionIDShouldMatch(): boolean; public abstract tenantNameAndDataPartitionIDShouldMatch(): boolean;
} }
export class DataEcosystemCoreFactory extends CloudFactory { export class DataEcosystemCoreFactory extends CloudFactory {
public static build(providerLabel: string, args: { [key: string]: any } = {}): IDataEcosystemCore { public static build(providerLabel: string, args: { [key: string]: any; } = {}): IDataEcosystemCore {
return CloudFactory.build(providerLabel, AbstractDataEcosystemCore, args) as IDataEcosystemCore; return CloudFactory.build(providerLabel, AbstractDataEcosystemCore, args) as IDataEcosystemCore;
} }
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Config, ConfigFactory } from '../../config'; import { Config, ConfigFactory } from '../../config';
import {AWSSSMhelper} from './ssmhelper'; import { AWSSSMhelper } from './ssmhelper';
@ConfigFactory.register('aws') @ConfigFactory.register('aws')
export class AWSConfig extends Config { export class AWSConfig extends Config {
// scopes // scopes
...@@ -36,7 +36,7 @@ export class AWSConfig extends Config { ...@@ -36,7 +36,7 @@ export class AWSConfig extends Config {
AWSConfig.AWS_ENVIRONMENT = process.env.ENVIRONMENT; AWSConfig.AWS_ENVIRONMENT = process.env.ENVIRONMENT;
const awsSSMHelper = new AWSSSMhelper(); const awsSSMHelper = new AWSSSMhelper();
AWSConfig.AWS_BUCKET = await awsSSMHelper.getSSMParameter('/osdu/'+AWSConfig.AWS_ENVIRONMENT+'/seismic-store/seismic-s3-bucket-name'); AWSConfig.AWS_BUCKET = await awsSSMHelper.getSSMParameter('/osdu/' + AWSConfig.AWS_ENVIRONMENT + '/seismic-store/seismic-s3-bucket-name');
// Logger // Logger
AWSConfig.LOGGER_LEVEL = process.env.LOGGER_LEVEL || 'info'; AWSConfig.LOGGER_LEVEL = process.env.LOGGER_LEVEL || 'info';
...@@ -45,10 +45,10 @@ export class AWSConfig extends Config { ...@@ -45,10 +45,10 @@ export class AWSConfig extends Config {
SERVICE_ENV: process.env.SERVICE_ENV, SERVICE_ENV: process.env.SERVICE_ENV,
SERVICE_PORT: +process.env.PORT || 5000, SERVICE_PORT: +process.env.PORT || 5000,
API_BASE_PATH: process.env.API_BASE_PATH, API_BASE_PATH: process.env.API_BASE_PATH,
IMP_SERVICE_ACCOUNT_SIGNER: process.env.IMP_SERVICE_ACCOUNT_SIGNER||'', IMP_SERVICE_ACCOUNT_SIGNER: process.env.IMP_SERVICE_ACCOUNT_SIGNER || '',
LOCKSMAP_REDIS_INSTANCE_ADDRESS: process.env.LOCKSMAP_REDIS_INSTANCE_ADDRESS, LOCKSMAP_REDIS_INSTANCE_ADDRESS: process.env.LOCKSMAP_REDIS_INSTANCE_ADDRESS,
LOCKSMAP_REDIS_INSTANCE_PORT: +process.env.LOCKSMAP_REDIS_INSTANCE_PORT, LOCKSMAP_REDIS_INSTANCE_PORT: +process.env.LOCKSMAP_REDIS_INSTANCE_PORT,
LOCKSMAP_REDIS_INSTANCE_KEY: process.env.LOCKSMAP_REDIS_INSTANCE_KEY||'', LOCKSMAP_REDIS_INSTANCE_KEY: process.env.LOCKSMAP_REDIS_INSTANCE_KEY || '',
DES_REDIS_INSTANCE_ADDRESS: process.env.DES_REDIS_INSTANCE_ADDRESS, DES_REDIS_INSTANCE_ADDRESS: process.env.DES_REDIS_INSTANCE_ADDRESS,
DES_REDIS_INSTANCE_PORT: +process.env.DES_REDIS_INSTANCE_PORT, DES_REDIS_INSTANCE_PORT: +process.env.DES_REDIS_INSTANCE_PORT,
DES_REDIS_INSTANCE_KEY: process.env.DES_REDIS_INSTANCE_KEY, DES_REDIS_INSTANCE_KEY: process.env.DES_REDIS_INSTANCE_KEY,
...@@ -56,11 +56,11 @@ export class AWSConfig extends Config { ...@@ -56,11 +56,11 @@ export class AWSConfig extends Config {
DES_SERVICE_HOST_ENTITLEMENT: process.env.ENTITLEMENTS_BASE_URL, DES_SERVICE_HOST_ENTITLEMENT: process.env.ENTITLEMENTS_BASE_URL,
DES_SERVICE_HOST_STORAGE: process.env.STORAGE_BASE_URL, DES_SERVICE_HOST_STORAGE: process.env.STORAGE_BASE_URL,
DES_SERVICE_HOST_PARTITION: process.env.PARTITION_BASE_URL, DES_SERVICE_HOST_PARTITION: process.env.PARTITION_BASE_URL,
DES_SERVICE_APPKEY: process.env.DES_SERVICE_APPKEY||'', DES_SERVICE_APPKEY: process.env.DES_SERVICE_APPKEY || '',
DES_GROUP_CHAR_LIMIT: AWSConfig.DES_GROUP_CHAR_LIMIT, DES_GROUP_CHAR_LIMIT: AWSConfig.DES_GROUP_CHAR_LIMIT,
JWKS_URL: process.env.JWKS_URL, JWKS_URL: process.env.JWKS_URL,
JWT_EXCLUDE_PATHS: process.env.JWT_EXCLUDE_PATHS||'', JWT_EXCLUDE_PATHS: process.env.JWT_EXCLUDE_PATHS || '',
JWT_AUDIENCE: process.env.JWT_AUDIENCE||'', JWT_AUDIENCE: process.env.JWT_AUDIENCE || '',
JWT_ENABLE_FEATURE: process.env.JWT_ENABLE_FEATURE ? process.env.JWT_ENABLE_FEATURE === 'true' : false, JWT_ENABLE_FEATURE: process.env.JWT_ENABLE_FEATURE ? process.env.JWT_ENABLE_FEATURE === 'true' : false,
TENANT_JOURNAL_ON_DATA_PARTITION: true, TENANT_JOURNAL_ON_DATA_PARTITION: true,
SSL_ENABLED: process.env.SSL_ENABLED === 'true', SSL_ENABLED: process.env.SSL_ENABLED === 'true',
...@@ -81,7 +81,11 @@ export class AWSConfig extends Config { ...@@ -81,7 +81,11 @@ export class AWSConfig extends Config {
FEATURE_FLAG_LOGGING: process.env.FEATURE_FLAG_LOGGING !== undefined ? FEATURE_FLAG_LOGGING: process.env.FEATURE_FLAG_LOGGING !== undefined ?
process.env.FEATURE_FLAG_LOGGING !== 'false' : true, process.env.FEATURE_FLAG_LOGGING !== 'false' : true,
FEATURE_FLAG_STACKDRIVER_EXPORTER: process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== undefined ? FEATURE_FLAG_STACKDRIVER_EXPORTER: process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== undefined ?
process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true,
FEATURE_FLAG_CCM_INTERACTION: process.env.FEATURE_FLAG_CCM_INTERACTION ?
process.env.FEATURE_FLAG_CCM_INTERACTION === 'true' : false,
CCM_SERVICE_URL: process.env.CCM_SERVICE_URL || '',
CCM_TOKEN_SCOPE: process.env.CCM_TOKEN_SCOPE || ''
}); });
} }
......
...@@ -15,15 +15,17 @@ ...@@ -15,15 +15,17 @@
import { import {
AbstractDataEcosystemCore, AbstractDataEcosystemCore,
DataEcosystemCoreFactory, DataEcosystemCoreFactory,
IDESEntitlementGroupMembersModel } from '../../dataecosystem'; IDESEntitlementGroupMembersModel
import { AWSCredentials } from './credentials'; } from '../../dataecosystem';
@DataEcosystemCoreFactory.register('aws') @DataEcosystemCoreFactory.register('aws')
export class AWSDataEcosystemServices extends AbstractDataEcosystemCore { export class AWSDataEcosystemServices extends AbstractDataEcosystemCore {
public getDataPartitionIDRestHeaderName(): string { return 'data-partition-id'; } public getDataPartitionIDRestHeaderName(): string { return 'data-partition-id'; }
public getEntitlementBaseUrlPath(): string { return '/api/entitlements/v2'; }; public getEntitlementBaseUrlPath(): string { return '/api/entitlements/v2'; };
public getComplianceBaseUrlPath(): string { return '/api/legal/v1'; }; public getComplianceBaseUrlPath(): string { return '/api/legal/v1'; };
public getStorageBaseUrlPath(): string { return '/api/storage/v2'; }; public getStorageBaseUrlPath(): string { return '/api/storage/v2'; };
public getUserAssociationSvcBaseUrlPath(): string { return 'userAssociation/v1'; }
public async getAuthorizationHeader(userToken: string): Promise<string> { public async getAuthorizationHeader(userToken: string): Promise<string> {
return userToken.startsWith('Bearer') ? userToken : 'Bearer ' + userToken; return userToken.startsWith('Bearer') ? userToken : 'Bearer ' + userToken;
...@@ -33,8 +35,8 @@ export class AWSDataEcosystemServices extends AbstractDataEcosystemCore { ...@@ -33,8 +35,8 @@ export class AWSDataEcosystemServices extends AbstractDataEcosystemCore {
return groupMembers as IDESEntitlementGroupMembersModel; return groupMembers as IDESEntitlementGroupMembersModel;
} }
public getUserAddBodyRequest(userEmail: string, role: string): {email: string, role: string} | string[] { public getUserAddBodyRequest(userEmail: string, role: string): { email: string, role: string; } | string[] {
return { email: userEmail, role } return { email: userEmail, role };
} }
public tenantNameAndDataPartitionIDShouldMatch() { public tenantNameAndDataPartitionIDShouldMatch() {
......
...@@ -58,6 +58,8 @@ export class AzureConfig extends Config { ...@@ -58,6 +58,8 @@ export class AzureConfig extends Config {
AzureConfig.DES_SERVICE_HOST_PARTITION = process.env.DES_SERVICE_HOST; AzureConfig.DES_SERVICE_HOST_PARTITION = process.env.DES_SERVICE_HOST;
AzureConfig.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH = process.env.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH; AzureConfig.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH = process.env.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH;
AzureConfig.DES_SERVICE_APPKEY = 'undefined'; AzureConfig.DES_SERVICE_APPKEY = 'undefined';
AzureConfig.CCM_SERVICE_URL = process.env.CCM_SERVICE_URL;
AzureConfig.CCM_TOKEN_SCOPE = process.env.CCM_TOKEN_SCOPE;
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_COMPLIANCE, '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_ENTITLEMENT, 'DES_SERVICE_HOST');
Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_STORAGE, 'DES_SERVICE_HOST'); Config.checkRequiredConfig(AzureConfig.DES_SERVICE_HOST_STORAGE, 'DES_SERVICE_HOST');
...@@ -126,6 +128,10 @@ export class AzureConfig extends Config { ...@@ -126,6 +128,10 @@ export class AzureConfig extends Config {
process.env.FEATURE_FLAG_LOGGING !== 'false' : true, process.env.FEATURE_FLAG_LOGGING !== 'false' : true,
FEATURE_FLAG_STACKDRIVER_EXPORTER: process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== undefined ? FEATURE_FLAG_STACKDRIVER_EXPORTER: process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== undefined ?
process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true, process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true,
FEATURE_FLAG_CCM_INTERACTION: process.env.FEATURE_FLAG_CCM_INTERACTION ?
process.env.FEATURE_FLAG_CCM_INTERACTION === 'true' : false,
CCM_SERVICE_URL: AzureConfig.CCM_SERVICE_URL,
CCM_TOKEN_SCOPE: AzureConfig.CCM_TOKEN_SCOPE
}); });
// initialize app insight // initialize app insight
......
...@@ -14,25 +14,25 @@ ...@@ -14,25 +14,25 @@
// limitations under the License. // limitations under the License.
// ============================================================================ // ============================================================================
import request from 'request-promise';
import { Cache, Error } from '../../../shared';
import { import {
AbstractDataEcosystemCore, AbstractDataEcosystemCore,
DataEcosystemCoreFactory, DataEcosystemCoreFactory,
IDESEntitlementGroupMembersModel IDESEntitlementGroupMembersModel
} from '../../dataecosystem'; } from '../../dataecosystem';
import { AzureCredentials } from './credentials';
import { AzureConfig } from './config'; import { AzureConfig } from './config';
import { Error, Cache } from '../../../shared'; import { AzureCredentials } from './credentials';
import { Keyvault } from './keyvault'; import { Keyvault } from './keyvault';
import request from 'request-promise'
@DataEcosystemCoreFactory.register('azure') @DataEcosystemCoreFactory.register('azure')
export class AzureDataEcosystemServices extends AbstractDataEcosystemCore { export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
private static _storageConfigs: Cache<string>;
private static _cosmosConfigs: Cache<string>;
private static _storageConfigs: Cache<string> public getUserAssociationSvcBaseUrlPath(): string { return 'userAssociation/v1'; }
private static _cosmosConfigs: Cache<string>
public getDataPartitionIDRestHeaderName(): string { return 'data-partition-id'; } public getDataPartitionIDRestHeaderName(): string { return 'data-partition-id'; }
public getEntitlementBaseUrlPath(): string { return '/api/entitlements/v2'; }; public getEntitlementBaseUrlPath(): string { return '/api/entitlements/v2'; };
public getComplianceBaseUrlPath(): string { return '/api/legal/v1'; }; public getComplianceBaseUrlPath(): string { return '/api/legal/v1'; };
...@@ -46,8 +46,8 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore { ...@@ -46,8 +46,8 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
return groupMembers as IDESEntitlementGroupMembersModel; return groupMembers as IDESEntitlementGroupMembersModel;
} }
public getUserAddBodyRequest(userEmail: string, role: string): { email: string, role: string } | string[] { public getUserAddBodyRequest(userEmail: string, role: string): { email: string, role: string; } | string[] {
return { email: userEmail, role } return { email: userEmail, role };
} }
public tenantNameAndDataPartitionIDShouldMatch() { public tenantNameAndDataPartitionIDShouldMatch() {
...@@ -75,15 +75,15 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore { ...@@ -75,15 +75,15 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
public static async getStorageAccountName(dataPartitionID: string): Promise<string> { public static async getStorageAccountName(dataPartitionID: string): Promise<string> {
if (!this._storageConfigs) { if (!this._storageConfigs) {
this._storageConfigs = new Cache<string>('storage') this._storageConfigs = new Cache<string>('storage');
} }
const res = await this._storageConfigs.get(dataPartitionID); const res = await this._storageConfigs.get(dataPartitionID);
if (res !== undefined) { return res }; if (res !== undefined) { return res; };
const dataPartitionConfigurations = await AzureDataEcosystemServices.getPartitionConfiguration(dataPartitionID); const dataPartitionConfigurations = await AzureDataEcosystemServices.getPartitionConfiguration(dataPartitionID);
const storageConfigs = (dataPartitionConfigurations[Keyvault.DATA_PARTITION_STORAGE_ACCOUNT_NAME] as { const storageConfigs = (dataPartitionConfigurations[Keyvault.DATA_PARTITION_STORAGE_ACCOUNT_NAME] as {
sensitive: boolean, value: string sensitive: boolean, value: string;
}); });
if (storageConfigs.sensitive) { if (storageConfigs.sensitive) {
storageConfigs.value = (await Keyvault.CreateSecretClient().getSecret(storageConfigs.value)).value; storageConfigs.value = (await Keyvault.CreateSecretClient().getSecret(storageConfigs.value)).value;
...@@ -93,10 +93,10 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore { ...@@ -93,10 +93,10 @@ export class AzureDataEcosystemServices extends AbstractDataEcosystemCore {
} }
public static async getCosmosConnectionParams( public static async getCosmosConnectionParams(
dataPartitionID: string): Promise<{ endpoint: string, key: string }> { dataPartitionID: string): Promise<{ endpoint: string, key: string; }> {
if (!this._cosmosConfigs) { if (!this._cosmosConfigs) {
this._cosmosConfigs = new Cache<string>('cosmos') this._cosmosConfigs = new Cache<string>('cosmos');