/** * Namespace qui regroupe toutes les fonctions en rapport avec le LDAP - API et fonctions internes * @namespace LDAP */ /** * @file Importe la configuration du LDAP au sein de l'application, et remplace certaines valeurs en fonction des variables d'environnement. * @memberof LDAP * @author manifold, hawkspar */ import fs from 'fs'; import path from 'path'; import colors from 'colors'; // Point central ; tous les champs de la BDD sont 'cachés' dans config.json et pas visibles directement let path_config = path.resolve(__dirname,'..', '..', '..', 'ldap_config.json'); console.log(colors.cyan("Loading LDAP config file from "+path_config)); export const ldapConfig = JSON.parse(fs.readFileSync(path_config).toString()); let path_credentials = path.resolve(__dirname,'..', '..', '..', 'ldap_credentials.json') console.log(colors.cyan("Loading LDAP credentials from "+path_credentials)); export const credentialsLdapConfig = JSON.parse(fs.readFileSync(path_credentials).toString()); // Override config server from environment if (process.env.LDAP_URI != null) { ldapConfig.server = process.env.LDAP_URI; } else { if (process.env.TARGET_ENV == `production`) { ldapConfig.server = ldapConfig.server_prod; } else { ldapConfig.server = ldapConfig.server_dev; } }