config.ts 9.16 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* Licensed Materials - Property of IBM              */
/* (c) Copyright IBM Corp. 2020. All Rights Reserved.*/

import { Config, ConfigFactory } from '../../config';
import { config } from './logger';

@ConfigFactory.register('ibm')
export class IbmConfig extends Config {

    // Apis base url path
    public static API_VERSION = 'v3';
    public static API_BASE_URL_PATH = '/api/' + IbmConfig.API_VERSION;

    // max len for a group name in DE
    public static DES_GROUP_CHAR_LIMIT = 256;

Walter D's avatar
Walter D committed
17
18
19
20
21
    // env

    public static IBM_ENVIRONMENT: string;
    public static IBM_REGION: string;

22
23
24
25
26
27
    // IBM COS
	public static COS_ACCESS_KEY_ID: string;
	public static COS_SECRET_ACCESS_KEY: string;
	public static COS_ENDPOINT: string;
	public static COS_S3_FORCEPATHSTYLE: boolean;
	public static COS_SIGNATUREVERSION: string;
Walter D's avatar
Walter D committed
28
29
30
    public static COS_SUBUSER_ACCESS_KEY_ID: string;
	public static COS_SUBUSER_SECRET_ACCESS_KEY: string;
    public static COS_TEMP_CRED_EXPITY: string;
31

32
33
34
35
36
37
38
39
40
41
	// IBM Keycloak
    public static KEYCLOAK_BASEURL: string;
    public static KEYCLOAK_URL_TOKEN: string;
    public static KEYCLOAK_REALM: string;
    public static KEYCLOAK_USERNAME: string;
    public static KEYCLOAK_PASSWORD: string;
    public static KEYCLOAK_GRANTTYPE: string;
    public static KEYCLOAK_CLIENTID: string;
    public static KEYCLOAK_CLIENTSECRET: string;

42
    // IBM Document DB
43
44
45
46
47
48
49
50
51
52
53
    public static DOC_DB_URL: string;
    public static DOC_DB_COLLECTION: string;
    public static DOC_DB_QUERY_RESULT_LIMIT: string;
    public static DOC_DB_QUERY_RESULT_LIMIT_VALUE: number;
    public static DOC_DB_QUERY_SELECT_FIELDS: string;

    // SERVICES
    public static ENTITLEMENT_HOST;
    public static LEGAL_HOST;
    public static STORAGE_HOST;

54
    // Logger
55
56
    public static LOGGER_LEVEL;

57
58
59
60
61
    // DES context path
    public static ENTITLEMENT_CONTEXT_PATH: string;
    public static COMPLIANCE_CONTEXT_PATH: string;
    public static STORAGE_CONTEXT_PATH: string;

62
63
64
65
66
67
68
69
    public async init(): Promise<void> {

        // data ecosystem host url and appkey
        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;

70
71
72
73
        // DES service context path
        IbmConfig.ENTITLEMENT_CONTEXT_PATH = process.env.ENTITLEMENT_CONTEXT_PATH
        IbmConfig.COMPLIANCE_CONTEXT_PATH = process.env.COMPLIANCE_CONTEXT_PATH
        IbmConfig.STORAGE_CONTEXT_PATH = process.env.STORAGE_CONTEXT_PATH
74
        IbmConfig.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH = '/groups/'
75

76
77
78
79
80
        // DES_SERVICE_HOST replaced by new variable ENTITLEMENT_HOST
        IbmConfig.ENTITLEMENT_HOST = process.env.ENTITLEMENT_HOST;
        IbmConfig.LEGAL_HOST = process.env.LEGAL_HOST;// DES_SERVICE_HOST replaced by new variable LEGAL_HOST
        IbmConfig.STORAGE_HOST = process.env.STORAGE_HOST;// DES_SERVICE_HOST replaced by new variable LEGAL_HOST

81
82
83
84
        // IBM COS
		IbmConfig.COS_ACCESS_KEY_ID = process.env.COS_ACCESS_KEY_ID;
		IbmConfig.COS_SECRET_ACCESS_KEY = process.env.COS_SECRET_ACCESS_KEY;
		IbmConfig.COS_ENDPOINT = process.env.COS_ENDPOINT;
85
		IbmConfig.COS_S3_FORCEPATHSTYLE = process.env.COS_S3_FORCEPATHSTYLE === 'true';// string to boolean
86
		IbmConfig.COS_SIGNATUREVERSION = process.env.COS_SIGNATUREVERSION;
Walter D's avatar
Walter D committed
87
88
89
        IbmConfig.COS_SUBUSER_ACCESS_KEY_ID = process.env.COS_SUBUSER_ACCESS_KEY_ID;
        IbmConfig.COS_SUBUSER_SECRET_ACCESS_KEY = process.env.COS_SUBUSER_SECRET_ACCESS_KEY;
        IbmConfig.COS_TEMP_CRED_EXPITY = process.env.COS_TEMP_CRED_EXPITY;
90

91
92
93
94
95
96
97
98
99
		// IBM Keycloak
		IbmConfig.KEYCLOAK_BASEURL = process.env.KEYCLOAK_BASEURL;
		IbmConfig.KEYCLOAK_URL_TOKEN = process.env.KEYCLOAK_URL_TOKEN;
		IbmConfig.KEYCLOAK_USERNAME = process.env.KEYCLOAK_USERNAME;
		IbmConfig.KEYCLOAK_PASSWORD = process.env.KEYCLOAK_PASSWORD;
		IbmConfig.KEYCLOAK_GRANTTYPE = process.env.KEYCLOAK_GRANTTYPE;
		IbmConfig.KEYCLOAK_CLIENTID = process.env.KEYCLOAK_CLIENTID;
		IbmConfig.KEYCLOAK_CLIENTSECRET = process.env.KEYCLOAK_CLIENTSECRET;
        IbmConfig.KEYCLOAK_REALM = process.env.KEYCLOAK_REALM;
100
101

        // IBM Document DB
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
        IbmConfig.DOC_DB_URL = process.env.DB_URL;
        IbmConfig.DOC_DB_COLLECTION = process.env.DOC_DB_COLLECTION;
        IbmConfig.DOC_DB_QUERY_SELECT_FIELDS = process.env.DOC_DB_QUERY_SELECT_FIELDS;
        IbmConfig.DOC_DB_QUERY_RESULT_LIMIT = process.env.DOC_DB_QUERY_RESULT_LIMIT;
        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_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)
        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
Diego Molteni's avatar
Diego Molteni committed
118
        IbmConfig.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE = process.env.CACHE_TLS_DISABLE ? true : false
119

120
121
122
        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
Diego Molteni's avatar
Diego Molteni committed
123
        IbmConfig.DES_REDIS_INSTANCE_TLS_DISABLE = process.env.CACHE_TLS_DISABLE ? true : false
124

125
        // Logger
126
127
128
129
130
131
132
133
134
135
136
137
138
        IbmConfig.LOGGER_LEVEL = process.env.LOGGER_LEVEL || 'debug';

