Skip to content
Snippets Groups Projects
Commit 02bc97f6 authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Fixes security issue. Do not allow overriding url and port for LDAP. Settings...

Fixes security issue. Do not allow overriding url and port for LDAP. Settings are set at /server/lib/ldap.coffee
parent e0a239cd
No related branches found
No related tags found
No related merge requests found
...@@ -140,6 +140,11 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) { ...@@ -140,6 +140,11 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) {
// Instantiate LDAP with options // Instantiate LDAP with options
var userOptions = loginRequest.ldapOptions || {}; var userOptions = loginRequest.ldapOptions || {};
// Don't allow overwriting url and port
delete userOptions.url;
delete userOptions.port;
var ldapObj = new LDAP(userOptions); var ldapObj = new LDAP(userOptions);
// Call ldapCheck and get response // Call ldapCheck and get response
...@@ -164,6 +169,14 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) { ...@@ -164,6 +169,14 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) {
// Login user if they exist // Login user if they exist
if (user) { if (user) {
if (user.ldap !== true) {
return {
userId: null,
error: "LDAP Authentication succeded, but there's already an existing user with provided username in Mongo."
};
}
userId = user._id; userId = user._id;
// Create hashed token so user stays logged in // Create hashed token so user stays logged in
...@@ -179,7 +192,8 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) { ...@@ -179,7 +192,8 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) {
// Otherwise create user if option is set // Otherwise create user if option is set
else if (ldapObj.options.createNewUser) { else if (ldapObj.options.createNewUser) {
var userObject = { var userObject = {
username: ldapResponse.username username: ldapResponse.username,
ldap: true
}; };
// Set email // Set email
if (ldapResponse.email) userObject.email = ldapResponse.email; if (ldapResponse.email) userObject.email = ldapResponse.email;
......
LDAP_DEFAULTS.url = "ldap://ldap.forumsys.com" LDAP_DEFAULTS.url = "ldap://ldap.forumsys.com"
\ No newline at end of file LDAP_DEFAULTS.port = '389'
LDAP_DEFAULTS.dn = false
\ No newline at end of file
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