41 lines
1.7 KiB
JavaScript
41 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
require('dotenv').config();
|
|
|
|
function getEnv(key, defaultValue) {
|
|
const value = process.env[key];
|
|
return value !== undefined && value !== '' ? value : defaultValue;
|
|
}
|
|
|
|
const legacyPowerShell = getEnv('LDAP_USE_POWERSHELL_PASSWORD', '') === 'true';
|
|
const passwordMethodDefault = legacyPowerShell
|
|
? 'powershell'
|
|
: process.platform === 'win32' ? 'powershell' : 'kerberos';
|
|
|
|
const config = {
|
|
ldapUrl: getEnv('LDAP_URL', 'ldap://dc.school25.ru:389'),
|
|
baseDN: getEnv('LDAP_BASE_DN', 'DC=school25,DC=ru'),
|
|
domain: getEnv('LDAP_DOMAIN', 'school25.ru'),
|
|
groupOU: getEnv('LDAP_GROUP_OU', ''),
|
|
adminLogin: getEnv('ADMIN_LOGIN', ''),
|
|
adminPassword: getEnv('ADMIN_PASSWORD', ''),
|
|
port: parseInt(getEnv('PORT', '8080'), 10),
|
|
sessionTTLMinutes: parseInt(getEnv('SESSION_TTL_MINUTES', '120'), 10),
|
|
encryptTraffic: getEnv('ENCRYPT_TRAFFIC', 'true') === 'true',
|
|
tlsRejectUnauthorized: getEnv('LDAP_TLS_REJECT_UNAUTHORIZED', 'false') === 'true',
|
|
caFile: getEnv('LDAP_CA_FILE', ''),
|
|
passwordMethod: getEnv('LDAP_PASSWORD_METHOD', passwordMethodDefault),
|
|
ldapRealm: getEnv('LDAP_REALM', String(getEnv('LDAP_DOMAIN', 'school25.ru')).toUpperCase()),
|
|
kdcServers: getEnv('LDAP_KDC_SERVERS', ''),
|
|
passwordRetries: Math.max(1, parseInt(getEnv('LDAP_PASSWORD_RETRIES', '3'), 10) || 3),
|
|
passwordRetryDelayMs: Math.max(0, parseInt(getEnv('LDAP_PASSWORD_RETRY_DELAY_MS', '1000'), 10) || 1000),
|
|
powerShellExe: getEnv('LDAP_POWERSHELL_EXE', 'powershell.exe'),
|
|
emailHost: getEnv('EMAIL_HOST', ''),
|
|
emailPort: parseInt(getEnv('EMAIL_PORT', '587'), 10),
|
|
emailSecure: getEnv('EMAIL_SECURE', 'false') === 'true',
|
|
emailUser: getEnv('EMAIL_LOGIN', ''),
|
|
emailPassword: getEnv('EMAIL_PASSWORD', ''),
|
|
mailFrom: getEnv('MAIL_FROM', '')
|
|
};
|
|
|
|
module.exports = config; |