        Config.checkRequiredConfig(IbmConfig.LOCKSMAP_REDIS_INSTANCE_PORT, 'REDIS_INSTANCE_PORT');

        // init generic configurations
        await Config.initServiceConfiguration({
            SERVICE_ENV: process.env.APP_ENVIRONMENT_IDENTIFIER,
            SERVICE_PORT: +process.env.PORT || 5000,
            API_BASE_PATH: IbmConfig.API_BASE_URL_PATH,
            IMP_SERVICE_ACCOUNT_SIGNER: IbmConfig.IMP_SERVICE_ACCOUNT_SIGNER,
            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,
139
            LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE: IbmConfig.LOCKSMAP_REDIS_INSTANCE_TLS_DISABLE,
140
141
142
            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,
143
            DES_REDIS_INSTANCE_TLS_DISABLE: IbmConfig.DES_REDIS_INSTANCE_TLS_DISABLE,
144
145
146
147
            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',
148
            DES_ENTITLEMENT_DELETE_ENDPOINT_PATH: IbmConfig.DES_ENTITLEMENT_DELETE_ENDPOINT_PATH,
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
            DES_SERVICE_APPKEY: IbmConfig.DES_SERVICE_APPKEY,
            DES_GROUP_CHAR_LIMIT: IbmConfig.DES_GROUP_CHAR_LIMIT,
            JWKS_URL: process.env.JWKS_URL,
            JWT_EXCLUDE_PATHS: process.env.JWT_EXCLUDE_PATHS,
            JWT_AUDIENCE: process.env.JWT_AUDIENCE,
            JWT_ENABLE_FEATURE: process.env.JWT_ENABLE_FEATURE ? process.env.JWT_ENABLE_FEATURE === 'true' : false,
            TENANT_JOURNAL_ON_DATA_PARTITION: true,
            FEATURE_FLAG_AUTHORIZATION: process.env.FEATURE_FLAG_AUTHORIZATION !== undefined ?
                process.env.FEATURE_FLAG_AUTHORIZATION !== 'false' : true,
            FEATURE_FLAG_LEGALTAG: process.env.FEATURE_FLAG_LEGALTAG !== undefined ?
                process.env.FEATURE_FLAG_LEGALTAG !== 'false' : true,
            FEATURE_FLAG_SEISMICMETA_STORAGE: process.env.FEATURE_FLAG_SEISMICMETA_STORAGE !== undefined ?
                process.env.FEATURE_FLAG_SEISMICMETA_STORAGE !== 'false' : true,
            FEATURE_FLAG_IMPTOKEN: process.env.FEATURE_FLAG_IMPTOKEN !== undefined ?
                process.env.FEATURE_FLAG_IMPTOKEN !== 'false' : true,
            FEATURE_FLAG_STORAGE_CREDENTIALS: process.env.FEATURE_FLAG_STORAGE_CREDENTIALS !== undefined ?
                process.env.FEATURE_FLAG_STORAGE_CREDENTIALS !== 'false' : true,
            FEATURE_FLAG_TRACE: process.env.FEATURE_FLAG_TRACE !== undefined ?
                process.env.FEATURE_FLAG_TRACE !== 'false' : true,
            FEATURE_FLAG_LOGGING: process.env.FEATURE_FLAG_LOGGING !== undefined ?
                process.env.FEATURE_FLAG_LOGGING !== 'false' : true,
            FEATURE_FLAG_STACKDRIVER_EXPORTER: process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== undefined ?
                process.env.FEATURE_FLAG_STACKDRIVER_EXPORTER !== 'false' : true,
        });

        config();

    }

Walter D's avatar
Walter D committed
178
}