From cb4eb710fb5e3dbbf8aa0f7433443d56880f3df0 Mon Sep 17 00:00:00 2001
From: Max Planck <mplanck@icasa.nmt.edu>
Date: Tue, 28 May 2019 18:05:55 -0600
Subject: [PATCH] Added ldap password environment variable.

---
 .gitignore               | 3 ++-
 server/src/lib/Server.ts | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 8dc02ff1..bed7331f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ src/.baseDir.ts
 .vscode/
 
 *.swp
-
+*~
 
 # Directory used by example
 /notifications/
@@ -39,3 +39,4 @@ users_database.test.yml
 
 .suite
 .kube
+.idea
diff --git a/server/src/lib/Server.ts b/server/src/lib/Server.ts
index c6b8a7b0..baffd5d7 100644
--- a/server/src/lib/Server.ts
+++ b/server/src/lib/Server.ts
@@ -75,6 +75,13 @@ export default class Server {
 
     const appConfiguration = ConfigurationParser.parse(configuration);
 
+    // We want to get the ldap binding password from the environment if it has been set, otherwise
+    // it will come from the configuration file
+    if (process.env.LDAP_BACKEND_PASSWORD) {
+      appConfiguration.authentication_backend.ldap.password = process.env.LDAP_BACKEND_PASSWORD;
+      that.globalLogger.debug("Got ldap binding password from environment");
+    }
+
     // by default the level of logs is info
     deps.winston.level = appConfiguration.logs_level;
     this.displayConfigurations(appConfiguration);