diff --git a/.meteor/packages b/.meteor/packages index 51fbd8a7c..30ce6f899 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -174,3 +174,4 @@ blaze kadira:blaze-layout peerlibrary:blaze-components ejson +logging diff --git a/package-lock.json b/package-lock.json index 55b5a4bbf..4935361e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -477,17 +477,6 @@ "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==" }, - "bunyan": { - "version": "1.8.15", - "resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.15.tgz", - "integrity": "sha512-0tECWShh6wUysgucJcBAoYegf3JJoZWibxdqhTm7OHPeT42qdjkZ29QCMcKwbgU1kiH+auSIasNRXMLWXafXig==", - "requires": { - "dtrace-provider": "~0.8", - "moment": "^2.19.3", - "mv": "~2", - "safe-json-stringify": "~1" - } - }, "cacache": { "version": "17.1.3", "resolved": "https://registry.npmjs.org/cacache/-/cacache-17.1.3.tgz", @@ -814,15 +803,6 @@ "domhandler": "^4.2.0" } }, - "dtrace-provider": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.8.tgz", - "integrity": "sha512-b7Z7cNtHPhH9EJhNNbbeqTcXB8LGFFZhq1PGgEvpeHlzd36bhbdTWoE/Ba/YguqpBSlAPKnARWhVlhunCMwfxg==", - "optional": true, - "requires": { - "nan": "^2.14.0" - } - }, "duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", @@ -2712,62 +2692,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "mv": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz", - "integrity": "sha512-at/ZndSy3xEGJ8i0ygALh8ru9qy7gWW1cmkaqBN29JmMlIvM//MEO9y1sk/avxuwnPcfhkejkLsuPxH81BrkSg==", - "optional": true, - "requires": { - "mkdirp": "~0.5.1", - "ncp": "~2.0.0", - "rimraf": "~2.4.0" - }, - "dependencies": { - "glob": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", - "integrity": "sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==", - "optional": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "optional": true, - "requires": { - "minimist": "^1.2.6" - } - }, - "rimraf": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", - "integrity": "sha512-J5xnxTyqaiw06JjMftq7L9ouA448dw/E7dKghkP9WpKNuwmARNNg+Gk8/u5ryb9N/Yo2+z3MCwuqFK/+qPOPfQ==", - "optional": true, - "requires": { - "glob": "^6.0.1" - } - } - } - }, - "nan": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", - "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", - "optional": true - }, - "ncp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", - "integrity": "sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==", - "optional": true - }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -3177,12 +3101,6 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, - "safe-json-stringify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/safe-json-stringify/-/safe-json-stringify-1.2.0.tgz", - "integrity": "sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==", - "optional": true - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", diff --git a/package.json b/package.json index 6f64ff81f..a49763f7a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "ajv": "^6.12.6", "bcryptjs": "^2.4.3", "bson": "^4.5.2", - "bunyan": "^1.8.15", "core-js": "^3.32.0", "dompurify": "^2.4.1", "es6-promise": "^4.2.4", diff --git a/packages/wekan-ldap/server/ldap.js b/packages/wekan-ldap/server/ldap.js index 83d7d7960..6b1592fa3 100644 --- a/packages/wekan-ldap/server/ldap.js +++ b/packages/wekan-ldap/server/ldap.js @@ -1,7 +1,6 @@ import ldapjs from 'ldapjs'; import util from 'util'; -import Bunyan from 'bunyan'; -import {log_debug, log_info, log_warn, log_error} from './logger'; +import { Log } from 'meteor/logging' // copied from https://github.com/ldapjs/node-ldapjs/blob/a113953e0d91211eb945d2a3952c84b7af6de41c/lib/filters/index.js#L167 function escapedToHex (str) { @@ -67,7 +66,7 @@ export default class LDAP { } return value; } else { - log_warn(`Lookup for unset variable: ${name}`); + Log.warn(`Lookup for unset variable: ${name}`); } } @@ -87,7 +86,7 @@ export default class LDAP { } connectAsync(callback) { - log_info('Init setup'); + Log.info('Init setup'); let replied = false; @@ -134,15 +133,15 @@ export default class LDAP { connectionOptions.url = `ldap://${connectionOptions.url}`; } - log_info('Connecting', connectionOptions.url); - log_debug(`connectionOptions${util.inspect(connectionOptions)}`); + Log.info('Connecting', connectionOptions.url); + Log.debug(`connectionOptions${util.inspect(connectionOptions)}`); this.client = ldapjs.createClient(connectionOptions); this.bindSync = Meteor.wrapAsync(this.client.bind, this.client); this.client.on('error', (error) => { - log_error('connection', error); + Log.error('connection', error); if (replied === false) { replied = true; callback(error, null); @@ -150,12 +149,12 @@ export default class LDAP { }); this.client.on('idle', () => { - log_info('Idle'); + Log.info('Idle'); this.disconnect(); }); this.client.on('close', () => { - log_info('Closed'); + Log.info('Closed'); }); if (this.options.encryption === 'tls') { @@ -164,12 +163,12 @@ export default class LDAP { // https://github.com/mcavage/node-ldapjs/issues/349 tlsOptions.host = this.options.host; - log_info('Starting TLS'); - log_debug('tlsOptions', tlsOptions); + Log.info('Starting TLS'); + Log.debug('tlsOptions', tlsOptions); this.client.starttls(tlsOptions, null, (error, response) => { if (error) { - log_error('TLS connection', error); + Log.error('TLS connection', error); if (replied === false) { replied = true; callback(error, null); @@ -177,7 +176,7 @@ export default class LDAP { return; } - log_info('TLS connected'); + Log.info('TLS connected'); this.connected = true; if (replied === false) { replied = true; @@ -186,7 +185,7 @@ export default class LDAP { }); } else { this.client.on('connect', (response) => { - log_info('LDAP connected'); + Log.info('LDAP connected'); this.connected = true; if (replied === false) { replied = true; @@ -197,7 +196,7 @@ export default class LDAP { setTimeout(() => { if (replied === false) { - log_error('connection time out', connectionOptions.connectTimeout); + Log.error('connection time out', connectionOptions.connectTimeout); replied = true; callback(new Error('Timeout')); } @@ -218,7 +217,7 @@ export default class LDAP { const usernameFilter = this.options.User_Search_Field.split(',').map((item) => `(${item}=${username})`); if (usernameFilter.length === 0) { - log_error('LDAP_LDAP_User_Search_Field not defined'); + Log.error('LDAP_LDAP_User_Search_Field not defined'); } else if (usernameFilter.length === 1) { filter.push(`${usernameFilter[0]}`); } else { @@ -248,7 +247,7 @@ export default class LDAP { userDn = `${this.options.User_Authentication_Field}=${username},${this.options.BaseDN}`; } - log_info('Binding with User', userDn); + Log.info('Binding with User', userDn); this.bindSync(userDn, password); this.domainBinded = true; @@ -263,7 +262,7 @@ export default class LDAP { return; } - log_info('Binding UserDN', this.options.Authentication_UserDN); + Log.info('Binding UserDN', this.options.Authentication_UserDN); this.bindSync(this.options.Authentication_UserDN, this.options.Authentication_Password); this.domainBinded = true; @@ -286,9 +285,9 @@ export default class LDAP { }; } - log_info('Searching user', username); - log_debug('searchOptions', searchOptions); - log_debug('BaseDN', this.options.BaseDN); + Log.info('Searching user', username); + Log.debug('searchOptions', searchOptions); + Log.debug('BaseDN', this.options.BaseDN); if (page) { return this.searchAllPaged(this.options.BaseDN, searchOptions, page); @@ -326,9 +325,9 @@ export default class LDAP { scope: 'sub', }; - log_info('Searching by id', id); - log_debug('search filter', searchOptions.filter.toString()); - log_debug('BaseDN', this.options.BaseDN); + Log.info('Searching by id', id); + Log.debug('search filter', searchOptions.filter.toString()); + Log.debug('BaseDN', this.options.BaseDN); const result = this.searchAllSync(this.options.BaseDN, searchOptions); @@ -337,7 +336,7 @@ export default class LDAP { } if (result.length > 1) { - log_error('Search by id', id, 'returned', result.length, 'records'); + Log.error('Search by id', id, 'returned', result.length, 'records'); } return result[0]; @@ -351,9 +350,9 @@ export default class LDAP { scope : this.options.User_Search_Scope || 'sub', }; - log_info('Searching user', username); - log_debug('searchOptions', searchOptions); - log_debug('BaseDN', this.options.BaseDN); + Log.info('Searching user', username); + Log.debug('searchOptions', searchOptions); + Log.debug('BaseDN', this.options.BaseDN); const result = this.searchAllSync(this.options.BaseDN, searchOptions); @@ -362,7 +361,7 @@ export default class LDAP { } if (result.length > 1) { - log_error('Search by username', username, 'returned', result.length, 'records'); + Log.error('Search by username', username, 'returned', result.length, 'records'); } return result[0]; @@ -393,7 +392,7 @@ export default class LDAP { scope : 'sub', }; - log_debug('Group list filter LDAP:', searchOptions.filter); + Log.debug('Group list filter LDAP:', searchOptions.filter); const result = this.searchAllSync(this.options.BaseDN, searchOptions); @@ -406,7 +405,7 @@ export default class LDAP { result.map((item) => { groups.push(item[grp_identifier]); }); - log_debug(`Groups: ${groups.join(', ')}`); + Log.debug(`Groups: ${groups.join(', ')}`); return groups; } @@ -441,7 +440,7 @@ export default class LDAP { scope : 'sub', }; - log_debug('Group filter LDAP:', searchOptions.filter); + Log.debug('Group filter LDAP:', searchOptions.filter); const result = this.searchAllSync(this.options.BaseDN, searchOptions); @@ -475,7 +474,7 @@ export default class LDAP { this.bindIfNecessary(); const processPage = ({ entries, title, end, next }) => { - log_info(title); + Log.info(title); // Force LDAP idle to wait the record processing this.client._updateIdle(true); page(null, entries, { @@ -489,13 +488,13 @@ export default class LDAP { this.client.search(BaseDN, options, (error, res) => { if (error) { - log_error(error); + Log.error(error); page(error); return; } res.on('error', (error) => { - log_error(error); + Log.error(error); page(error); return; }); @@ -526,7 +525,7 @@ export default class LDAP { end : true, }); } else if (entries.length) { - log_info('Page'); + Log.info('Page'); processPage({ entries, title: 'Page', @@ -555,13 +554,13 @@ export default class LDAP { this.client.search(BaseDN, options, (error, res) => { if (error) { - log_error(error); + Log.error(error); callback(error); return; } res.on('error', (error) => { - log_error(error); + Log.error(error); callback(error); return; }); @@ -573,25 +572,25 @@ export default class LDAP { }); res.on('end', () => { - log_info('Search result count', entries.length); + Log.info('Search result count', entries.length); callback(null, entries); }); }); } authSync(dn, password) { - log_info('Authenticating', dn); + Log.info('Authenticating', dn); try { if (password === '') { throw new Error('Password is not provided'); } this.bindSync(dn, password); - log_info('Authenticated', dn); + Log.info('Authenticated', dn); return true; } catch (error) { - log_info('Not authenticated', dn); - log_debug('error', error); + Log.info('Not authenticated', dn); + Log.debug('error', error); return false; } } @@ -599,7 +598,7 @@ export default class LDAP { disconnect() { this.connected = false; this.domainBinded = false; - log_info('Disconecting'); + Log.info('Disconecting'); this.client.unbind(); } }