Skip to content
Snippets Groups Projects
Commit ba15d2f0 authored by Olivér FACKLAM's avatar Olivér FACKLAM
Browse files

[ldaps] loading of tlsOptions in ldap/config.ts

parent ebd5c4b8
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ passport.use(new LdapStrategy({ ...@@ -45,7 +45,7 @@ passport.use(new LdapStrategy({
searchBase: ldapConfig.dn.user, // this field cannot be left empty. searchBase: ldapConfig.dn.user, // this field cannot be left empty.
searchFilter: '(uid={{username}})', // this field cannot be left empty. searchFilter: '(uid={{username}})', // this field cannot be left empty.
searchAttributes: ['uid', 'urlPhoto'], // only fetch the uid, no need for any other field searchAttributes: ['uid', 'urlPhoto'], // only fetch the uid, no need for any other field
//tlsOptions: '..........', tlsOptions: ldapConfig.tlsOptions,
//https://www.npmjs.com/package/passport-ldapauth for more //https://www.npmjs.com/package/passport-ldapauth for more
}, },
//usernameField: 'username', // Field name where the username is found, defaults to username //usernameField: 'username', // Field name where the username is found, defaults to username
......
...@@ -14,7 +14,7 @@ import ldapEscape from 'ldap-escape'; ...@@ -14,7 +14,7 @@ import ldapEscape from 'ldap-escape';
import {ldapConfig, credentialsLdapConfig} from './config'; import {ldapConfig, credentialsLdapConfig} from './config';
// Connection au serveur LDAP avec des temps de timeout arbitraires // Connection au serveur LDAP avec des temps de timeout arbitraires
var client = ldap.createClient({ url: ldapConfig.server}); var client = ldap.createClient({ url: ldapConfig.server, tlsOptions: ldapConfig.tlsOptions });
// Interface pratique pour que Typescript comprenne ce qu'est un dictionnaire simple // Interface pratique pour que Typescript comprenne ce qu'est un dictionnaire simple
interface dic { interface dic {
......
...@@ -31,6 +31,15 @@ else { ...@@ -31,6 +31,15 @@ else {
else ldapConfig.server = ldapConfig.server_dev; 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 };
// Gestion des super-identifiants // Gestion des super-identifiants
let path_credentials = path.resolve(__dirname, '..', '..', '..', 'ldap_credentials.json'); let path_credentials = path.resolve(__dirname, '..', '..', '..', 'ldap_credentials.json');
console.log(colors.green("Loading LDAP credentials from "+path_credentials)); console.log(colors.green("Loading LDAP credentials from "+path_credentials));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment