|
@@ -22,6 +22,7 @@ interface EnvConfig {
|
|
|
key: string,
|
|
key: string,
|
|
|
type: ValueType,
|
|
type: ValueType,
|
|
|
default?: number | string | boolean | null,
|
|
default?: number | string | boolean | null,
|
|
|
|
|
+ isSecret?: boolean,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type EnumDictionary<T extends string | symbol | number, U> = {
|
|
type EnumDictionary<T extends string | symbol | number, U> = {
|
|
@@ -48,7 +49,7 @@ const parserDictionary: EnumDictionary<ValueType, ValueParser<number | string |
|
|
|
* The commented out item has not yet entered the migration work.
|
|
* The commented out item has not yet entered the migration work.
|
|
|
* So, parameters of these are under consideration.
|
|
* So, parameters of these are under consideration.
|
|
|
*/
|
|
*/
|
|
|
-const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
|
|
|
|
+const ENV_VAR_NAME_TO_CONFIG_INFO: Record<string, EnvConfig> = {
|
|
|
FILE_UPLOAD: {
|
|
FILE_UPLOAD: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'app:fileUploadType',
|
|
key: 'app:fileUploadType',
|
|
@@ -168,6 +169,7 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'autoInstall:adminPassword',
|
|
key: 'autoInstall:adminPassword',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
AUTO_INSTALL_GLOBAL_LANG: {
|
|
AUTO_INSTALL_GLOBAL_LANG: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -321,6 +323,7 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'security:sessionMaxAge',
|
|
key: 'security:sessionMaxAge',
|
|
|
type: ValueType.NUMBER,
|
|
type: ValueType.NUMBER,
|
|
|
default: undefined,
|
|
default: undefined,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
USER_UPPER_LIMIT: {
|
|
USER_UPPER_LIMIT: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -339,18 +342,21 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'security:trustProxyBool',
|
|
key: 'security:trustProxyBool',
|
|
|
type: ValueType.BOOLEAN,
|
|
type: ValueType.BOOLEAN,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
TRUST_PROXY_CSV: {
|
|
TRUST_PROXY_CSV: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'security:trustProxyCsv',
|
|
key: 'security:trustProxyCsv',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
TRUST_PROXY_HOPS: {
|
|
TRUST_PROXY_HOPS: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'security:trustProxyHops',
|
|
key: 'security:trustProxyHops',
|
|
|
type: ValueType.NUMBER,
|
|
type: ValueType.NUMBER,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
LOCAL_STRATEGY_ENABLED: {
|
|
LOCAL_STRATEGY_ENABLED: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -405,6 +411,14 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'security:passport-saml:issuer',
|
|
key: 'security:passport-saml:issuer',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ SAML_CERT: {
|
|
|
|
|
+ ns: 'crowi',
|
|
|
|
|
+ key: 'security:passport-saml:cert',
|
|
|
|
|
+ type: ValueType.STRING,
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
SAML_ATTR_MAPPING_ID: {
|
|
SAML_ATTR_MAPPING_ID: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -436,12 +450,6 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
|
- SAML_CERT: {
|
|
|
|
|
- ns: 'crowi',
|
|
|
|
|
- key: 'security:passport-saml:cert',
|
|
|
|
|
- type: ValueType.STRING,
|
|
|
|
|
- default: null,
|
|
|
|
|
- },
|
|
|
|
|
SAML_ABLC_RULE: {
|
|
SAML_ABLC_RULE: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'security:passport-saml:ABLCRule',
|
|
key: 'security:passport-saml:ABLCRule',
|
|
@@ -531,18 +539,21 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'azure:tenantId',
|
|
key: 'azure:tenantId',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
AZURE_CLIENT_ID: {
|
|
AZURE_CLIENT_ID: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'azure:clientId',
|
|
key: 'azure:clientId',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
AZURE_CLIENT_SECRET: {
|
|
AZURE_CLIENT_SECRET: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'azure:clientSecret',
|
|
key: 'azure:clientSecret',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
AZURE_STORAGE_ACCOUNT_NAME: {
|
|
AZURE_STORAGE_ACCOUNT_NAME: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -609,12 +620,14 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'slackbot:withoutProxy:signingSecret',
|
|
key: 'slackbot:withoutProxy:signingSecret',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
SLACKBOT_WITHOUT_PROXY_BOT_TOKEN: {
|
|
SLACKBOT_WITHOUT_PROXY_BOT_TOKEN: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'slackbot:withoutProxy:botToken',
|
|
key: 'slackbot:withoutProxy:botToken',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: null,
|
|
default: null,
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
SLACKBOT_WITHOUT_PROXY_COMMAND_PERMISSION: {
|
|
SLACKBOT_WITHOUT_PROXY_COMMAND_PERMISSION: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -633,12 +646,14 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
key: 'slackbot:withProxy:saltForGtoP',
|
|
key: 'slackbot:withProxy:saltForGtoP',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: 'gtop',
|
|
default: 'gtop',
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
SLACKBOT_WITH_PROXY_SALT_FOR_PTOG: {
|
|
SLACKBOT_WITH_PROXY_SALT_FOR_PTOG: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
|
key: 'slackbot:withProxy:saltForPtoG',
|
|
key: 'slackbot:withProxy:saltForPtoG',
|
|
|
type: ValueType.STRING,
|
|
type: ValueType.STRING,
|
|
|
default: 'ptog',
|
|
default: 'ptog',
|
|
|
|
|
+ isSecret: true,
|
|
|
},
|
|
},
|
|
|
OGP_URI: {
|
|
OGP_URI: {
|
|
|
ns: 'crowi',
|
|
ns: 'crowi',
|
|
@@ -805,16 +820,6 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * return whether env belongs to Security settings
|
|
|
|
|
- * @param key ex. 'security:passport-saml:isEnabled' is true
|
|
|
|
|
- * @returns
|
|
|
|
|
- */
|
|
|
|
|
-const isSecurityEnv = (key) => {
|
|
|
|
|
- const array = key.split(':');
|
|
|
|
|
- return (array[0] === 'security');
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
export interface ConfigObject extends Record<string, any> {
|
|
export interface ConfigObject extends Record<string, any> {
|
|
|
fromDB: any,
|
|
fromDB: any,
|
|
|
fromEnvVars: any,
|
|
fromEnvVars: any,
|
|
@@ -883,7 +888,7 @@ export default class ConfigLoader {
|
|
|
config[configInfo.ns][configInfo.key] = configInfo.default;
|
|
config[configInfo.ns][configInfo.key] = configInfo.default;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- const parser: ValueParser<number | string | boolean> = parserDictionary[configInfo.type];
|
|
|
|
|
|
|
+ const parser = parserDictionary[configInfo.type];
|
|
|
config[configInfo.ns][configInfo.key] = parser.parse(process.env[ENV_VAR_NAME] as string);
|
|
config[configInfo.ns][configInfo.key] = parser.parse(process.env[ENV_VAR_NAME] as string);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -905,10 +910,13 @@ export default class ConfigLoader {
|
|
|
if (process.env[ENV_VAR_NAME] === undefined) {
|
|
if (process.env[ENV_VAR_NAME] === undefined) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if (isSecurityEnv(configInfo.key) && avoidSecurity) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // skip to show secret values
|
|
|
|
|
+ if (avoidSecurity && configInfo.isSecret) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- const parser: ValueParser<number | string | boolean> = parserDictionary[configInfo.type];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const parser = parserDictionary[configInfo.type];
|
|
|
config[ENV_VAR_NAME] = parser.parse(process.env[ENV_VAR_NAME] as string);
|
|
config[ENV_VAR_NAME] = parser.parse(process.env[ENV_VAR_NAME] as string);
|
|
|
}
|
|
}
|
|
|
|
|
|