Skip to content

Commit bbbf64a

Browse files
committed
Fix HMD_LDAP_TLS_CA not passing correctly and update README.md
1 parent d6822dd commit bbbf64a

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ Environment variables (will overwrite other server configs)
130130
| HMD_DROPBOX_CLIENTSECRET | no example | Dropbox API client secret |
131131
| HMD_GOOGLE_CLIENTID | no example | Google API client id |
132132
| HMD_GOOGLE_CLIENTSECRET | no example | Google API client secret |
133-
| HMD_LDAP_URL | ldap://example.com | url of LDAP server |
133+
| HMD_LDAP_URL | `ldap://example.com` | url of LDAP server |
134134
| HMD_LDAP_BINDDN | no example | bindDn for LDAP access |
135135
| HMD_LDAP_BINDCREDENTIALS | no example | bindCredentials for LDAP access |
136-
| HMD_LDAP_TOKENSECRET | supersecretkey | secret used for generating access/refresh tokens |
137-
| HMD_LDAP_SEARCHBASE | o=users,dc=example,dc=com | LDAP directory to begin search from |
138-
| HMD_LDAP_SEARCHFILTER | (uid={{username}}) | LDAP filter to search with |
136+
| HMD_LDAP_TOKENSECRET | `supersecretkey` | secret used for generating access/refresh tokens |
137+
| HMD_LDAP_SEARCHBASE | `o=users,dc=example,dc=com` | LDAP directory to begin search from |
138+
| HMD_LDAP_SEARCHFILTER | `(uid={{username}})` | LDAP filter to search with |
139139
| HMD_LDAP_SEARCHATTRIBUTES | no example | LDAP attributes to search with |
140-
| HMD_LDAP_TLS_CA | no example | Root CA for LDAP TLS in PEM format |
141-
| HMD_LDAP_PROVIDERNAME | My institution | Optional name to be displayed at login form indicating the LDAP provider |
140+
| HMD_LDAP_TLS_CA | `server-cert.pem, root.pem` | Root CA for LDAP TLS in PEM format (use comma to separate) |
141+
| HMD_LDAP_PROVIDERNAME | `My institution` | Optional name to be displayed at login form indicating the LDAP provider |
142142
| HMD_IMGUR_CLIENTID | no example | Imgur API client id |
143143
| HMD_EMAIL | `true` or `false` | set to allow email signin |
144144
| HMD_ALLOW_EMAIL_REGISTER | `true` or `false` | set to allow email register (only applied when email is set, default is `true`) |

lib/config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// external modules
2+
var fs = require('fs');
23
var path = require('path');
34

45
// configs
@@ -123,9 +124,17 @@ if (process.env.HMD_LDAP_SEARCHATTRIBUTES)
123124
ldap.searchAttributes = process.env.HMD_LDAP_SEARCHATTRIBUTES;
124125
if (process.env.HMD_LDAP_TLS_CA) {
125126
var ca = {
126-
ca: process.env.HMD_LDAP_TLS_CA
127+
ca: process.env.HMD_LDAP_TLS_CA.split(',')
128+
}
129+
ldap.tlsOptions = ldap.tlsOptions ? Object.assign(ldap.tlsOptions, ca) : ca;
130+
if (Array.isArray(ldap.tlsOptions.ca) && ldap.tlsOptions.ca.length > 0) {
131+
var i, len, results;
132+
results = [];
133+
for (i = 0, len = ldap.tlsOptions.ca.length; i < len; i++) {
134+
results.push(fs.readFileSync(ldap.tlsOptions.ca[i], 'utf8'));
135+
}
136+
ldap.tlsOptions.ca = results;
127137
}
128-
ldap.tlsOptions = ldap.tlsOptions ? Object.assign(ldap.tlsOptions, ca) : ca
129138
}
130139
if (process.env.HMD_LDAP_PROVIDERNAME) {
131140
ldap.providerName = process.env.HMD_LDAP_PROVIDERNAME;

0 commit comments

Comments
 (0)