/** * 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. * @author hawkspar * @memberof LDAP */ import fs from 'fs'; import path from 'path'; import colors from 'colors'; import dotenv from 'dotenv'; // Chargement de l'environnement let path_env = path.resolve(__dirname, '..', '..', '..', './.env'); console.info(colors.red("Loading .env config file from "+path_env)); dotenv.config({ path: path_env }); // 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.info(colors.cyan("Loading LDAP config file from "+path_config)); export const ldapConfig = JSON.parse(fs.readFileSync(path_config).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; } //Get certification authorities let ca = [] if(process.env.CA !== undefined) { for(let file of process.env.CA.split(' ')) { ca.push(fs.readFileSync(file)); } } ldapConfig.tlsOptions = { ca: ca }; // Data formats and useful constants export const categories = ["admins","speakers","members","followers"];